Skip to content

Commit

Permalink
complete ex1-ex4
Browse files Browse the repository at this point in the history
  • Loading branch information
hstaoqian committed Dec 20, 2016
1 parent fe9555c commit 8d836d0
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ex1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
print "Hello World!"
print "Hello Again"
print "I like typing this."
print "This is fun."
print 'Yay! Printing.'
print "I'd much rather you 'not'."
print 'I "said" do not touch this.'
9 changes: 9 additions & 0 deletions ex2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# A comment, this is so you can read your program later.
# Anything after the # is ignored by python.

print "I could have code like this." # and the comment after is ignored

# You can also use a comment to "disable" or comment out a piece of code:
# print "This won't run."

print "This will run."
33 changes: 33 additions & 0 deletions ex3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 在console输出
print "I will now count my chickens:"

# 在console输出,逗号后的部分做计算
print "Hens", 25 + 30 / 6
print "Roosters", 100 - 25 * 3 % 4

# 在console输出
print "Now I will count the eggs:"

# 计算
print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6

# 在console输出
print "Is it true that 3 + 2 < 5 - 7?"

# 在console输出不等式两边比较大小的结果
print 3 + 2 < 5 - 7

# 在cosole输出,并做计算
print "What is 3 + 2?", 3 + 2
print "What is 5 - 7?", 5 - 7

# 在console输出
print "Oh, that's why it's False."

# 在console输出
print "How about some more."

# 在console输出,并比较不等式两边的大小
print "Is it greater?", 5 > -2
print "Is it greater or equal?", 5 >= -2
print "Is it less or equal?", 5 <= -2
16 changes: 16 additions & 0 deletions ex4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_driven


print "There are", cars, "cars available."
print "There are only", drivers, "drivers available."
print "There will be", cars_not_driven, "empty cars today."
print "We can transport", carpool_capacity, "people today."
print "We have", passengers, "to carpool today."
print "We need to put about", average_passengers_per_car, "in each car."

0 comments on commit 8d836d0

Please sign in to comment.