为了账号安全,请及时绑定邮箱和手机立即绑定
def data_of_square(side):
C= 4*side
S=side * side
print('c is {},s is {}'.format(C,S))
return C,S
C,S= data_of_square(6)
print('周长={}'.format(C))
print('面积={}'.format(S))
# coding=utf-8

d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
template = "{}的第{}次成绩是{}分"
for key, value in d.items():
for index in range(len(value)):
print(template.format(key,index+1,value[index]))
不是表面积吗
special string:',",\,\\,\n,\t
print "special string: \', \",\\, \\\\, \\n, \\t"
a = 'python'
print 'hello,', a or 'world'
b = ''
print 'hello,', b or 'world'

a为有效字符串,即为true; 则 = true
b为空字符串,即为false; 则 = false
def greet(c='World'):
print('hello'+','+c)
return
greet()
greet('sb')
# coding=utf-8
#请分别使用循环和递归的形式定义函数,求出1~100的和。
#循环
def sum(n):
i=0
s=0
while i<=n:
s=s+i
i=i+1
print(s)
return


sum(100)
#递归
def he(n):
x=0
if n==1:
x=n
else:
x=he(n-1)+n
return x
print(he(100))
# coding=utf-8
def sub_sum(L):
y=0
j=0
i=0
while i<len(L):
if i%2==0:
y=y+L[i]
else:
j=j+L[i]
i=i+1
print(y,j)
return
sub_sum([1,2,3,4])
请问哪里有习题的参考答案
顾语成是靓仔
按题目要求,应该是这么写吧
L = [95.5, 85, 59, 66, 72]
L2 = sorted(L,reverse=True)
print(L2[0:3])
注意运算优先级的影响
老师你猜我看懂了么
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
names = ["Alice", "Bob", "Candy", "Mimi", "David"]
for key, name in zip(d.keys(), names):
if name in d.keys():
print(d.get(key))
else:
print(None)
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

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

帮助反馈 APP下载

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

公众号

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

友情提示:

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

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消