'''
@Author: your name
@Date: 2020-07-15 22:44:09
@LastEditTime: 2020-07-15 23:18:43
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \vscode_py\day10.py
'''
# Question 31
# 计算1-20的平方,存放在字典中,并输出
def Question31():
d={}
for i in range(1,21):
d[i]=i**2
print(d)
# Question 32
# 计算1-20的平方,存放在字典中,并输出keys
def Question32():
d={}
for i in range(1,21):
d[i]=i**2
# for i in d.keys():
# print(i)
print(d.keys())
# Question33
# 计算1-20的平方,存放在list
def Question33():
l=[]
for i in range(1,21):
l.append(i**2)
print(l)
# Question34
# 计算1-20的平方,存放在list,输出前5个元素
def Question34():
l=[]
for i in range(1,21):
l.append(i**2)
print(l[:5])
# Question35
# 计算1-20的平方,存放在list,输出后5个元素
def Question35():
l=[]
for i in range(1,21):
l.append(i**2)
print(l[-5:])
# Question36
# 计算1-20的平方,存放在list,输出除掉前5个元素的所有元素
def Question36():
l=[]
for i in range(1,21):
l.append(i**2)
print(l[5:])
# Question37
# 计算1-20的平方,存放在list,输出tuple
def Question37():
l=[]
for i in range(1,21):
l.append(i**2)
l=tuple(l)
print(l)
if __name__ == "__main__":
# Question31()
# Question32()
# Question33()
# Question34()
# Question35()
# Question36()
Question37()