def greet(name="world"):
if name == "world":
print("Hello, world.")
else:
print(f"Hello, {name}.")
if name == "world":
print("Hello, world.")
else:
print(f"Hello, {name}.")
2024-05-17
# Enter a code
a=5
x=a
d=10
z=d/5
c=28
t=c/7
y=(x*z)/t
print(y,z)
a=5
x=a
d=10
z=d/5
c=28
t=c/7
y=(x*z)/t
print(y,z)
2024-05-17
def greet(L='world'):
sc='Hello,{}'.format(L)
return sc
print(greet())
print(greet('Lisi')
sc='Hello,{}'.format(L)
return sc
print(greet())
print(greet('Lisi')
2024-05-17
def square_of_sum(list):
result = 0
for num in list:
result += num * num
return result
print(square_of_sum([1, 2, 3, 4, 5]))
result = 0
for num in list:
result += num * num
return result
print(square_of_sum([1, 2, 3, 4, 5]))
2024-05-17
# Enter a code
L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
for i in range(len(L)):
a = L[i][0]
b = L[i][1]
c = L[i][2]
print(2 * (a*b + b*c + a*c))
L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
for i in range(len(L)):
a = L[i][0]
b = L[i][1]
c = L[i][2]
print(2 * (a*b + b*c + a*c))
2024-05-16
# Enter a code
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
new1 = 'Zero'
new2 = 'Phoebe'
new3 = 'Gen'
names.append(new2)
names.append(new1)
names.insert(5, new3)
print(names)
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
new1 = 'Zero'
new2 = 'Phoebe'
new3 = 'Gen'
names.append(new2)
names.append(new1)
names.insert(5, new3)
print(names)
2024-05-16
# Enter a code
s1='ABC'
s2='123'
s3='xyz'
for i in s1:
for j in s2:
for k in s3:
print(i + j + k)
s1='ABC'
s2='123'
s3='xyz'
for i in s1:
for j in s2:
for k in s3:
print(i + j + k)
2024-05-16
# Enter a code
i = 0
sum = 0
while i <= 1000:
if i%2 != 0:
i = i+1
continue
sum += i
i = i+1
print (sum)
i = 0
sum = 0
while i <= 1000:
if i%2 != 0:
i = i+1
continue
sum += i
i = i+1
print (sum)
2024-05-16
# Enter a code
i = 0
sum = 0
while True:
if i > 1000:
print (sum)
break
if i%2 == 0:
sum += i
i = i+1
i = 0
sum = 0
while True:
if i > 1000:
print (sum)
break
if i%2 == 0:
sum += i
i = i+1
2024-05-16
num = 1
sum = 1
while num <=10:
sum*= num
num+= 1
print(num)
print(sum)
sum = 1
while num <=10:
sum*= num
num+= 1
print(num)
print(sum)
2024-05-14
a = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
b = a.append('Gen') and a.append('Phoebe') and a.append('Zero')
print(a)
b = a.append('Gen') and a.append('Phoebe') and a.append('Zero')
print(a)
2024-05-12
a = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
b = a.append('Gen')
c = a.append('Phoebe')
d = a.append('Zero')
print(a)
b = a.append('Gen')
c = a.append('Phoebe')
d = a.append('Zero')
print(a)
2024-05-12
L = [95.5, 85, 59, 66, 72]
L = sorted(L)
p = (L[-1])
pr = (L[-2])
pri = (L[-3])
print('第一名: {}'.format(p))
print('第二名: {}'.format(pr))
print('第三名: {}'.format(pri))
L = sorted(L)
p = (L[-1])
pr = (L[-2])
pri = (L[-3])
print('第一名: {}'.format(p))
print('第二名: {}'.format(pr))
print('第三名: {}'.format(pri))
2024-05-12