【HW】第五章作业 2018.3.19
2018-03-19 20:23
453 查看
Python代码:#Chapter 5 by szh 2018.3.19
print("\n5.2")
print("student" == "Student")
print("student" == "Student".lower())
print(12 == 12)
print(12 != 13)
print(12 >= 13)
print(12 < 13 and 13 > 14)
print(12 > 13 or 12 < 13)
nums = [1, 2, 3, 4, 5]
print(3 in nums)
print(6 not in nums)
print("\n5.3")
alien_color = 'green'
if alien_color == 'green':
print("You got 5 points!")
print("\n5.4")
alien_color = 'yellow'
if alien_color == 'green':
print("You got 5 points!")
else:
print("You got 10 points!")
print("\n5.5")
alien_color = 'red'
if alien_color == 'green':
print("You got 5 points!")
elif alien_color == 'yellow':
print("You got 10 points!")
else:
print("You got 15 points!")
print("\n5.6")
ages = [1, 3, 10, 18, 40, 70]
for age in ages:
if age < 2:
print("He is a baby.")
elif age < 4:
print("He is learn to walk.")
elif age < 13:
print("He is a children.")
elif age < 20:
print("He is a teenager.")
elif age < 65:
print("He is a adult.")
else:
print("He is a elder.")
print("\n5.7")
favorite_fruits = ['apple', 'banana', 'watermelon']
question_fruits = ['apple', 'banana', 'watermelon', 'orange', 'kiwi']
for fruit in question_fruits:
if fruit in favorite_fruits:
print("You really like " + fruit)
else:
print("You don't like the " + fruit)
print("\n5.8")
names = ['admin', 'Alice', 'Bob', 'Eric', 'Jack']
for name in names:
if name == 'admin':
print("Hello admin, would you like to see a status report?")
else:
print("Hello " + name + ", thank you for logging in again")
输出结果:5.2
False
True
True
True
False
False
True
True
True
5.3
You got 5 points!
5.4
You got 10 points!
5.5
You got 15 points!
5.6
He is a baby.
He is learn to walk.
He is a children.
He is a teenager.
He is a adult.
He is a elder.
5.7
You really like apple
You really like banana
You really like watermelon
You don't like the orange
You don't like the kiwi
5.8
Hello admin, would you like to see a status report?
Hello Alice, thank you for logging in again
Hello Bob, thank you for logging in again
Hello Eric, thank you for logging in again
Hello Jack, thank you for logging in again
print("\n5.2")
print("student" == "Student")
print("student" == "Student".lower())
print(12 == 12)
print(12 != 13)
print(12 >= 13)
print(12 < 13 and 13 > 14)
print(12 > 13 or 12 < 13)
nums = [1, 2, 3, 4, 5]
print(3 in nums)
print(6 not in nums)
print("\n5.3")
alien_color = 'green'
if alien_color == 'green':
print("You got 5 points!")
print("\n5.4")
alien_color = 'yellow'
if alien_color == 'green':
print("You got 5 points!")
else:
print("You got 10 points!")
print("\n5.5")
alien_color = 'red'
if alien_color == 'green':
print("You got 5 points!")
elif alien_color == 'yellow':
print("You got 10 points!")
else:
print("You got 15 points!")
print("\n5.6")
ages = [1, 3, 10, 18, 40, 70]
for age in ages:
if age < 2:
print("He is a baby.")
elif age < 4:
print("He is learn to walk.")
elif age < 13:
print("He is a children.")
elif age < 20:
print("He is a teenager.")
elif age < 65:
print("He is a adult.")
else:
print("He is a elder.")
print("\n5.7")
favorite_fruits = ['apple', 'banana', 'watermelon']
question_fruits = ['apple', 'banana', 'watermelon', 'orange', 'kiwi']
for fruit in question_fruits:
if fruit in favorite_fruits:
print("You really like " + fruit)
else:
print("You don't like the " + fruit)
print("\n5.8")
names = ['admin', 'Alice', 'Bob', 'Eric', 'Jack']
for name in names:
if name == 'admin':
print("Hello admin, would you like to see a status report?")
else:
print("Hello " + name + ", thank you for logging in again")
输出结果:5.2
False
True
True
True
False
False
True
True
True
5.3
You got 5 points!
5.4
You got 10 points!
5.5
You got 15 points!
5.6
He is a baby.
He is learn to walk.
He is a children.
He is a teenager.
He is a adult.
He is a elder.
5.7
You really like apple
You really like banana
You really like watermelon
You don't like the orange
You don't like the kiwi
5.8
Hello admin, would you like to see a status report?
Hello Alice, thank you for logging in again
Hello Bob, thank you for logging in again
Hello Eric, thank you for logging in again
Hello Jack, thank you for logging in again
相关文章推荐
- 数据库原理与设计第五章作业
- 第五章作业一
- 第五章作业
- 王爽汇编第五章作业 [BX]和LOOP指令
- 【课后作业】第五章概念总结 .
- 第五章作业
- 第五章课后作业
- Python第五章课后作业
- 第五章python作业
- 第五章作业:动物声音模拟器
- The C++ Programming Language 第五章 作业
- 数据库第五章作业
- C++第三次作业3-1(Accelerated C++第五章)
- 第五章 作业
- 第五章作业第一部分
- C++第五章剩下作业题目(第八周)
- [置顶] CSAPP第五章家庭作业参考答案
- 【windows核心编程】 第五章 作业
- 第五章:作业
- 【HW】第四章作业 2018.3.14