Задача по Python?

Marina10

Новичок
Пользователь
Апр 29, 2020
12
0
1
Условие следующее:
At the warm-up event for Oscar’s All Star Hot Dog Eating Contest, Al ate one
hot dog. Bob then showed him up by eating three hot dogs. Not to be outdone
Carl ate five. This continued with each contestant eating two more hot dogs
than the previous contestant. How many hot dogs did Zeno (the 26th and final
contestant) eat?
Если честно у меня не совсем получается отследить логику, как можно написать такой код на Python. У меня пока что получается следующее и естественно код не работает:
def hot_dog(guest_number):
hot_dogs_number = [1,]
for person in range(1,guest_number):
if person == 1:
print(1)
elif person > 1:
hot_dog = hot_dogs_number[:1] + 2
hot_dogs_number.append(hot_dog)
print(hot_dogs_number[-1])
 

MaksimD

Пользователь
Пользователь
Май 12, 2020
51
11
8
Условие следующее:
At the warm-up event for Oscar’s All Star Hot Dog Eating Contest, Al ate one
hot dog. Bob then showed him up by eating three hot dogs. Not to be outdone
Carl ate five. This continued with each contestant eating two more hot dogs
than the previous contestant. How many hot dogs did Zeno (the 26th and final
contestant) eat?
Если честно у меня не совсем получается отследить логику, как можно написать такой код на Python. У меня пока что получается следующее и естественно код не работает:
def hot_dog(guest_number):
hot_dogs_number = [1,]
for person in range(1,guest_number):
if person == 1:
print(1)
elif person > 1:
hot_dog = hot_dogs_number[:1] + 2
hot_dogs_number.append(hot_dog)
print(hot_dogs_number[-1])
Код:
def getHotDogs(N):
    a = (N+1)
    b = (N+2)
    res = int(a)+int(b)
    print(res)

if __name__ == '__main__':
    getHotDogs(26)
 

Форум IT Специалистов