Explanation of For Loops: Exercise and Solution 6
Exercise
Exercise 6:
Write a program that read three persons' heights and display the best sport fits to this person according to the following table.
Foor Loop
| Tall in CM |
Best sport |
| < 159 |
Tennis |
| between 160 & 175 |
Football aka Soccer |
| > 175 |
Basketball |
Code
See below the code and output:
for i in range (1,4):
height = float(input("Enter your height in CM: "))
if (height<165):
print ("The best sport is Tennis")
elif (height ≥ 166 and height ≤ 175):
print ("The best sport is Football")
elif (height >175):
print ("The best sport is Basketball")
For more details, please contact me here.