I Haz Codes

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Menu
Even Stevens…

Enter the code below. Currently the program will print out the numbers from 1 to 10. We are going to change it so it prints out the first 10 even numbers. It should display the following –

2
4
6
8
10
12
14
16
18
20

Change the code as follows –

  • Change “x=0” to start on 2.
  • Change “while x <= 10” to end at 20.
  • change “x =x + 1” to add two instead of one.
 
x = 0
while x <= 10:
    print(x)
    x = x + 1

Leave a Reply

Your email address will not be published. Required fields are marked *

Information