3. Counters¶
Now print from 1 to a number entered by the user
6
end = int(input("Enter the last number: "))
x = 1
while x <= end:
print(x)
x = x + 1
Activity: 3.1 ActiveCode (ac_l15_3a_en)
Print even numbers between 0 and a number given by the user using
if
7
end = int(input("Enter the last number: "))
x = 0
while x <= end:
if x%2 == 0:
print(x)
x = x + 1
Activity: 3.2 ActiveCode (ac_l15_3b_en)
Print even numbers between 0 and a provided number without using
if
6
end = int(input("Enter the last number: "))
x = 0
while x <= end:
print(x)
x = x + 2
Activity: 3.3 ActiveCode (ac_l15_3c_en)
3.1. Some Exercises¶
Modify the previous program to print from 1 to the number entered by the user, but this time only the odd numbers.
2
Activity: 3.1.1 ActiveCode (ac_l15_3d_en)
Write a program that prints the first 10 multiples of 3.
2
Activity: 3.1.2 ActiveCode (ac_l15_3e_en)
You have attempted 1 of 6 activities on this page