num =eval(input("输入三位整数"))if(num//100>0and num //100<10):print("三位数")
b = num //100#百位
c = num %10#个位if b == c:print("是回文数")else:print("不是回文数")else:print("不是三位数")
练习2.棋盘
import turtle
step =20
turtle.showturtle()#显示for i inrange(11):
turtle.penup()
turtle.goto(0,step*i)
turtle.pendown()
turtle.forward(step*10)
turtle.right(270)for i inrange(11):
turtle.penup()
turtle.goto(step*i,0)
turtle.pendown()
turtle.forward(step*10)
turtle.dot(10,"red")
turtle.done()
练习3.三个数比大小
a,b,c =eval(input("a,b,c"))if a>b:passif a>c:print("max",a)if b>c:print(b,c)else:print(c,b)else:passif b >c :print("max",b)if c>a:print(c,a)else:print(a,c)else:print("max",c)if a > b:print(a, b)else:print(b, a)
sheng ={}#省和市的集合deftianjia(s,c):#s代表省 c代表市if s notin sheng.keys():
sheng[s]= c
else:print(s+'已经存在')print(sheng)defshow():#显示以存储的省和市for p in sheng.keys():print(p,sheng[p])defseeksheng(s):if s in sheng.keys():print(s,end=':')for i in sheng[s]:print(i,end=' ')print()else:print('没有这个省')defseekct(c):for i in sheng.keys():if c in sheng[i]:print(c+"属于"+i+'省')returnprint('没有这个城市')