🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X
Questions




































Write a Python program which takes list of numbers as input and finds: (i) The largest number in the list (ii) The smallest number in the list (iii) Product of all the items in the list

Last Updated : 16 Jul 2025 Jul 21, Jan 22, Jan 23

Solution:

# Initialize an empty list
mylist = []

# Get the number of elements from the user
tn = int(input("How many numbers do you want to enter? "))

# Collect numbers from the user and append to the list
for i in range(tn):
    item = int(input("Enter a number: "))
    mylist.append(item)

# Print the greatest number
print("Greatest number =", max(mylist))

# Print the smallest number
print("Smallest number =", min(mylist))

# Initialize the product variable
product = 1

# Calculate the product of all numbers in the list
for i in mylist:
    product *= i

# Print the product
print("Product =", product)
OUTPUT:

How many numbers do you want to enter? 5
Enter a number: 14
Enter a number: -9
Enter a number: 7
Enter a number: 20
Enter a number: 15
Greatest number = 20
Smallest number = -9
Product = -264600

 

Explanation:

  • Initialize List: Create an empty list mylist.
  • Input Numbers: Get the number of entries from the user and collect numbers into mylist.
  • Greatest and Smallest: Print the largest (max()) and smallest (min()) numbers.
  • Product: Compute and print the product of all numbers in mylist.
Report an error

Meanwhile you can watch this video

Watch Video
Latest Updates