Python的练习
统计下划线,大写字母,和写字母个数
s1="1234abcABCDE_"
xiaoxiezimu=0
daxiezimu=0
xhx=0
i=0
while i<len(s1):
if s1[i]>="a"and s1[i]<="z":
xiaoxiezimu+=1
elif s1[i]>="A"and s1[i]<="Z":
daxiezimu+=1
elif s1[i]=="_":
xhx+=1
i+=1
print(f"大写字母个数{daxiezimu},小写字母个数{xiaoxiezimu},下划线个数{xhx}")
求输入数的最大最小值,和
i=0
max=0
min=0
he=0
while i<5:
num=int(input("请输入整数"))
if i==0:
max=num
min=num
else:
if num>max:
max=num
elif num<min:
min=num
he+=num
i+=1
print("最大值%d,最小值%d,和%d"%(max,min,he))
用python打印99乘法表
for i in range(1, 10):
for j in range(1, i+1):
if i == j:
print("%d*%d=%d" % (j,i,i*j), end="\n")
else:
print("%d*%d=%d" % (j,i,i*j), end="\t")
进一步练习
def info():
print("1楼 珠宝")
print("2楼 女装")
print("3楼 小吃城")
print("4楼 影城")
floor=int(input("请输入层数"))
if floor==1:
print("大悦城1楼欢迎你")
info()
elif floor==2:
print("大悦城2楼欢迎你")
info()
elif floor==3:
print("大悦城3楼欢迎你")
info()
elif floor==4:
print("大悦城4楼欢迎你")
info()