forked from lugnitdgp/Learn-Python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsamplewhile.py
More file actions
Latest commit
19 lines (17 loc) · 695 Bytes
/
Copy pathsamplewhile.py
File metadata and controls
19 lines (17 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# A while-loop will keep executing the code block under it as long as a boolean expression is True.
# If we write a line and end it with a colon then that tells Python to start a new block of code.
# Then we indent and that is the new code.
# This is all about structuring your programs so that Python knows what you mean.
# If you do not get that idea then go back and do some more work with if-statements, functions, and the for-loop until you get it.
# SAMPLE CODE
i=0
numbers= []
whilei<6:
print"At the top i is %d"%i
numbers.append(i)
i=i+1
print"Numbers now: ", numbers
print"At the bottom i is %d"%i
print"The numbers: "
fornuminnumbers:
printnum