1、
mnx = 0
count = 0
while True:
num = int(input("请输入一个数字 (以数字0结束): "))
if num == 0:
break
if num > mnx:
mnx = num
count = 1
elif num == mnx:
count += 1
print("最大的数字是:", mnx)
print("最大数字出现的次数是: ", count)
2、
A = int(input("请输入一个十进制数:"))
print(bin(A))
3、
A = int(input("请输入一个十进制数:"))
print(hex(A))
4、
import random
sm = 0
for i in range(0, 1000001):
x = random.random() * random.choice([-1, 1])
y = random.random() * random.choice([-1, 1])
if x <= 0 or (x >= 0 and y >= 0 and (y / (1 - x) >= 1)):
sm += 1
a = sm / 1000000
print("1000000个随机点落在奇数区域的概率是%.12f" % a)
5、
xy = 0
for y in range(2001, 2101):
if y % 400 == 0 or y % 4 == 0 and y % 100 != 0:
print(y, end=" ")
xy += 1
if xy % 10 == 0:
print()
6、
7、
8、
9、
10、11、