Skip to content

Commit

Permalink
Finished chapter 2
Browse files Browse the repository at this point in the history
  • Loading branch information
chenguohui committed Jun 29, 2017
1 parent 6c83612 commit 1c472f4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chap02/exitExample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sys
while True:
print('Type exit to exit.')
response = input()
if response == 'exit':
sys.exit()
print('You typed ' + response + '.')
9 changes: 9 additions & 0 deletions chap02/fiveTimes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
print('My name is')
for i in range(5):
print('Jimmy Five Times (' + str(i) + ')')

print()
i = 0
while i < 5:
print('Jimmy Five Times (' + str(i) + ')')
i += 1
3 changes: 3 additions & 0 deletions chap02/printRandom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import random
for i in range(5):
print(random.randint(1, 10))
5 changes: 5 additions & 0 deletions chap02/yourName.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name = ''
while name != 'your name':
print('Please type your name.')
name = input()
print('Thank you!')
6 changes: 6 additions & 0 deletions chap02/yourName2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')

0 comments on commit 1c472f4

Please sign in to comment.