Day 13
Lesson 36
(因个人想象力比较丰富 也加上)学这么多课了 正好就此机会写一个小程序吧~ 我这次打算每天写一点 尽量写一个完整的 我想的是每天写一个函数 并把未来需要的函数命名出来 今日份~
import sys
def forest(heart):
print("You wake up and you find yourself in a dark dark forest.")
print("You have two choices, 1. walk forward and try to find a road 2. try to find a flashlight")
print("Please type 1 or 2:")
c = input()
if c == '1':
print("You can't see anything and you tripped on a tree and you hurt yourself, heart-1")
heart -= 1
if heart == 0:
print("You have ran out of heart, too bad! Game over.")
sys.exit()
else:
print("Be careful! You only have %d heart left!" % heart)
if c == '2':
print("You knee down and try to see if there's anything on the ground, and, there's a flashlight!")
print("You turn on the flashlight and see there's a little house in front")
print("Will you knock on the door? 1. Yes 2. No")
c = input()
if c=='1':
house(heart)
else:
walk(heart)
def house(heart):
def walk(heart):
Lesson 37
这课我就不多说了 这个… 就只能背了 需要更多文档也可以去官网找~
Lesson 38
嗯… 这本书讲得比较慢 当然 不是坏事 练习比较多…
但是 既然有这个练习机会 我就也建议大家不要一模一样的copy书上的内容 尽量自己写
ten = "Dog Cat Fish Chip Chocolate Cake"
print ("Wait there are not 10 things in that list. Let's fix that.")
stuff = ten.split(' ')
more = ["Bed", "Table", "Chair", "Light", "Wall", "Laptop", "Pencil", "TV"]
while len(stuff) != 10:
next = more.pop()
print("Adding: ", next)
stuff.append(next)
print("There are %d items now." % len(stuff))
print("There we go: ", stuff)
print("Let's do some things with stuff.")
print(stuff[1])
print(stuff[-1])
print(stuff.pop())
print(' '.join(stuff))
print('#'.join(stuff[3:5]))
好啦 今天三课打卡完成~
Au revoir~