"""
随机产生一个数字:45
请输入数字:30
提示大了或者小了
继续输入
"""
from random import randint
num = randint(0,100)
value = int(input('请输入一个数字:'))
while value > num:
print('猜大了,继续')
value = int(input('请输入一个数字:'))
while value < num:
print('猜小了,继续')
value = int(input('请输入一个数字:'))
print('恭喜你答对了')
score = int(input('请输入成绩:'))
if score >= 60:
print('及格')
else:
print('不及格')
age = int(input('请输入年龄:'))
if 18 <= age <= 150:
print('成年')
elif 0 <= age < 18:
print('未成年')
else:
print('这不是人!')
a = int(input('输入a的值:'))
b = int(input('输入b的值:'))
if (a-b) % 2 != 0:
print(a-b)
else:
print('a-b的值不为奇数')
m = 1
while m <= 100:
if m % 3 == 0:
print(m, end=' ')
m += 1
print()
n = 0
while n <= 100:
if n % 2 == 0:
print(n, end=' ')
n += 1
for x in range(1, 11):
x *= x
print('1*2*3...*10=', x)
n = 0
for x in range(12, 101, 30):
n += 1
print('统计100以内个位数是2并且能够被3整除的数的个数:', n)
n = int(input('输入一个正整数:'))
m = 1
x = 0
if 0 < n < 10:
print('它是1位数')
elif n <= 0:
print('请输入正整数!')
else:
while m < n:
if n // m > 0:
x += 1
m *= 10
else:
x = 1
m *= 10
print('它是', x, '位数')
for x in range(100, 1000):
if (x // 100)*(x // 100)*(x // 100) + (x // 10 % 10)*(x // 10 % 10)*(x // 10 % 10) + (x % 10)*(x % 10)*(x % 10) == x:
print(x, end=' ')
n = int(input('输入一个数:'))
i = 0
for x in range(2, n):
for m in range(2, n):
if x * m == n :
i = 1
break
if i == 0:
print('它是一个素数')
else:
print('它是一个合数')
n = int(input('从斐波那契数列中找第几个数?'))
a, b, c = 0, 1, 1
if n == 1:
print(0)
elif n == 2 or n == 3:
print(1)
elif n == 4:
print(2)
elif n == 5:
print(3)
elif n == 6:
print(5)
else:
for x in range(1, n // 3):
a = b + c
b = c + a
c = a + b
if n % 3 == 1:
print(a)
elif n % 3 == 2:
print(b)
else:
print(c)
for i in range(1, 10):
for j in range(1, 10):
print(i, '*', j, '=', i*j)
for x in range(1, 99):
for y in range(1, 100-x):
if x * 0.5+ y*2.0 + (100-x-y)*3.0 == 100.0:
print('小马', x, '中马', y, '大马', 100-x-y)