year =int(input("请输入年份:"))
condition1 = year %4==0and year %100!=0
condition2 = year %400==0if condition1 or condition2:print(year,"是个闰年")
第二十二题
import random
com = random.randint(10,99)
usr =int(input("请输入数字:"))
ca = com //10
cb = com %10
ua = usr //10
ub = usr %10if ca == ua and cb == ub :print("10000美金")elif ca == ub and cb == ua :print("3000美金")elif ca == ua or ca == ub or cb == ua or cb == ub :print("1000美金")else:print("无")
第二十三题
a, b, c =eval(input("Enter a,b,c:"))
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 = %.2f , x2 = %.2f"%(x1, x2))elif delt ==0:
x =(-b - delt **0.5)/(2* a)print("x = %.2f"% x)else:print("No real roots")
第二十四题
a, b, c, d, e, f =eval(input("Enter a,b,c,d,e,f:"))if a * d - b * c ==0:print("The equation has no solution")else:
x =(e * d - b * f)/(a * d - b * c)
y =(a * f - e * c)/(a * d - b * c)print("x is %.1f and y is %.1f"%(x,y))
第二十五题
oday =int(input("输入今天的日期,例如(星期天是0,星期一是1, ....,星期六是6):"))
a =int(input("请输入要经过多少天:"))if(today + a)%7==0:print("Today is Sunday and the future day is 星期天")elif(today + a)%7==1:print("Today is Sunday and the future day is 星期一")elif(today + a)%7==2:print("Today is Sunday and the future day is 星期二")elif(today + a)%7==3:print("Today is Sunday and the future day is 星期三")elif(today + a)%7==4:print("Today is Sunday and the future day is 星期四")elif(today + a)%7==5:print("Today is Sunday and the future day is 星期五")elif(today + a)%7==6:print("Today is Sunday and the future day is 星期六")
a =int(input("请输入一个整数:"))if a %5==0and a %6==0:print("%d这个数能被5和6都整除"% a)elif a %5!=0and(a %6==0):print("%d这个数能被6整除,但不能被5整除"% a)elif(a %5==0)and(a %6!=0):print("%d这个数能被5整除,但不能被6整除"% a)elif(a %5!=0)and(a %6!=0):print("%d这个数不能被5或者6整除"% a)
第二十八题
import random
com = random.randint(0,2)
usr =int(input("剪刀(0),石头(1),布(2):"))
com_str =""
usr_str =""if com ==0:
com_str ="剪刀"elif com ==1:
com_str ="石头"else:
com_str ="布"if usr ==0:
usr_str ="剪刀"elif usr ==1:
usr_str ="石头"else:
usr_str ="布"if com == usr:print("玩家是%s,电脑是%s,是一个平局"%(usr_str, com_str))elif usr - com ==-1or usr - com ==2:print("玩家是%s,电脑是%s,玩家输"%(usr_str, com_str))else:print("玩家是%s,电脑是%s,玩家赢"%(usr_str, com_str))
第二十九题
rate =eval(input("Enter the exchange rate from do1lars to RMB: "))
choice =eval(input("Enter 0 to convert do11ars to RMB and 1 vice versa: "))
amount =eval(input("Enter the do1lar amount: "))if choice ==0:
amount1 = amount * rate
print("$%.1f is %.1f yuan"%(amount,amount1))elif choice ==1:
amount1 = amount / rate
print("%.1f yuan is $%.2f"%(amount, amount1))else:print("Incorrect input")
第三十题
a, b, c =eval(input("Enter three sides:"))if a + b > c and a + c > b and b + c > a:print(a+b+c,"合法")else:print("不合法")
第三十一题
import math
year =eval(input("Enter year:(e,g.,2008):"))
month =eval(input("Enter month:1-12:"))
q =eval(input("Enter the day of the month:1-31:"))
m =0if month ==1or month ==2:
m =12+ month
year = year -1
j = year //100
k = year %100
h =(q +((26*(m +1))//10)+ k + k //4+ j //4+5* j)%7if h ==0:print("Today is Sunday and the future day is 星期六")elif h ==1:print("Today is Sunday and the future day is 星期天")elif h ==2:print("Today is Sunday and the future day is 星期一")elif h ==3:print("Today is Sunday and the future day is 星期二")elif h ==4:print("Today is Sunday and the future day is 星期三")elif h ==5:print("Today is Sunday and the future day is 星期四")elif h ==6:print("Today is Sunday and the future day is 星期五")
第三十二题
x, y =eval((input("Enter a point with two coordinates:")))if x <=10and y <=10:print("Point (%.1f,%.1f) is in the circle"%(x,y))else:print("Point (%.1f,%.1f) is not in the circle"%(x,y))
第三十三题
x, y =eval(input("Enter a point with two coordinates:"))if x >=-5and x <=5and y <=2.5and y >=-2.5:print("Point (%.1f,%.1f) is in the rectangle"%(x,y))else:print("Point (%.1f,%.1f) is not in the rectangle"%(x, y))
第三十四题
number =int(input("Enter a three-digit integer:"))
a = number %10
b = number //100if a == b:print("%d is a palindrome"%number)else:print("%d not is a palindrome"%number)
第三十五题
x, y =eval(input("Enter a point's x- and y-coordinates:"))if x >=0and x <=200and y >=0and y <=100:
k = y /(200- x)if k <=100/200: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")
第三十六题
x1, y1, r1=eval(input("Enter circlel's_ center x1,y1coordinates,and radius:"))
x2, y2, r2=eval(input("Enter circlel's_ center x2,y2coordinates,and radius:"))
d =((x2 - x1)**2+(y2 - y1)**2)**0.5if d <=abs(r1 - r2):print("circle2 is inside circle1")elif d <= r1 + r2:print("circle2 overlaps circle1")else:print("circle2 does not overlap circle")