L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L.pop(2)
L.pop(2)
print(L)
L.pop(2)
L.pop(2)
print(L)
2022-09-12
names=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
names.insert(5,'Gen')
names.append('Phonebe')
names.append('Zero')
print(names)
names.insert(5,'Gen')
names.append('Phonebe')
names.append('Zero')
print(names)
2022-09-12
L = ['Alice', 66, 'Bob', True, 'False', 100]
n=0
for a in L:
n=n+1
if n%2!=0:
print(a)
n=0
for a in L:
n=n+1
if n%2!=0:
print(a)
2022-09-11
s1='ABC'
s2='123'
s3='xyz'
for a in s1:
for b in s2:
for c in s3:
print(a+b+c)
s2='123'
s3='xyz'
for a in s1:
for b in s2:
for c in s3:
print(a+b+c)
2022-09-11
num=2
sum=0
while num<=1000:
sum=sum+num
num=num+2
continue
print(sum)
sum=0
while num<=1000:
sum=sum+num
num=num+2
continue
print(sum)
2022-09-10
>>> 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-09-10
>>> num=1
>>> sum=1
>>> while num<=10:
... sum=sum*num
... num=num+1
...
>>> print(sum)
3628800
>>> sum=1
>>> while num<=10:
... sum=sum*num
... num=num+1
...
>>> print(sum)
3628800
2022-09-10
这个比答案更简单:
num=2
sum=0
while True:
if num>1000:
break
sum=num+sum
num=num+2
print(sum)
num=2
sum=0
while True:
if num>1000:
break
sum=num+sum
num=num+2
print(sum)
2022-09-01
template = '{},{}'
life='life is short'
python='you need python'
result=template.format(life, python)
print(result)
life='life is short'
python='you need python'
result=template.format(life, python)
print(result)
2022-08-30
# Enter a code
T = (0,1,2,3,4,5,6,7,8,9)
print(T)
L = list(T)
print(L)
L.insert(0,'sos')
L.insert(2,'sos')
L.insert(4,'sos')
L.insert(6,'sos')
L.insert(8,'sos')
L.insert(10,'sos')
L.insert(12,'sos')
L.insert(14,'sos')
L.insert(16,'sos')
L.insert(18,'sos')
print(L)
T = (0,1,2,3,4,5,6,7,8,9)
print(T)
L = list(T)
print(L)
L.insert(0,'sos')
L.insert(2,'sos')
L.insert(4,'sos')
L.insert(6,'sos')
L.insert(8,'sos')
L.insert(10,'sos')
L.insert(12,'sos')
L.insert(14,'sos')
L.insert(16,'sos')
L.insert(18,'sos')
print(L)
2022-08-30
# Enter a code
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
temple = L[0]
L[0] = L[4]
L[1] = temple
L[4] = L[1]
print(L)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
temple = L[0]
L[0] = L[4]
L[1] = temple
L[4] = L[1]
print(L)
2022-08-30
# coding=utf-8
def sum1():
sum = 0
for i in range(101):
sum += i
return sum
def sum2(n):
if n==1:
return 1
else:
return n+sum2(n-1)
print(sum1())
print(sum2(100))
def sum1():
sum = 0
for i in range(101):
sum += i
return sum
def sum2(n):
if n==1:
return 1
else:
return n+sum2(n-1)
print(sum1())
print(sum2(100))
2022-08-24