python判断语句19-36题
set1 = "1t3t5t7n"
"9t11t13t15n"
"17t19t21t23n"
"25t27t29t31n"
set2 = "2t3t6t7n"
"10t11t14t15n"
"18t19t22t23n"
"26t27t30t31n"
set3 = "4t5t6t7n"
"12t13t14t15n"
"20t21t22t23n"
"28t29t30t31n"
set4 = "8t9t10t11n"
"12t13t14t15n"
"24t25t26t27n"
"28t29t30t31n"
set5 = "16t17t18t19n"
"20t21t22t23n"
"24t25t26t27n"
"28t29t30t31n"
birthday = 0
print(set1)
a = input("birthday not in set1(y/n):")
if a == "y":
birthday+=1
print(set2)
a = input("birthday not in set1(y/n):")
if a == "y":
birthday+=2
print(set3)
a = input("birthday not in set1(y/n):")
if a == "y":
birthday+=4
print(set4)
a = input("birthday not in set1(y/n):")
if a == "y":
birthday+=8
print(set5)
a = input("birthday not in set1(y/n):")
if a == "y":
birthday+=16
print(birthday)
a,b = eval(input("输入体重和身高:"))
BMI = a * 0.45359237 / ((b * 0.0254))**2
if BMI < 18.5:
print("超轻")
elif 18.5 <= BMI <25.0:
print("标准")
elif 25.0 <= BMI <30.0:
print("超重")
else:
print("痴肥")
year = int(input("请输入年份:"))
a = year % 4==0 and year % 100!=0
b = year % 400==0
if a or b:
print("这个年份是闰年")
else:
print("这个年份不是闰年")
import random
com = random.randint(10,99)
a = int(input("输入一个两位数的数字:"))
b = a // 10
c = a % 10
d = com // 10
e = com % 10
if b == d and c == e:
print("奖金10000美元")
elif b == e and c == d:
print("奖金3000美元")
elif b == d or b == e or c == d or c == e:
print("奖金1000美元")
else:
print("0美元")
a,b,c = eval(input("Enter a,b,c:"))
g = b ** 2 - 4 * a * c
if g > 0:
r1 = (-b+g**0.5)/(2*a)
r2 = (-b-g**0.5)/(2*a)
print("The roots are %.6f and %.5f"%(r1,r2))
elif g == 0:
print("The root is %s"%r1)
else:
print("The equation has no real roots")
a,b,c,d,e,f = eval(input("Enter a,b,c,d,e,f:"))
h = a * d - b * c
if h !=0:
x = (e * d - b * f)/(a * d - b * c)
y = (a * f - e * c)/(a * d - b * c)
print(" x is %s and y is %s"%(x,y))
else:
print("The equation has no solution")
Day = int(input("Enter today's day:"))
day1 = int(input("Enter the number of days elapsed since today:"))
day2 = Day + day1
a = day2 % 7
if day1 == 0:
Day = 'Sunday'
elif day1 == 1:
Day = 'Monday'
elif day1 == 2:
Day = 'Tuesday'
elif day1 == 3:
Day = 'Wednesday'
elif day1 == 4:
Day = 'Thursday'
elif day1 == 5:
Day = 'Friday'
else:
Day = 'Saturday'
if a == 0:
today = 'Sunday'
elif a == 1:
today = 'Monday'
elif a == 2:
today = 'Tuesday'
elif a == 3:
today = 'Wednesday'
elif a == 4:
today = 'Thursday'
elif a == 5:
today = 'Friday'
else:
today = 'Saturday'
print("Todays is %s and the future day is %s" %(today,Day))
a,b = eval(input("Enter weight and price for package 1:"))
c,d = eval(input("Enter weight and price for package 2:"))
e = a / b
f = c / d
if e > f:
print("package 1 has the better price")
elif e = f:
print("Both packages are equally cheap")
else:
print("package 2 has the better price")
a = int(input("Enter an integer:"))
b = a % 5
c = a % 6
if b == 0 and c == 0:
d = "True"
else:
d = "False"
if b == 0 or c == 0:
e = "True"
else:
e = "False"
if b != 0 and c == 0:
f = "True"
elif b == 0 and c != 0:
f = "True"
else:
f = "False"
print("Is %s divisible by 5 and 6?%s"%(a,d))
print("Is %s divisible by 5 or 6?%s"%(a,e))
print("Is %s divisible by 5 and 6, but not both?%s"%(a,f))
import random
com = random.randint(0,2)
a = int(input("scissor(0),rock(1),paper(2):"))
if com == 0 and a ==0:
print("The computer is scissor. You are scissor too. It is a draw")
elif com == 1 and a ==1:
print("The computer is rock. You are rock too. It is a draw")
elif com == 2 and a ==2:
print("The computer is paper. You are paper too. It is a draw")
elif com == 0 and a ==2:
print("The computer is scissor. You are paper. You lost")
elif com == 0 and a ==1:
print("The computer is scissor. You are rock. You won")
elif com == 1 and a ==2:
print("The computer is rock. You are paper. You won")
elif com == 2 and a ==0:
print("The computer is paper. You are scissor. You won")
elif com == 1 and a ==0:
print("The computer is rock. You are scissor. You lost")
elif com ==2 and a == 1:
print("The computer is paper. You are rock. You lost")
a = float(input("Enter the exchange rate from dollars to RMB:"))
b = float(input("Enter 0 to convert dollars to RMB and 1 vice versa:"))
if b == 0:
c = float(input("Enter the dollars amount:"))
d = a * c
print("$%.1f is %.1f yuan"%(c,d))
elif b == 1:
c = float(input("Enter the RMB amount:"))
e = c / a
print("%.1f yuan is $%.2f"%(c,e))
else:
print("Incorrect input")
a,b,c = eval(input("Enter three edges:"))
d = a + b + c
if a + b > c and c - a >= 0 and c - b >= 0:
print("The perimeter is %s"%d)
elif a + c > b and b - a >= 0 and b - c >= 0:
print("The perimeter is %s"%d)
elif b + c > a and a - c >= 0 and a - b >= 0:
print("The perimeter is %s"%d)
else:
print("The input is invalid")
year = int(input("Enter year :(e.g.,2008):"))
month = int(input("Enter month: 1-12:"))
q = int(input("Enter the day of the month: 1-31:"))
if month == 1:
m = 13
k = year % 100 - 1
elif month == 2:
m = 14
k = year % 100 - 1
else:
m = month
k = year % 100
j = year // 100
h = (q + (26 * (m + 1)) // 10 + k + k // 4 + j // 4 + 5 * j) % 7
if h == 0:
a = "Saturday"
elif h == 1:
a = "Sunday"
elif h == 2:
a = "Monday"
elif h == 3:
a = "Tuesday"
elif h == 4:
a = "Wednesday"
elif h == 5:
a = "Thursday"
else:
a = "Friday"
print("Days of the week is %s"%a)
x1,y1 = eval(input("Enter a point with two coordinates:"))
d = ((x1)**2+(y1)**2)**0.5
if d <= 10:
print("Point (%.1f,%.1f) is in the circle"%(x1,y1))
else:
print("Point (%.1f,%.1f) is not in the circle"%(x1,y1))
x1,y1 = eval(input("Enter a point with two coordinates:"))
d = ((x1 - 0)**2)**0.5
s = ((y1 - 0)**2)**0.5
if d <= (10 / 2) and s <= (5.0 / 2):
print("Point (%.1f,%.1f) is in the rectangle"%(x1,y1))
else:
print("Point (%.1f,%.1f) is not in the rectangle"%(x1,y1))
a = int(input("Enter a three-digit integer:"))
b = a // 100
c = a // 10 % 10
d = a % 10
e = 100 * d + 10 * c + b
if a == e:
print("%s is a palindrome"%a)
else:
print("%s is not a palindrome"%a)
x,y = eval(input("Enter a point's x- and y-coordinates:"))
if 0 <= x <= 200 and 0 <= y <= 100 :
k = -y / (x - 200)
if k <= 0.5:
print("The point is in the triangle")
else:
print("The point is not in the triangle")
else:
print("The point is not in the triangle")
import math
x1,y1,r1 = eval(input("Enter circle's center x-,y-coordinates, and radius:"))
x2,y2,r2 = eval(input("Enter circle's center x-,y-coordinates, and radius:"))
d = math.sqrt((x1-x2)**2+(y1-y2)**2)
a = math.sqrt((r1 - r2)**2)
if d <= a:
print("circle2 is inside circle1")
elif d <= r1 + r2:
print("circle2 overlaps circle1")
else:
print("circle2 does not overlaps circle1")



