Computer Science
Given three numbers A, B and C, write a program to write their values in an ascending order. For example, if A = 12, B = 10, and C = 15, your program should print out:
Smallest number = 10
Next higher number = 12
Highest number = 15
Python
Python Control Flow
23 Likes
Answer
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
if a < b and a < c :
small = a
if b < c :
middle = b
large = c
else :
middle = c
large = b
elif b < a and b < c :
small = b
if a < c :
middle = a
large = c
else :
middle = c
large = a
else :
small = c
if a < b :
middle = a
large = b
else :
middle = b
large = a
print("Smallest number =", small)
print("Next higher number =", middle)
print("Highest number =", large)
Output
Enter first number: 10
Enter second number: 5
Enter third number: 15
Smallest number = 5
Next higher number = 10
Highest number = 15
Answered By
11 Likes
Related Questions
Write a program using nested loops to produce a rectangle of *'s with 6 rows and 20 *'s per row.
Write programs using nested loops to produce the following patterns:
2
4 4
6 6 6
8 8 8 8Write a Python script to input temperature. Then ask them what units, Celsius or Fahrenheit, the temperature is in. Your program should convert the temperature to the other unit. The conversions are:
F = 9/5C + 32 and C = 5/9 (F 32).
Ask the user to enter a temperature in Celsius. The program should print a message based on the temperature:
- If the temperature is less than -273.15, print that the temperature is invalid because it is below absolute zero.
- If it is exactly -273.15, print that the temperature is absolute 0.
- If the temperature is between -273.15 and 0, print that the temperature is below freezing.
- If it is 0, print that the temperature is at the freezing point.
- If it is between 0 and 100, print that the temperature is in the normal range.
- If it is 100, print that the temperature is at the boiling point.
- If it is above 100, print that the temperature is above the boiling point.