您的位置:首页 > 其它

第三周作业

2018-03-25 21:02 267 查看
5.6
age = 13

if age < 2:
print("He is a baby")
elif age >= 2 and age < 4:
print("He is learning to walk")
elif age >= 4 and age < 13:
print("He is a child")
elif age >= 13 and age < 20:
print("He is a teenger")
elif age >= 20 and age < 65:
print("He is an adult")
elif age >= 65:
print("He is an old")

5.7
favorite_fruits = ["apple", "banana", "pear"]

if "apple" in favorite_fruits:
print("You really like apples!")

if "orange" in favorite_fruits:
print("You really like oranges!")

if "banana" in favorite_fruits:
print("You really like bananas!")

if "strawberry" in favorite_fruits:
print("You really like strawberrys!")

if "pear" in favorite_fruits:
print("You really like pears!")

5.11
nums = range(1, 9 + 1)

for num in nums:
if num == 1:
print(str(num) + "st")
elif num == 2:
print(str(num) + "nd")
elif num == 3:
print(str(num) + "rd")
else:
print(str(num) + "th")

6.1
person = {
'first_name': 'chen',
'last_name': 'pengyu',
'age': '20',
'city': 'Guangzhou',
}

print("He is " + person['first_name'].title() + " " +
person['last_name'].title() + ", and he is " + person['age'] +
' years old. And he lives in ' + person['city'].title() + ' city.')

6.8
dog_1 = {'kind': 'dog', 'host': 'lala'}
cat_1 = {'kind': 'cat', 'host': 'sasa'}
rabbit_1 = {'kind': 'rabbit', 'host': 'angle'}

pets = [dog_1, cat_1, rabbit_1]

for pet in pets:
print(pet)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: