输入一个正整数n,求0到这个数以内的所有 奇数的和 与 偶数的和 x = int(input(">>>>>>>")) ou1 = 0 ji1 = 0 for i in range(1,x+1): if i % 2 == 0: ou1 = ou1 + i else: ji1 = ji1 + i print("ji1",ji1) print("ou1",ou1) 求1到n的阶乘结果 x = int(input(">>>>>>>>>>>>")) b = 1 c = 0 for i in range(1, x+1): b = b * i c = b + c print(b) print(c) 输入一个整数,判断他是否是素数 x = int(input(">>>>>>>>")) for i in range(2,x): if x % i == 0: print("no shushu") break else: print("shushu") 死循环输入数字,输入后打印出之前输入的最大值和之前所有数字的平均数,如果输入的不是数字,而是quit字符串或者空格,则结束循环,退出程序 all1 = 0 max1 = 0 mount1 = 0 while True: x = input('>>') if x ==''or x =='quit'or x ==' ': break x = int(x) mount1 +=1 all1 +=x avg1 =all1 /mount1 if x > max1: max1 =x print('最大数',max1,'总和',all1,'平均数',avg1)