Loops (Need) Exercises

Exercise 1 (Celcius to Farenheit)

You are provided with the following list of temperatures in Celsius. Write a quick Python snippet that converts each temperature to Fahrenheit and prints both temperatures.

temperatures_celsius = [
    0, 5, 10, 15, 20, 25,
    30, 35, 40, 45, 50
]

Exercise 2 (Multiplication table)

You can put a loop within a loop to do doubly loopy stuff. Here is an example:

for letter in ['A', 'B', 'C']:
    for number in [1, 2, 3]:
        print(f'{letter}{number}', end='\t')
    print('\n')
A1  A2  A3  

B1  B2  B3  

C1  C2  C3  

Try this out and explore.

Write a Python snippet that prints a multiplication table (up to 5) for numbers 1 through 5 using nested for loops. The output should be formatted as shown below:

1 : 1   2   3   4   5   
2 : 2   4   6   8   10  
3 : 3   6   9   12  15  
4 : 4   8   12  16  20  
5 : 5   10  15  20  25  
Back to top