def my_work(**kwargs):
for j , i in enumerate(kwargs.get('names')):
print('姓名:{},性別:{},年齡:{}'.format(i,kwargs.get('gender')[j],kwargs.get('age')[j]))
return
my_work(names=['熊貓','大象','狗熊'],gender=['男','女','男'],age=[18,28,33])
for j , i in enumerate(kwargs.get('names')):
print('姓名:{},性別:{},年齡:{}'.format(i,kwargs.get('gender')[j],kwargs.get('age')[j]))
return
my_work(names=['熊貓','大象','狗熊'],gender=['男','女','男'],age=[18,28,33])
2022-02-11
def square_of_sum(L):
L1=[]
for i in L:
L1.extend([i*i])
return sum(L1)
print(square_of_sum([1, 2, 3, 4, 5]))
L1=[]
for i in L:
L1.extend([i*i])
return sum(L1)
print(square_of_sum([1, 2, 3, 4, 5]))
2022-02-09
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
new_names=[]
for i in names:
name_lower=i.lower()
new_names.append(name_lower)
print(new_names)
new_names=[]
for i in names:
name_lower=i.lower()
new_names.append(name_lower)
print(new_names)
2022-02-09
d = dict()
d['Alice'] = [50, 61, 66]
d['Bob'] = [80, 61, 66]
d['Candy'] = [88, 75, 90]
d['Alice'] = [50, 61, 66]
d['Bob'] = [80, 61, 66]
d['Candy'] = [88, 75, 90]
2022-02-09
num = 2
sum = 0
while True:
if num > 1000:
break
sum = sum + num
num = num + 2
print(sum) # ==> 250500
sum = 0
while True:
if num > 1000:
break
sum = sum + num
num = num + 2
print(sum) # ==> 250500
2022-02-08
# coding: utf-8
s1 = '這是一句中英文混合的{}字符串:{}'
python = 'Python'
hello = 'Hello World!'
result = s1.format(python , hello)
print(result)
s1 = '這是一句中英文混合的{}字符串:{}'
python = 'Python'
hello = 'Hello World!'
result = s1.format(python , hello)
print(result)
2022-02-07
t = (100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100,42, 88, 100)
print(t.count(100))
print(t.count(100))
2022-02-07
In [13]:
?
def vcb(**c):
namess = c['names']
genderss = c['genders']
agess = c['ages']
index = 0
for name in namess:
gender = genderss[index]
age = agess[index]
index += 1
print(name + ' is a ' + gender + ' of '+ age)
#輸入時注意列表里面的元素都為字符串即可
?
def vcb(**c):
namess = c['names']
genderss = c['genders']
agess = c['ages']
index = 0
for name in namess:
gender = genderss[index]
age = agess[index]
index += 1
print(name + ' is a ' + gender + ' of '+ age)
#輸入時注意列表里面的元素都為字符串即可
2022-02-03
In [9]:
?
def vcb(names,genders,ages):
index = 0
for name in names:
gender = genders[index]
age = ages[index]
index += 1
print(name + ' is a ' + gender + ' of '+ age)
#輸入時注意列表里面的元素都為字符串即可
?
def vcb(names,genders,ages):
index = 0
for name in names:
gender = genders[index]
age = ages[index]
index += 1
print(name + ' is a ' + gender + ' of '+ age)
#輸入時注意列表里面的元素都為字符串即可
2022-02-03
def hancan(x):
listhe = 0
tuplehe = 1
if isinstance(x,list):
for i in x:
listhe += i
return listhe
elif isinstance(x,tuple):
for j in x:
tuplehe *= j
return tuplehe
else:
return '數據類型有誤'
listhe = 0
tuplehe = 1
if isinstance(x,list):
for i in x:
listhe += i
return listhe
elif isinstance(x,tuple):
for j in x:
tuplehe *= j
return tuplehe
else:
return '數據類型有誤'
2022-02-03
或運算下
a是字符串,判斷為ture 返回a
b是空字符串判斷為false,結果取決于world,返回world
輸出hello Python
hello world
a是字符串,判斷為ture 返回a
b是空字符串判斷為false,結果取決于world,返回world
輸出hello Python
hello world
2022-02-02