Download presentation
Presentation is loading. Please wait.
1
class 4 definite loops range list end=" "
in loop, after loop – indentation matters simultaneous assignment simultaneous input using the debugger in thonny retrieving previous statement in thonny or IDLE shell
2
module doesn't print without a print statement (ie, nothing like >>>a)
In shell: >>>x=3 >>>x 3 In module: x=3 x no output
3
definite loop
4
for i in range(5): print("i=",i)
5
for i in range(5): print("i=",i) i= 0 i= 1 i= 2 i= 3 i= 4
6
CODE for k in range(5): print(2*k, end=" ")
7
CODE for k in range(5): print(2*k, end=" ") OUTPUT
8
CODE for k in range(5): print(2*k+1, end=" ")
9
CODE for k in range(5): print(2*k+1, end=" ") OUTPUT
10
CODE m = 5 for k in range(m): print(100+2*k+1, end=", ") print(100+2*m+1)
11
CODE m = 5 for k in range(m): print(100+2*k+1, end=", ") print(100+2*m+1) OUTPUT 101, 103, 105, 107, 109, 111
12
CODE m = 5 for k in range(m): print(100+2*k+1, end=", ") print() print(100+2*m+1)
13
CODE m = 5 for k in range(m): print(100+2*k+1, end=", ") print() print(100+2*m+1) OUTPUT 101, 103, 105, 107, 109, 111
14
CODE m = 5 for k in range(m): print(100+2*k+1, end=", ") print() print(100+2*m+1)
15
CODE m = 5 for k in range(m): print(100+2*k+1, end=", ") print() print(100+2*m+1) OUTPUT 101, 103, 105, 107, 109, 111
16
Indentation Matters! CODE m = 5 for k in range(m):
print(100+2*k+1, end=", ") print() print(100+2*m+1) OUTPUT 101, 103, 105, 107, 109, 111 Indentation Matters!
17
CODE for k in [101, 103, 105, 107, 109]: print(k, end=", ") print() print(111)
18
CODE for k in [101, 103, 105, 107, 109]: print(k, end=", ") print() print(111) OUTPUT 101, 103, 105, 107, 109, 111
19
What if I asked for odd numbers 101 to 1001?
CODE for k in [101, 103, 105, 107, 109]: print(k, end=", ") print() print(111) What if I asked for odd numbers 101 to 1001? OUTPUT 101, 103, 105, 107, 109, 111
20
CODE list(range(4))
21
CODE list(range(4)) OUTPUT [0, 1, 2, 3]
22
Simultaneous Assignment (draw memory)
long, lat = 43.0, 76.1 month, day, yr = eval(input("month, day, year"))
23
Debugger review an example view the variables area
debug, step over, step into
24
retrieving previous statements in the shell.
In Thonny, up and down arrow keys. In IDLE: mac: control p (previous), control n (next) windows: alt p, alt n
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.