asked 147k views
2 votes
Write a program that asks the user to enter the number of pancakes eaten for breakfast by 10 different people (Person 1, Person 2, ..., Person 10) Once the data has been entered the program must analyze the data and output which person ate the most pancakes for breakfast.

1 Answer

1 vote

Answer:

The program written in python is as follows

persons = []

most = 0

personindex = 0

for i in range(1,11):

print("Person ",i)

pancake = int(input(": "))

persons.append(pancake)

if pancake > most:

most = pancake

personindex = i

print("Person ",personindex," ate most pancakes")

Step-by-step explanation:

This line initializes an empty list

persons = []

This line initializes variable most to 0

most = 0

This line initializes variable personindex to 0

personindex = 0

This line iterates from 1 to 10

for i in range(1,11):

The next two line prompts user for input

print("Person ",i)

pancake = int(input(": "))

This line inserts the user input to the created list "persons"

persons.append(pancake)

The next if statement checks for the person with the most pancakes

if pancake > most:

most = pancake

personindex = i

This line prints the person with most pancakes

print("Person ",personindex," ate most pancakes")

answered
User Phfsck
by
7.9k points