为了账号安全,请及时绑定邮箱和手机立即绑定
List=range(1,10)
print(tuple(List))
我还有以为是需要把两种数据类型拼接到一起,哈哈
# Enter a code
def sum(list):
sum = 0
for i in list:
sum += i
return sum


list1 = []
for i in range(1, 101):
num = i * i
list1.append(num)

total = sum(list1)
print(total) # 338350
# 要查找的姓名转换成小写,遍历的集合时,将成员也转换成小写,再遍历
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name_set = set(names)
namesInput = "ALICE".lower()

for name in name_set:
if namesInput == name.lower():
print("cun zai")
break #找到姓名时,就跳出循环
else:
print("mei you zhao dao")
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
list1 = d.keys()
print(len(list1))
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for name in d.keys():
print(d[name])
for item in d.items():
print(item)
for key, value in d.items():
print(value)
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}

for student in d.keys():
if student == "Alice":
print("Alice score is %s" %d[student])
d[student] = 60

print(d)
d = {
'Alice': [45],
'Bob': [60],
'Candy': [75],
}
aliceScore = [50, 61, 66]
bobScore = [80, 61, 66]
candyScore = [88, 75, 90]
d["Alice"].append(aliceScore)
d["Bob"].append(bobScore)
d["Candy"].append(candyScore)
print(d)

记录一下下,
tuple1 = ((1+2), ((1+2),), ('a'+'b'), (1, ), (1,2,3,4,5))
count = 0
for i in tuple1:
if type(i) == tuple:
count += 1

print("number of tuple is %d " %count)
# coding:utf-8
age = 75
if age<3:
print('你是婴儿, 年龄为{}岁。'.format(age))
elif age<6:
print('你是小孩子, 年龄为{}岁。'.format(age))
elif age<18:
print('你是青少年, 年龄为{}岁。'.format(age))
else:
print('你为成年, 年龄为{}岁。'.format(age))
elif score >= 80:
print('恭喜你,拿到优秀的成绩') 为ture
# coding:utf-8
age = 17
if age>=18:
print('咚咚呛年龄是{}'.format(age)+'岁,你已成年!')
else:
print('咚咚呛年龄是{}'.format(age)+'岁,你未成年!')
L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
# print(len(L))
for i in range(0, len(L)):
sum = 1
sum = (L[i][0]*L[i][1] + L[i][0]*L[i][2] + L[i][1]*L[i][2]) * 2
print("di {0} ge chang fang xing biao mian ji shi {1}".format(i, sum))
L = ['Alice', 66, 'Bob', True, 'False', 100]
i = 0
for item in L:
i += 1
if i%2 != 0:
print(L[i])
sum = 0
num = 0
while num < 1000:
num += 1
if (num % 2) != 0:
continue
sum += num
print("sum = ", sum)
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消