finds the largest of the input numbers:
# get the number of input numbers
n = int(input("Enter the number of input numbers: ")) # get the input numbers numbers = [] for i in range(n): num = int(input("Enter number {}: ".format(i+1))) numbers.append(num) # find the largest number largest = max(numbers) # print the largest number print("The largest number is:", largest) In this program, we first get the number of input numbers from the user. Then, we ask the user to enter each input number and store them in a list called `numbers`. Finally, we use the `max()` function to find the largest number in the list, and print it out.
Comments
Post a Comment