高级编程技术 第三周作业
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)
该章主要是各种情况下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)
相关文章推荐
- 高级编程技术 Python 第三周作业
- 高级编程技术 第三周作业
- 【高级编程技术】【作业】【第三周】【2】
- 【高级编程技术】第三周作业
- 第三周作业(1)——高级编程技术
- 【高级编程技术】【作业】【第三周】【1】
- 《高级编程技术》第三周作业
- 高级编程技术第三周平时作业
- 高级编程技术第三周平时作业(2)
- 高级编程技术作业第三周 第五章,第六章课后练习
- 第三周作业(2)——高级编程技术
- princeton algorithms part 1 第三周作业题
- 高级编程技术作业_1:浏览https://www.python.org的发现与收获
- RFID第三周作业
- 第二次作业(高级编程技术)
- 高级编程技术_课后作业(二)
- 高级编程技术第一次作业
- 算法第三周作业02
- 高级编程技术第二周平时作业
- 高级编程技术第二周平时作业(2)