【无标题】

代码片.


19
set1 = "1\t3\t5\t7\n" \
       "9\t11\t13\t15\n" \
       "17\t19\t21\t23\n" \
       "25\t27\t29\t31\n"
set2 = "2\t3\t6\t7\n" \
       "10\t11\t14\t15\n" \
       "18\t19\t22\t23\n" \
       "26\t27\t30\t31\n"
set3 = "4\t5\t6\t7\n" \
       "12\t13\t14\t15\n" \
       "20\t21\t22\t23\n" \
       "28\t29\t30\t31\n"
set4 = "8\t9\t10\t11\n" \
       "12\t13\t14\t15\n" \
       "24\t25\t26\t27\n" \
       "28\t29\t30\t31\n"
set5 = "16\t17\t18\t19\n" \
       "20\t21\t22\t23\n" \
       "24\t25\t26\t27\n" \
       "28\t29\t30\t31\n"
day = 0
print(set1)
a = input("你的生日是否在表格中(yes/no):")
if a == "yes" :
       day += 1
print(set2)
a = input("你的生日是否在表格中(yes/no):")
if a == "yes" :
       day += 2
print(set3)
a = input("你的生日是否在表格中(yes/no):")
if a == "yes" :
       day += 4
print(set4)
a = input("你的生日是否在表格中(yes/no):")
if a == "yes" :
       day += 8
print(set5)
a = input("你的生日是否在表格中(yes/no):")
if a == "yes" :
       day += 16
if a == 0 :
       print("不存在")
else :
       print("你的生日在%s号"%(day))

20
a = float(input("请输入身高:"))
b = float(input("请输入体重:"))
BMI = b / (a **2)
if BMI < 18.5 :
	print("超轻")
elif BMI >= 18.5 and BMI < 25.0 :
	print("标准")
elif BMI >= 25.0 and BMI < 30.0 :
	print("超重")
else :
	print("痴胖")
 Demo21

21
year = int(input("请输入年份:"))
first = year % 4 == 0 and year % 100 != 0
second = year % 400 == 0
if first or second :
	print("%d是个闰年"%(year))
else :
	print("%d是个平年"%(year))
22

import random 
number = int (input("输入一个两位数的数值:"))
computer = random.randint(10,99)
print("电脑的数字:%s" %computer)
c1 = computer//10
c2 = computer%10
num1 = number//10
num2 = number%10
if c1 == num1 and c2 == num2:
  print("恭喜你与电脑相同,可得10000元。")
elif c1 == num2 or c2 ==num1 :
  print("只有一个顺序相同,得到3000元。")
elif c1 == num1 or c1== num2  or c2 == num2 or c2 == num1:
  print("相同1000") 
else:
  print("yo die")
23

a,b,c = eval(input("请输入三个数:"))
delt = b * b - 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("The equation has no roots")
24

a,b,c,d,e,f = eval(input("请输入6个数:"))
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 %s , y is %s"%(x,y))
25

today = int(input("请输入今天的日期:"))
a = int(input("请输入要经过多少天:"))
if (today + a) % 7 == 0 :
	print("Today is Sunday and future day is 星期天")
elif (today + a) % 7 == 1 :
	print("Today is Sunday and future day is 星期一")
elif (today + a) % 7 == 2 :
	print("Today is Sunday and future day is 星期二")
elif (today + a) % 7 == 3 :
	print("Today is Sunday and future day is 星期三")
elif (today + a) % 7 == 4 :
	print("Today is Sunday and future day is 星期四")
elif (today + a) % 7 == 5 :
	print("Today is Sunday and future day is 星期五")
elif (today + a) % 7 == 6 :
	print("Today is Sunday and future day is 星期六")
26
weight1,price1 = eval(input("请输入第一种包装的重量和价钱:"))
weight2,price2 = eval(input("请输入第二种包装的重量和价格:"))
if (price1 / weight1) > (price2 / weight2) :
	print("第二种更好")
elif (price1 / weight1) == (price2 / weight2) :
	print("两种一样好")
else :
	print("第一种更好")
27

a = int(input("请输入一个整数:") )
if a % 5 == 0 and a % 6 == 0:
    print("%d这个数能被5和6都整除" % a)
elif a % 5 != 0 and 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)
28

import random
player = int(input("请输入:0剪刀,1石头,2布 :"))
computer = random.randint(0,2)
if (player == 0 and computer == 2) or (player == 1 and computer == 0) or (player == 2 and computer ==1) :
  print("恭喜你,你赢了!")
elif player == computer :
  print("平局。")
else :
  print("真遗憾,你输了。")
29
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")
30

a, b, c = eval(input("Enter three sides:"))
if a + b > c and a + c > b and b + c > a:
    print("%s"%(a+b+c))
else :
    print("非法")
    31
    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 = 0
if month == 1 or 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) % 7
if 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 星期五")
32

x1, y1 = eval(input("请输入一个点的坐标:"))
x2 = 0 
y2 = 0
l = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
if l <= 10 :
	print("这个点在圆内")
else :
	print("这个点在圆外")
33
x, y = eval(input("请输入一个点的坐标::"))
if x >= -5 and x <= 5 and y <= 2.5 and y >= -2.5:
    print("点 (%.1f,%.1f) 在矩形内"%(x,y))
else :
    print("点 (%.1f,%.1f) 不在矩形内" % (x, y))
34

num = int(input("请输入一个三位整数:"))
a = num % 10
b = num // 100
if a == b :
	print("%d是回文数"%(num))
else :
	print("%d不是回文数"%(num))
	35
	
x, y = eval(input("Enter a point's x- and y-coordinates:"))

if x >= 0 and x <= 200 and y >= 0 and 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")
36

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.5
 
if d <= abs(r1 - r2):
    print("circle2 is inside circle1")
elif  d <= r1 + r2:
    print("circle2 overlaps circle1")
else:
    print("circle2 does not overlap circle")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值