题目:
代码
- 十九
- 二十
- 二十一
- 二十二
- 二十三
- 二十四
- 二十五
- 二十六
- 二十七
- 二十八
- 二十九
- 三十
- 三十一
- 三十二
- 三十三
- 三十四
- 三十五
- 三十六
十九
birthday = int(input(“请输入生日日期:”))
Set1 = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31]
Set2 = [2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31]
Set3 = [4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31]
Set4 = [8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31]
Set5 = [16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
if (birthday == (Set1[0] + Set2[0]+ Set3[0])):
print(“在数字集里”)
elif(birthday == (Set1[0] + Set2[0] + Set4[0])):
print(“在数字集里”)
elif(birthday == (Set1[0] + Set2[0] + Set5[0])):
print(“在数字集里”)
elif(birthday == (Set2[0] + Set3[0] + Set4[0])):
print(“在数字集里”)
elif(birthday == (Set2[0] + Set3[0] + Set5[0])):
print(“在数字集里”)
elif(birthday == (Set3[0] + Set4[0] + Set5[0])):
print(“在数字集里”)
else:
print(“不在数字集里”)
二十
height = 1.75
weight = 80.5
BMI = kg / tall * tall
if BMI < 18.5:
print(“过轻”)
elif 18.5 <= BMI < 25:
print(“正常”)
elif 25 <= BMI <28:
print(“过重”)
elif 28 <= BMI < 32:
print(“肥胖”)
elif BMI > 32:
print(“严重肥胖”)
二十一
num = int(input(“请输入一个年份:”))
if num % 4 == 0 and num % 100 != 0 or num % 400 == 0:
print(“这个年份是闰年”)
else:
print(“不是闰年”)
二十二
import random
num = int(input(“请输入一个两位数字:”))
ran = random.randint(10,99)
Tennum = num % 10
Bitnum = num / 10
oneran = ran % 10
tworan = ran / 10
if(num == ran):
print(“得奖金10000美元”)
elif(Tennum == oneran and Tennum == tworan or Bitnum == oneran and Bitnum == tworan):
print(“得奖金3000美元”)
elif(Tennum == oneran or Tennum == tworan or Bitnum == oneran or Bitnum == tworan):
print(“得奖金1000美元”)
二十三
a = int(input(“请输入a的值:”))
b = int(input(“请输入b的值:”))
c = int(input(“请输入c的值:”))
s = b ** 2 - 4 * a * c
r1 = (-b + s ** 0.5) / (2 * a)
r2 = (-b - s ** 0.5) / (2 * a)
if(s > 0):
print(“得出两个根:\n”,r1,r2)
elif(s == 0):
print(“得出两个相等实根:”,r1)
else:
print(“无实根”)
二十四
a = float(input(“请输入a:”))
b = float(input(“请输入b:”))
c = float(input(“请输入c:”))
d = float(input(“请输入d:”))
e = float(input(“请输入e:”))
f = float(input(“请输入f:”))
x = (e * d - b * f) / (a * d - b * c)
y = (a * f - e * c) / (a * d - b * c)
if(a * d - b * c == 0):
print(“The equation has no solution”)
else:
print(“x is”,x,"y is ",y)
二十五
day = int(input(“请输入表示星期的7个数字0-6,星期天是0:”))
future = int(input(“请输入另一个数,表示未来的星期数:”))
days = (day + future) % 7
if(day == 0 and days):
print(“Today is Sunday”)
elif(day == 1):
print(“Today is Mondy”)
elif(day == 2):
print(“Today is Tuesday”)
elif(day == 3):
print(“Today is Wednesday”)
elif(day == 4):
print(“Today is Thursday”)
elif(day == 5):
print(“Today is Friday”)
elif(day == 6):
print(“Today is Saterday”)
if(days == 0):
print(“Today is Sunday”)
elif(days == 1):
print(“Today is Tuesday”)
elif(days == 2):
print(“Today is Wednesday”)
elif(days == 3):
print(“Today is Wednesday”)
elif(days == 4):
print(“Today is Thursday”)
elif(days == 5):
print(“Today is Friday”)
elif(days == 6):
print(“Today is Saterday”)
二十六
package1x,package1y = map(float,input(“请输入第一种包装的重量和价钱:”).split(‘,’))
package2x,package2y = map(float,input(“请输入第二种包装的重量和价钱:”).split(‘,’))
if package1x / package1y < package2x / package2y:
print(“Package 2 has the better price”)
else:
print(“Package 1 has the better price”)
二十七
num = int(input(“请输入一个整数:”))
if num % 5 == 0 and num % 5 == 0:
print(“num % 5 == 0 and num % 5 == 0 is True”)
elif num % 5 == 0 or num % 6 == 0:
print(“num % 5 == 0 or num % 6 == 0 is True”)
else:
print(“num % 5 == 0 or num % 6 == 0 is False”)
二十八
import random
num = int(input(“请输入一个0-2的整数:”))
ran = random.randint(0,2)
if num == ran:
print(“平局”)
elif num > ran >= 1:
print(“You won”)
elif ran > num >= 1:
print(“You draw”)
elif num < ran <= 1:
print(“You draw”)
elif ran < num <= 1:
print(“You won”)
elif num == 2 and ran == 0:
print(“You draw”)
elif num == 0 and ran == 2:
print(“You won”)
二十九
num = float(input(“美元转人民币汇率为0,人民币转美元汇率为1:”))
if num == 0:
data1 = float(input(“请输入美元金额:”))
data1 = data1 * 7.14
print(“转换为人民币金额为:”,data1)
elif num == 1:
data2 = float(input(“请输入人民币金额:”))
data2 = data2 / 7.14
print(“转换为美元金额为:”,data2)
三十
side1,side2,side3 = map(float,input(“请输入三边长度:”).split(‘,’))
if side1 + side2 > side3 and side2 + side3 > side1 and side1 + side3 > side2:
print(“输入合法”)
else:
print(“输入不合法”)
三十一
year = int(input(“请输入年份:”))
month = int(input(“请输入月份:”))
if month == 1 :
month = 13 and year - 1
elif month == 2:
month = 14 and year - 1
day = int(input(“请输入这个月的某一天:”))
k = year % 100
j = year / 100
h = (day + (26 * (month + 1) / 10) + k + (k / 4) + (j / 4) + 5 * j) % 7
h = round(h)
if h == 1:
h = “一”
elif h == 2:
h = “二”
elif h == 3:
h = “三”
elif h == 4:
h = “四”
elif h== 5:
h = “五”
elif h == 6:
h = “六”
elif h== 7:
h = “日”
print(“这是一周的星期”,h)
三十二
x,y = map(float,input(“请输入点x,y:”).split(‘,’))
if (x ** 2 + y ** 2) ** 0.5 <= 10:
print(“在圆内”)
else:
print(“不在圆内”)
三十三
x,y = map(float,input(“请输入点x,y:”).split(‘,’))
if abs(x) >= 5 or abs(y) >= 2.5:
print(“不在矩形内”)
else:
print(“在矩形内”)
三十四
num = int(input(“请输入一个三位整数:”))
numList = list(str(num)) #存储输入函数
tmpList = list(str(num)) #存入反转函数
tmpList.reverse() #数字反转函数 使输入的数值进行反转 然后对其两个数值进行判断
if numList == tmpList:
print(num)
print(“这个数是回文数”,num)
三十五
x,y = map(float,input(“请输入一个坐标x,y:\n”).split(‘,’))
if x * y == 200 * 100:
print(“坐标在三角形中”)
else:
print(“坐标不在三角形中”)
三十六
r1x,r1y = map(float,input(“请输入第一个圆的圆心坐标:”).split(‘,’))
r2x,r2y = map(float,input(“请输入第二个圆的圆心坐标:”).split(‘,’))
r1 = float(input(“请输入第一个圆的半径:”))
r2 = float(input(“请输入第二个圆的半径:”))
if ((r1x - r2x) ** 2 + (r1y - r2y) ** 2) ** 0.5 <= abs(r1 -r2):
print(“圆2在圆1内”)
elif ((r1x - r2x) ** 2 + (r1y - r2y) ** 2) ** 0.5 >= r1 + r2:
print(“圆2和圆1是有重叠的”)
else:
print(“圆2和圆1没有相交关系”)