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!

Software ==> Python  (28 exercises)
Version ==> Latest version
Topic ==> Sequences  (7 exercises)
Level ==> Relatively easy
Classroom ==> Python programming
Online ==> Python programming

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:

Final numbers

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!

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post