第一题:
cel = eval(input())
fah = 9 / 5 * cel + 32
print("%.1f" % fah)
第二题:
radius, length = eval(input())
area = radius * radius * 3.14159267
volume = area * length
print("%.2f" % area)
print("%.2f" % volume)
第三题:
num = eval(input())
result = num * 0.305
print(result)
第四题:
import random
random_num = random.randint(10,99)
print(random_num)
r1 = random_num / 10
r2 = random_num % 10
user_num = eval(input())
u1 = user_num / 10
u2 = user_num % 10
if random_num == user_num:
print(5000)
elif r1 == u1 or r2 == u2:
print(3000)
elif r1 == u1 or r1 == u2 or r2 == u1 or r2 == u2:
print(2000)
else:
print("无奖励")
第五题:
nums = eval(input())
ge = nums % 10
nums //= 10
shi = nums % 10
nums //= 10
bai = num % 10
result = ge + shi + bai
print(result)
第六题:
minutes = eval(input())
hours = minutes // 60
days = hours // 24
years = days // 365
days = days % 365
print(years)
print(days)
第七题:
water,first,end = eval(input())
Q = water * (first - end) * 4148
print(Q)
第八题:
a, b, c, d, e, f = eval(input())
x = (e * d - b * f) / (a * d - b * c)
y = (a * f - e *c ) / (a * d - b * c)
print(x)
print(y)
第九题:
x1, y1, x2, y2, x3, y3 = eval(input())
side1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
side2 = ((x3 - x2) ** 2 + (y3 - y2) ** 2) ** 0.5
side3 = ((x1 - x3) ** 2 + (y1 - y3) ** 2) ** 0.5
s = (side1 + side2 + side3) / 2
area = (s * (s - side1) * (s - side2) * (s - side3)) ** 0.5
print("%.1f" % area)
第十题:
import time
print(time.time())
第十一题:
import math
a, b, c = eval(input())
A = math.acos((a * a - b * b - c * c) / (-2 * b * c))
B = math.acos((b * b - a * a - c * c) / (-2 * a * c))
C = math.acos((c * c - b * b - a * a) / (-2 * a * b))
print(A)
print(B)
print(C)
第十二题:
amount = int(input("请输入总金额:"))
denominations = [100, 25, 10, 5, 1]
coin_counts = [0] * len(denominations)
for i, coin in enumerate(denominations):
coin_counts[i] = amount // coin
amount %= coin
print("每种硬币的个数为:", coin_counts)
第十三题:
import math
n, s = eval(input())
area = (n * s *s) / (4 * math.tan(3.14 / n))
print(area)
第十四题:
weight = float(input("请输入体重(kg):"))
height = float(input("请输入身高(米):"))
bmi = weight / (height ** 2)
if bmi < 18.5:
print("较轻")
elif bmi >= 18.5 and bmi < 25:
print("标准")
elif bmi >= 25 and bmi < 30:
print("超重")
else:
print("肥胖")
第十五题:
year = eval(input())
if year / 4 ==0 or year / 100 != 0:
print("yes")
elif year / 400 == 0:
print("yes")
else:
print("no")
第十六题:
import random
random_num = random.randint(10,99)
print(random_num)
r1 = random_num / 10
r2 = random_num % 10
user_num = eval(input())
u1 = user_num / 10
u2 = user_num % 10
if random_num == user_num:
print(5000)
elif r1 == u1 or r2 == u2:
print(3000)
elif r1 == u1 or r1 == u2 or r2 == u1 or r2 == u2:
print(2000)
else:
print("无奖励")
第十七题:
a, b, c = eval(input())
delt = b ** 2 - 4 * a * c
if delt > 0:
x1 = (-b + delt ** 0.5) / (2 * a)
x2 = (-b - delt ** 0.5) / (2 * a)
print(x1)
print(x2)
elif delt == 0:
x = -b / (2 * a)
print(x)
else:
print("无实数解")
第十八题:
a, b, c, d, e, f = eval(input())
x = (e * d - b * f) / (a * d - b * c)
y = (a * f - e *c ) / (a * d - b * c)
print(x)
print(y)
第二十题:
year = int(input("请输入年份:"))
month = int(input("请输入月份:"))
day = int(input("请输入日期:"))
days_in_month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
days_in_month[2] = 29
day_of_year = sum(days_in_month[:month]) + day
print("今天是今年的第{}天。".format(day_of_year))
第二十一题:
while True:
import random
random_num = random.randint(0,2)
user_num = int(input("请输入一个数字,0.石头,1.剪刀,3.布\n"))
if random_num == 0:
print("电脑出的是石头")
if user_num == 0:
print("平局")
elif user_num == 1:
print("你输了")
else:
print("你赢了")
elif random_num == 1:
print("电脑出的是剪刀")
if user_num == 0:
print("你赢了")
elif user_num == 1:
print("平局")
else:
print("你输了")
else:
print("电脑出的是布")
if user_num == 0:
print("你输了")
elif user_num == 1:
print("你赢了")
else:
print("平局")
第二十二题:
def fun1(a, b, c):
if a + b > c and a + c > b and b + c > a:
result = a + b + c
print("构成三角形")
return result
else:
print("此三角形不成立")
a, b, c = eval(input())
result1 = fun1(a, b, c)
print(result1)
第二十三题:
year, month, day = eval(input())
r = (26 * (month + 1)) // 10
k = year % 100
j = year // 100
h = int((day + r + k + (k // 4) +(j // 4) + 5 * j) % 7)
if h == 0:
print("星期六")
elif h == 1:
print("星期天")
elif h == 2:
print("星期一")
elif h == 3:
print("星期二")
elif h == 4:
print("星期三")
elif h == 5:
print("星期四")
elif h == 6:
print("星期五")
else:
print("错误")
第二十四题:
def fun1(num):
num_str = str(num)
return num_str == num_str[::-1]
user_num = input("请输入一个数字:\n")
if fun1(user_num):
print("是回文数")
else:
print("不是回文数")
第二十五题:
x1, y1, wight1, high1 = eval(input())
x2, y2, wight2, high2 = eval(input())
x1_min , x1_max = x1 - wight1 / 2, x1 + wight1 / 2
x2_min , x2_max = x2 - wight2 / 2, x2 + wight2 / 2
y1_min , y1_max = y1 - high1 / 2, y1 + high1 / 2
y2_min , y2_max = y2 - high2 / 2, y2 + high2 / 2
if (x1_min <= x2_max and x1_max >= x2_min and y1_min <= y2_max and y1_max >= y2_min):
print("重叠")
elif (x1_min <= x2_min and x1_max >= x2_max and y1_min <= y2_min and y1_max >= y2_max):
print("包含")
else:
print("相离")
第二十六题:
def fun1(num):
for i in range(1, num + 1): # 打印多少行,再利用最后一行的print进行换行
for j in range(1, i+1): # 打印的是每一行的数字
print(j, end=" ")
print()
def fun2(num):
for i in range(num, 0, -1): # 打印多少行
for j in range(1, i + 1): # 内循环控制数
print(j, end = " ")
print()
def fun3(num):
for i in range(1, num + 1): # 控制行数
for _ in range(num - i): # 打印每行有多少个空格
print(" ",end = " ")
for j in range(i, 0, -1): # 打印数字,倒叙
print(j, end = " ")
print()
def fun4(num):
for i in range(0, num): # 打印每行
for _ in range(i):
print(" ", end = " ")
for j in range(1, num - i + 1):
print(j, end = " ")
print()
第二十七题:
for n in range(1, 8):
for k in range(7 - n):
print(' ', end = " ")
for x in range(1 - n ,n):
print(abs(x) + 1, end = " ")
print()
第二十八题:
for n in range(1,8):
for k in range(7 - n):
print(" ", end = " ")
for x in range(1 - n, n):
num = 2 **(n - 1 - abs(x))
print("%2d" % (num), end = " ")
print()
第二十九题:
rows = 5
for i in range(1, rows + 1):# 1,5
print(" " * (rows - i) + "* " * i)
for i in range(rows - 1, 0, -1):
print(" " * (rows - i) + "* " * i)
第三十题:
n = eval(input())
m = n // 2
for i in range(-m, m+1):
for k in range(abs(i)):
print(" ", end = "")
for j in range(m+1-abs(i)):
print("*",end = " ")
print()