Python从零开始 day3

格式化输入:
name=input(‘Name:’)
age=input(‘Age:’)
job=input(‘Job:’)
hometwon=input(‘Hometwon:’)
into=’’’------------into of %s ----------
name : %s
age : %s
job : %s
hometown : %s
-------------end -------------
‘’’ % (name,name,age,job,hometwon)
print(into)

while嵌套循环:
#0-100,不打印50的值,60-80打印其值的平方
count =0
while count <= 100:
if count == 50:
pass #表示跳过的意思
elif count >= 60 and count <= 80:
print(count*count)
else:
print(count)
count+=1
print(‘END’)

count=0
age=26
while count<3:
guess_age=int(input(‘输入年龄:’))
if guess_age == age:
print(‘你猜对了!’)
break
elif guess_age > age:
print(‘你猜大了,请试试小的!’)
else:
print(‘你猜大了!’)
count+=1
if count3:
chioce=input(‘你还想玩吗?(y|Y)’)
if chioce
’y’ or chioce==‘Y’:
count=0

乘法表:

‘’‘num=5
while num>0:
#print(’*’)

tap=0
while tap <=num :
#print(’’,end=’’)
tap+=1
print(tap,’
’,num,’=’,tapnum,end=’ ‘)
print()
num-=1’’’
num =1
while num<=5:
tap=1
while tap<=num:
#print(tap,’
’,num,’=’,tapnum,end=’\t’)
print(str(tap)+’
’+str(num)+’=’+str(tap*num),end=’\t’)
tap+=1
print()
num+=1

你可能感兴趣的:(Python从零开始 day3)