摘要: # -*- coding:utf-8 -*- ## Animal is-a object (yes,sort of confusing) look at the extra credit class Animal(object): pass ## 添加在动物的子类狗?? class Dog(Animal): def __init__ (self,name): s... 阅读全文
posted @ 2016-11-28 14:20 听风呤 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 1 # create a mapping of state to abbreviation 2 states = { 3 'Oregon': 'OR', 4 'Florida': 'FL', 5 'California': 'CA', 6 'New York': 'NY', 7 'Michigan': 'MI' 8 } 9 10 #ct... 阅读全文
posted @ 2016-11-25 23:53 听风呤 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 1 class song(object): 2 3 def __init__(self, lytics): 4 self.lyrics = lytics 5 6 def sing_me_a_song(self): 7 for line in self.lyrics: 8 print (line) 9 ... 阅读全文
posted @ 2016-11-25 23:53 听风呤 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 1 # -*- coding:GBK -*- 2 animals = ["熊", "python", "孔雀", "袋鼠", "鲸鱼", "鸭嘴兽"] 3 4 place1 = animals[0] 5 print ("the place1 animal is %r." % place1) 6 7 no3 = animals[3] 8 print ("the no3 anim... 阅读全文
posted @ 2016-11-23 23:25 听风呤 阅读(791) 评论(0) 推荐(0) 编辑
摘要: 1 from sys import exit 2 3 def gold_room(): 4 print ("This room is full of gold. how much do you take?") 5 6 7 next = input(">") 8 if "0" in next or "1"in next: 9 ... 阅读全文
posted @ 2016-11-23 23:25 听风呤 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 1 i = 1 2 numbers = [] 3 4 while i <= 8: 5 print ("At the top i is %d" % i) 6 numbers.append(i) 7 i = i * 2 8 print ("Numbers now:",numbers) 9 print ("At the bottom i is... 阅读全文
posted @ 2016-11-23 23:24 听风呤 阅读(352) 评论(0) 推荐(0) 编辑
摘要: 1 # -*- coding:utf-8 -*- 2 the_count = [1,2,3,4,5] 3 fruits = ['appples', 'oranges', 'pears', 'apricots'] 4 change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] 5 6 #this frist kind of for-loop ... 阅读全文
posted @ 2016-11-23 15:04 听风呤 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 1 people = 30 2 cars = 40 3 buses = 50 4 5 if cars > people: 6 print ("We should take the cars.") 7 elif cars cars: 13 print ("That's too many buses.") 14 elif buses buses: 20 p... 阅读全文
posted @ 2016-11-23 15:03 听风呤 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 1 print ("You enter a dark room witn two doors.Do you go through door #1 or door #2?") 2 3 door = input(">>>") 4 5 if door == "1": 6 print ("There 's a giant bear here eating a cheese cak... 阅读全文
posted @ 2016-11-23 15:03 听风呤 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 1 people = 20 2 cats = 30 3 dogs = 15 4 5 if people cats: 9 print ("Not many cats! The world is saved!") 10 11 if people dogs: 15 print ("The world is dry!") 16 17 18 dogs += 5 19... 阅读全文
posted @ 2016-11-23 15:02 听风呤 阅读(162) 评论(0) 推荐(0) 编辑