为了账号安全,请及时绑定邮箱和手机立即绑定
age = 20
if age > 18:
print('成年人')
elif age >=6:
print('青少年')
elif age >=3:
print('小孩子')
else:
print('婴儿')
# Enter a code
age = 20
if age < 18 :
print('adult')
else :
print('teenager')
a = 18
if a > 18:
print('成年人')
else:
print('未成年')
最后任务的标准答案是啥
template = 'Life is short, {}'
a = 'you need Python'
result = template.format(a)
print(result)

template = 'Life is short, {a}'
b = 'you need Python'
result1 = template.format(a = b)
print(result1)
def my_func(x):
if isinstance(x, list):
return sum(x)
elif isinstance(x, tuple):
num = 1
for item in x:
num = item*num
return num


x = (12, 34, 56, 43, 65)
print(my_func(x))
def sub_sum(l):
sum_even = 0
sum_odd = 0
for num in l:
if num % 2 == 0:
sum_even = num + sum_even
else:
sum_odd = num + sum_odd

return sum_even, sum_odd

l = [1,2,3,4,5,6,7,8,9,10]
sum_even, sum_odd = sub_sum(l)
print(sub_sum(l))
print('Hello world')
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if s1.isdisjoint(s2)==False:
for numbers_overlap in s1:
if numbers_overlap in s2:
print(numbers_overlap)

#so if there are numbers(numbers_overlap) in s1 found in set 2, print the numbers_overlap
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])

# if ( item_L) is in S, it should be deleted from set, if not, it should be added into set.
for item_L in L:
if item_L in S:
S.remove(item_L)
else:
S.add(item_L)
print(S)
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for i in L:
S1 = S
S1.add(i)
if S != S1:
S.add(i)
S1.remove(i)
else:
S.remove(i)

print(S)
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

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

帮助反馈 APP下载

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

公众号

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

友情提示:

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

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消