Exercises
- Use
Thonny
for writing your code.
Exercise 12
Save your code in your Python
folder and call it exercise12
.
Write a program that prints values from 0 to 100 using a for
loop.
Help
Go back to the for loop section of the course and check the first example for the range
function.
Exercise 13
Save your code in your Python
folder and call it exercise13
.
Write a program that sums the numbers between 100 and 200 using a for
loop and prints the final result.
Help
- Initialise a variable
total
to 0. - Use a
for
with arange
function to create a sequence going from 100 to 200 included (see example 2 in range function section). - Inside the for loop add the iterator to the
total
variable.
Exercise 14
Save your code in your Python
folder and call it exercise14
.
Write a program printing the multiplication table of 3 using a loop (you can choose the one you prefer).
Help
- Use a
for
with a range function to create a sequence going from 1 to 10 included. - Print the calculation and the result:
Exercise 15
Save your code in your Python
folder and call it exercise15
.
Write a program that asks for a number n as an input and prints a square with n “X” per side.
For example, if the number n is 6, the result should be: