亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
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('出現錯誤')
d = {
'Alice': [45],
'Bob': [60],
'Candy': [75],
}
l=[50, 61, 66],[80, 61, 66],[88, 75, 90]
print(l[0])
n=0
for v2 in d:
d[v2] = l[n]
print(d,end='\n')
課程須知
如果您了解程序設計的基本概念,會簡單使用命令行,了解中學數學函數的概念,那么對課程學習會有很大的幫助,讓您學起來得心應手,快速進入Python世界。
老師告訴你能學到什么?
通過本課程的學習,您將學會搭建基本的Python開發環境,以函數為基礎編寫完整的Python代碼,熟練掌握Python的基本數據類型以及list和dict的操作,靈活使用流程控制語句。

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!

本次提問將花費2個積分

你的積分不足,無法發表

為什么扣積分?

本次提問將花費2個積分

繼續發表請點擊 "確定"

為什么扣積分?

舉報

0/150
提交
取消