为了账号安全,请及时绑定邮箱和手机立即绑定
age = 19
if age >= 18:
print('your age = {}'.format(age))
print('adult')
s = 'aabcdefghhij'
print(s[1:9])
>>> r = 'you need Python'
>>> template = 'Life is short,{}'
>>> result = template.format(r)
>>> print(result)
Life is short,you need Python

>>> template = 'Life is short,{w}'
>>> w = 'you need Python'
>>> result = template.format(w=w)
>>> print(result)
Life is short,you need Python
>>>
哥哥,这个标准答案里没有print,没有输出啊
T = (1, 'CH', [3, 4])
T = list(T)
T[2]=tuple(T[2])
print(tuple(T))
集合是无序的,但是python3.7及以后的版本字典有序的
a='python'
print('hello',a and 'world') #==>hello, python
在and语句下,a值为true,所以运算结果取决于前者
b=''
print('hello',b or 'world') #==>hello, world
在or语句下,b值为false(空,0,None),所以运算结果取后者
搞那么复杂
def sub_sum(l):
j_sum=0
o_sum=0
for n in l:
if n%2 == 0 :
o_sum += n
else:
j_sum += n
return j_sum,o_sum

l=[1,3,5,2,4,6,7,8,9,10]
s=sub_sum(l)

print('奇数和={}'.format(s[0]))
print('偶数和={}'.format(s[1]))
# Enter a code
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for v1 in L:
if v1 in S:
S.remove(v1)
else:
S.add(v1)
print(S)
names1= []
names2=['Jenny', 'Ellena', 'Alice', 'Candy', 'David', 'Hally', 'Bob', 'Isen', 'Karl']
names1_set=set(names1)
#方法一
for v in names2:
names1_set.add(v)
print(names1_set)
#方法二
names1_set.update(names2)
print(names1_set)
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])

for x in s1:
if s1.isdisjoint(s2) == False:
print(x)
s=set(['Alice', 'Bob', 'Candy', 'David', 'Ellena'])
print(s)
# Enter a code
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
names.insert(0,'Ellena')
names.pop(2)
names[-1] = 'Bob'
print(names)
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for key in d:
value=d[key]
for score in value:
print(key,score)
# Enter a code
# -*- coding: UTF-8 -*-
# Enter a code
# -*- coding: UTF-8 -*-
#age = int(input('请输入年龄 '))
age = 6
if age >= 18:
print('成年人')
elif 6 <= age <= 18:
print('青少年')
elif 3 <= age <= 6:
print('小孩子')
elif age <= 3:
print('婴儿')
else:
print('出现错误')
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

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

帮助反馈 APP下载

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

公众号

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

友情提示:

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

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消