Robotics & Artificial Intelligence
Write a program to find the smallest number among three numbers by using the nested 'if-else' statements.
Python Control Flow
2 Likes
Answer
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
if a < b:
if a < c:
print("Smallest number is:", a)
else:
print("Smallest number is:", c)
else:
if b < c:
print("Smallest number is:", b)
else:
print("Smallest number is:", c)Output
Enter first number: 5
Enter second number: 8
Enter third number: 3
Smallest number is: 3
Answered By
2 Likes
Related Questions
Fill in the blanks:
- ……………. is used to repeat a block of code until a certain condition is met.
- ……………. statement in a loop is used to break the execution of the loop.
- ……………. keyword is used to create an empty loop.
- ……………. statement is used to skip the current iteration of the loop and move to the next.
- ……………. loop is used to iterate over a sequence of items.
Explain the use of break statement in Python with the help of an example.
Write a Python program to check that if a given number is even or odd.
Write a Python program to add all the elements of a tuple.