Python | Sequences exercise | Print out numbers divisible by 3 but not by 2
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
You can learn how to do this exercise if you attend the course listed below!
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
In a new program, create a variable to hold the first 50 integers.
Loop over the values in this range, printing out those which are divisible by 3 but not by 2:
The program should produce this output. You can test whether one number is divisble by another by using the % symbol to find its remainder, and testing if this is 0 (for example 23 % 5 woudl give 3, the remainder when you divide 23 by 5).
While reflecting on whether you will ever use this program in anger, close it down!