# Enter a code
a='Life is short,{}'
b='you need Python.'
result=a.format(b)
print(b)
a='Life is short,{c}'
b='you need Python.'
result=a.format(c=b)
print(result)
a='Life is short,{}'
b='you need Python.'
result=a.format(b)
print(b)
a='Life is short,{c}'
b='you need Python.'
result=a.format(c=b)
print(result)
2021-09-13
# Enter a code
a=r''' '\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer. '''
print(a)
a=r''' '\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer. '''
print(a)
2021-09-13
我觉得没必要判断奇偶啊,直接num=0 每次加2就可以了。
num = 0
sum = 0
while True:
if num > 1000:
break
sum = sum + num
num = num + 2
print(sum)
num = 0
sum = 0
while True:
if num > 1000:
break
sum = sum + num
num = num + 2
print(sum)
2021-09-12
#..........
ab= ' {}'
b =ab.format('Life is short,you need python')
print(b)
N = 'Life is {0},you need {1}'
b2= N.format('short','python')
print(b2)
N2 ='Life is {w},you need {y}'
short ='short'
python ='pythin'
b3=N2.format(w=short,y=python)
print(b3)
ab= ' {}'
b =ab.format('Life is short,you need python')
print(b)
N = 'Life is {0},you need {1}'
b2= N.format('short','python')
print(b2)
N2 ='Life is {w},you need {y}'
short ='short'
python ='pythin'
b3=N2.format(w=short,y=python)
print(b3)
2021-09-10
moban='{a} {b} {c},{d} {e} {f}.'
a1='Life'
b1='is'
c1='short'
d1='you'
e1='need'
f1='Python'
result=moban.format(a=a1,b=b1,c=c1,d=d1,e=e1,f=f1)
print(result)
a1='Life'
b1='is'
c1='short'
d1='you'
e1='need'
f1='Python'
result=moban.format(a=a1,b=b1,c=c1,d=d1,e=e1,f=f1)
print(result)
2021-09-09
num=0
L = ['Alice', 66, 'Bob', True, 'False', 100]
while num<=5:
num=num+1
if num%2==0:
continue
print(L[num])
L = ['Alice', 66, 'Bob', True, 'False', 100]
while num<=5:
num=num+1
if num%2==0:
continue
print(L[num])
2021-09-08
L=[75,92,59,68,99]
sum=0
for i in range(len(L)):
sum=L[i]+sum
print(sum/len(L))
sum=0
for i in range(len(L)):
sum=L[i]+sum
print(sum/len(L))
2021-09-08
L = [95.5, 85, 59, 66, 72]
a=0
b=0
c=0
for ch in L:
temp=ch
if ch>a :
a=temp
elif ch>b:
b=temp
elif ch>c:
c=temp
print(a,b,c)
a=0
b=0
c=0
for ch in L:
temp=ch
if ch>a :
a=temp
elif ch>b:
b=temp
elif ch>c:
c=temp
print(a,b,c)
2021-09-07
from itertools import permutations
s1 = 'ABC'
s2 = '123'
s3 = 'xyz'
for ss1 in s1:
for ss2 in s2:
for ss3 in s3:
for s in permutations([ss1, ss2, ss3]):
print(''.join(s))
s1 = 'ABC'
s2 = '123'
s3 = 'xyz'
for ss1 in s1:
for ss2 in s2:
for ss3 in s3:
for s in permutations([ss1, ss2, ss3]):
print(''.join(s))
2021-09-06