Robotics & Artificial Intelligence
Write a program to input 10 different numbers. Display the greatest and the smallest numbers among them.
Python Control Flow
3 Likes
Answer
n = int(input("Enter a number: "))
greatest = n
smallest = n
for i in range(1, 10):
n = int(input("Enter a number: "))
if(n > greatest):
greatest = n
if(n < smallest):
smallest = n
print("Greatest number =", greatest)
print("Smallest number =", smallest)Output
Enter a number: 12
Enter a number: 56
Enter a number: 45
Enter a number: 78
Enter a number: 19
Enter a number: 20
Enter a number: 30
Enter a number: 41
Enter a number: 87
Enter a number: 90
Greatest number = 90
Smallest number = 12
Answered By
1 Like
Related Questions
Write a program to enter a number and display the sum of its digits.
Sample Input: 642
Output: 12 (6+4+2 = 12)
Write a Python code to check and display whether a number input by the user is a composite number or not.
[A number is said to composite, if it has one or more factors excluding 1 and the number itself. For example: 4, 6, 8, 9, ……………]
Write a program to input a number. Check and display whether it is a Niven Number or not. (A number is said to be Niven when it is divisible by the sum of its digits).
Sample Input: 126
Sum of its digits = 1 + 2 + 6 = 9 and 126 is divisible by 9.
Write a program to input a number and display the new number after reversing the digits.
Sample Input: 467
Sample Output: 764