L = ['Alice','Bob','Candy','David','Ellena']
candy = L.pop(2)
David = L.pop(2)
print(candy)
print(David)
print(L)
candy = L.pop(2)
David = L.pop(2)
print(candy)
print(David)
print(L)
2024-02-15
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
names.append('Zero')
names.insert(5,'Phoebe')
names.insert(5,'Gen')
print(names)
names.append('Zero')
names.insert(5,'Phoebe')
names.insert(5,'Gen')
print(names)
2024-02-15
L = ['Alice',66,'Bob',True,'False',100]
num = 0
for item in L:
num = num +1
if num%2==0:
print(item)
num = 0
for item in L:
num = num +1
if num%2==0:
print(item)
2024-02-14
s1 = 'ABC'
s2 = '123'
s3 = 'xyz'
for x in s1:
for y in s2:
for z in s3:
print(x + y + z)
s2 = '123'
s3 = 'xyz'
for x in s1:
for y in s2:
for z in s3:
print(x + y + z)
2024-02-13
num = 0
sum = 0
while True:
if num > 1000:
break
if num%2!=0:
num = num+1
continue
sum = sum+num
num = num+1
print(sum)
sum = 0
while True:
if num > 1000:
break
if num%2!=0:
num = num+1
continue
sum = sum+num
num = num+1
print(sum)
2024-02-13
num = 0
sum = 0
while True:
if num>1000:
break
if num%2==0:
sum = sum+num
num = num+1
print(sum)
sum = 0
while True:
if num>1000:
break
if num%2==0:
sum = sum+num
num = num+1
print(sum)
2024-02-13
num = 1
mul = 1
while num<=10:
mul = mul * num
num = num+1
print(mul)
mul = 1
while num<=10:
mul = mul * num
num = num+1
print(mul)
2024-02-13
L = [75, 92, 59, 68, 99]
sum = 0
for i in L:
sum += i
print(sum)
print(sum/5)
print(sum/len(L))
sum = 0
for i in L:
sum += i
print(sum)
print(sum/5)
print(sum/len(L))
2024-02-13
age = 2
if age>=18:
print('adult')
elif age>=6 and age<18:
print('teenager')
elif age>=3 and age<6:
print('kid')
else:
print('baby')
if age>=18:
print('adult')
elif age>=6 and age<18:
print('teenager')
elif age>=3 and age<6:
print('kid')
else:
print('baby')
2024-02-13
age =30
if age<18:
print('teenager')
else:
print('adult')
if age<18:
print('teenager')
else:
print('adult')
2024-02-13
age = 19
if age>18:
print('adult')
print('dondonqiang age {}'.format(age))
else:
print('minor')
if age>18:
print('adult')
print('dondonqiang age {}'.format(age))
else:
print('minor')
2024-02-13
template = '{l} {i} {s}, {y} {n} {p}'
l = 'Life'
i = 'is'
s = 'short'
y = 'you'
n = 'need'
p = 'Python'
result = template.format(l,i,s,y,n,p)
print(result)
result = template.format(l='Life',i='is',s='short',y='you',n='need',p='Python')
print(result)
l = 'Life'
i = 'is'
s = 'short'
y = 'you'
n = 'need'
p = 'Python'
result = template.format(l,i,s,y,n,p)
print(result)
result = template.format(l='Life',i='is',s='short',y='you',n='need',p='Python')
print(result)
2024-02-08
template = '{}'
con = 'Life is short,you need Python'
result = template.format(con)
print(result)
template = '{0} {1} {2},{3} {4} {5}'
result = template.format('Life','is','short','you','need','Python')
print(result)
con = 'Life is short,you need Python'
result = template.format(con)
print(result)
template = '{0} {1} {2},{3} {4} {5}'
result = template.format('Life','is','short','you','need','Python')
print(result)
2024-02-08
print(r'''
"To be, or not to be": that is the question.Whether it's nobler in the mind to suffer.
''')
"To be, or not to be": that is the question.Whether it's nobler in the mind to suffer.
''')
2024-02-08
print("special string:',\",\,\\\,\\n,\\t")
print("special string:',\",\,\\\\,\\n,\\t")
print("special string:',\",\,\\\\,\\n,\\t")
2024-02-08