Your browser does not support JavaScript!
Please enable JavaScript to use the full functionality of the site.
Without JavaScript, you will not be able to expand the content tables in the PD Materials Page and CSP Index Page.

PD4CS

Professional Development for CS Principles Teaching

Log in

Menu

Skip to content
  • Home
  • CSP Index
  • PLTW Index
  • Resources
  • About

Home » Loops » Loops – Python » Example 3: Print all the integers from 1 to 1000 that are multiples of both 6 and 10.

Example 3: Print all the integers from 1 to 1000 that are multiples of both 6 and 10.

Yizhou QianJune 21, 20140

The program will again use the range function in a for loop. The first three integers printed will be 30, 60, and 90.

# 02Loops example_03 PrintIntegers.py
for number in range(1,1001):
    if(number % 6 ==0 and number % 10 ==0):
        print number

Recall that % is the remainder operator (for example, 10%6 = 4).

This entry was posted in Loops – Python. Bookmark the permalink.

Post navigation

nsf1 This work is supported by the National Science Foundation under grant number 1502462. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation"
Proudly powered by WordPress | If you have questions, please contact PD4CS Research Team