您的位置:首页 > 编程语言

高级编程技术 第三周作业

2018-04-06 22:42 323 查看
第五章:if语句
该章主要是各种情况下if语句的使用
5-5def colorcheck(color):
if color == 'Green':
print('You get 5 points')
elif color == 'Yellow':
print('You get 10 points')
elif color == 'Red':
print('You get 15 points')
colorcheck('Green')
colorcheck('Yellow')
colorcheck('Red')5-9userlist = ['admin']
if userlist:
print('Not Empty')
else:
print('We need to find some users!')
del userlist[0]
if userlist:
print('Not Empty')
else:
print('We need to find some users!')5-11numlist = []
for i in range(1, 10):
numlist.append(i)
for i in numlist:
if i == 1:
print(str(i) + 'st')
elif i == 2:
print(str(i) + 'nd')
elif i == 3:
print(str(i) + 'rd')
else:
print(str(i) + 'th')第六章:字典
这一章主要讲述了字典类型的使用。字典类型放到Cpp里面就是std::map类型。不过相对来说字典使用更方便一些。
6-3,6-4pyword = {
'print': 'print something',
'if': 'if something',
'for': 'for something',
'list': 'something list',
'tuple': 'something tuple'
}
for key, item in pyword.items():
print(key + ':' + item)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: