# Enter a code
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(squre, 2))
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(squre, 2))
2020-11-23
# Enter a code
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(wide, 2))
lengh = 3.14
wide = 1.57
squre = lengh * wide
print(round(wide, 2))
2020-11-23
l=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
l[0]='Ellena'
l[1]='Alice'
l[-1]='Bob'
print(l)
l[0]='Ellena'
l[1]='Alice'
l[-1]='Bob'
print(l)
2020-11-23
print(r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.''')
print('\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.')
Whether it's nobler in the mind to suffer.''')
print('\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.')
2020-11-21
# 方法1
list = [i ** 2 for i in range(1, 10)]
print(sum(list))
# 方法2
list2 = [*range(1, 10)]
def square_of_sum(list):
sum = 0
for num in list:
sum += num**2
return sum
sum = square_of_sum(list2)
print(sum)
list = [i ** 2 for i in range(1, 10)]
print(sum(list))
# 方法2
list2 = [*range(1, 10)]
def square_of_sum(list):
sum = 0
for num in list:
sum += num**2
return sum
sum = square_of_sum(list2)
print(sum)
2020-11-21
# 方法1
list = [i**2 for i in range(1,10)]
print(sum(list))
# 方法2
list2 = [*range(1,10)]
def square_of_sum(list):
sum = 0
for num in list:
sum += num
return sum
sum = square_of_sum(list2)
print(sum)
list = [i**2 for i in range(1,10)]
print(sum(list))
# 方法2
list2 = [*range(1,10)]
def square_of_sum(list):
sum = 0
for num in list:
sum += num
return sum
sum = square_of_sum(list2)
print(sum)
2020-11-21
new_names = ['Jenny', 'Ellena', 'Alice', 'Candy', 'David', 'Hally', 'Bob', 'Isen', 'Karl']
# 第一种
names = new_names.copy()
print(names)
'''# 第二种
names = []
name_set = set(names)
name_set.update(new_names)
print(names)
'''
# 第一种
names = new_names.copy()
print(names)
'''# 第二种
names = []
name_set = set(names)
name_set.update(new_names)
print(names)
'''
2020-11-15
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name_set = set(names)
n='bob'
if n.capitalize()in name_set :#capitalize 首字母大写
print('True')
else:
print('False')
name_set = set(names)
n='bob'
if n.capitalize()in name_set :#capitalize 首字母大写
print('True')
else:
print('False')
2020-11-15
冒泡排序完成的,仅供参考。
L = [95.9, 85, 59, 66, 72];
n = len(L)
j = 0
for i in range(n):
for j in range(0, n-j-1):
if L[j] < L[j+1] :
L[j], L[j+1] = L[j+1], L[j]
for count in range(n):
if(count<3):
print(L[count])
else:
break
L = [95.9, 85, 59, 66, 72];
n = len(L)
j = 0
for i in range(n):
for j in range(0, n-j-1):
if L[j] < L[j+1] :
L[j], L[j+1] = L[j+1], L[j]
for count in range(n):
if(count<3):
print(L[count])
else:
break
2020-11-14