x =input("please enter your age")
x =int(x)if x <10:print("你是个孩子")elif x <20:print("你是个少年")elif x<30:print("你是个青年")else:print("你是个成人")
nm_list=[]
m=0for i inrange(10):
x =input("please enter your age")
x =float(x)
nm_list.append(x)
m = m + x
mean = m/10print("元素之和为{}".format(m))print("元素平均数为{}".format(mean))
nm_list=[]
m=0for i inrange(10):
x=input("请输入你的年龄")
x=float(x)
m=m+x
mean=m/10print("元素之和为{}".format(m))print("元素平均值为{}".format(mean))
a ={"贵州茅台":840,"中国平安":78,"中信证券":60}for k,v in a.items():print(k,v)
num_list=[]
total=0whileTrue:
num=input("please enter a number")if num =="done":break
num =float(num)
num_list.append(num)
total = total + num
print(total)print(total/len(num_list))
猜数字游戏 生成0-20的数 如果小于那个数 则输出你猜小了 如果大于 则输出你猜大了
import random
x = random.randint(0,20)
n =0while n<=6:
num =input("please enter a number")
num =int(num)
n=n+1if num == x:print("你猜对了")breakelif num < x:print("你猜小了")elif num > x:print("你猜大了")elif n ==6:print("傻子,就知道你猜不对")