0% found this document useful (0 votes)
5 views

Python Programm to Print the Largest and Smallest

Uploaded by

arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python Programm to Print the Largest and Smallest

Uploaded by

arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Programme to print the largest and smallest among ten given numbers

without storing it in list.


largest = None
smallest = None
print("Enter 10 numbers:")
for i in range(10):
num = float(input(f"Enter number {i + 1}: "))
# Update largest and smallest
if largest is None or num > largest:
largest = num
if smallest is None or num < smallest:
smallest = num

print(f"The largest number is: {largest}")


print(f"The smallest number is: {smallest}")

Programme to print the largest and smallest among ten given numbers by
storing it in list.
numbers = []
print("Enter 10 numbers:")
for i in range(10):
num = float(input(f"Enter number {i+1}: "))
numbers.append(num)
largest = max(numbers)
smallest = min(numbers)
print(f"The largest number is: {largest}")
print(f"The smallest number is: {smallest}")

You might also like