import math
r =eval(input('Enter the length from the center to a vertex:'))
s =2* r * math.sin(math.pi/5)
area =5* s **2/(4* math.tan(math.pi/5))print('The area of the pentagon is %.2f'%area)
第二题
import math
x1,y1 =eval(input('Enter point 1 (latitude and longitude) in degrees:'))
x2,y2 =eval(input('Enter point2(latitude and longitude) in degrees:'))
radius =6371.01
x11 = math.radians(x1)
y11 = math.radians(y1)
x22 = math.radians(x2)
y22 = math.radians(y2)
d = radius * math.acos(math.sin(x11)* math.sin(x22)+ math.cos(x11)* math.cos(x22)* math.cos(y11-y22))print('The distance between the two points is %.14f km'%d)
第三题
import math
s =eval(input('Enter the side :'))
area =(5* s **2)/(4* math.tan(math.pi/5))print('The area of the pentagon is %.14f'%area)
第四题
import math
num =eval(input('Enter the number of side :'))
s =eval(input('Enter the side :'))
area =(num * s **2)/(4* math.tan(math.pi / num))print('The area of the polygon is %.14f'%area)
第五题
a =eval(input('Enter an ASCII code :'))print(chr(a))
第六题
name =input('Enter employee’s name :')
hours =eval(input('Enter number of hours worked in a week :'))
pay =eval(input('Enter hosrly pay tate :'))
federal =eval(input('Enter federal tax withholding rate :'))
state =eval(input('Enter state tax withholding rate :'))print('Employee Name :%s'%name)print('Hours Worked :%s'%hours)print('Pay Rate :$%s'%pay)
gross = hours * pay
print('Gross Pay :$%.2f'%gross)print('Deductions:')
a = federal *100
b = gross * federal
print(' Federal Withholding (%s%%) :$%.2f'%(a,b))
c = state *100
d = gross * state
print(' State Withholding (%s%%) :$%.2f'%(c,d))
res = b + d
print(' Total Deduction : $%.2f'%res)
net = gross - res
print('Net Pay : $%.2f'%net)
第七题
strA =input('Enter an number :')print('The reversed number is %s'%strA[::-1])
第八题
a =input('请输入一串文本:')print('即将进行加密,请稍等!!!')for i in a :
b =ord(i)
c = b +10
d =chr(c-19)print(d,end=" ")
第九题
import math
a , b , c =map(int,input('Enter a, b, c :').split(','))
num = b **2-4* a * c
if num >0:
r1 =(-b + math.sqrt(num))/(a *2)
r2 =(-b - math.sqrt(num))/(a *2)print('The roots are %g and %g '%(r1,r2))elif num ==0:
r =(-b + math.sqrt(num))/(a *2)print('The root is %g'%r)else:print('The equation has no real roots')
第十题
import random
num1 = random.randint(0,101)
num2 = random.randint(0,101)
he = num1 + num2
print('欢迎来到猜数字游戏!!!')print('下面将随机生成两个一百以内的整数')print('*** ***')
res =int(input('请输入你认为这两个数字的和:'))if res == he :print('you are winner!!!')else:print('you are loser !!!')
第十一题
today =int(input('Enter today’s day :'))
sin =int(input('Enter the number of days elapsed sine today :'))
a = sin %7
b = today + a
l ='Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'if b >6:
c = b -7print('Today is %s and the future day is %s'%(l[today],l[c]))else:
c = b
print('Today is %s and the future day is %s'%(l[today],l[c]))
第十二题
a , b , c =map(int,input('请输入需要排序的三个整数').split(','))print('数据排序中,请稍后!!!')if a > b > c :print(c, b, a)elif a > c > b :print(b, c, a)elif b > a > c :print(c, a, b)elif b > c > a :print(a, c, b)elif c > a > b :print(b, a, c)else:print(a, b, c)
第十三题
a , b =map(float,input('Enter weight and price for package 1 :').split(','))
c , d =map(float,input('Enter weight and price for package 2 :').split(','))
p1 = b / a
p2 = d / c
if p1 > p2:print('Package 2 has the better peice.')else:print('Package 1 has the better peice.')
第十四题
month=int(input('请输入月份>>>'))
year=int(input('请输入年份>>>'))if(year%4==0and year%100!=0)or(year%400==0):
i ={1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}print(i[month])else:
j ={1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}print(j[month])
第十五题
import random
i = random.randint(1,2)
res =int(input('请输入猜测的硬币的正反面(正面为1,反面为2):'))if i == res:print('你猜对了!!!')else:print('你猜错了!!!')
第十六题
import numpy as np
computer = np.random.randint(0,3)print(computer)
you =int(input('scissor(0),rock(1),paper(2):'))
ku ='scissor','rock','paper'if computer == you :print('The computer is %s.you are %s too .It is a draw.'%(ku[computer],ku[you]))elif computer ==0and you ==2:print('The comeputer is %s.You are %s.You lose. '%(ku[computer],ku[you]))elif computer ==1and you ==0:print('The comeputer is %s.You are %s.You lose. '%(ku[computer],ku[you]))elif computer ==2and you ==1:print('The comeputer is %s.You are %s.You lose. '%(ku[computer],ku[you]))else:print('The comeputer is %s.You are %s.You won. '%(ku[computer],ku[you]))
第十七题
import math
a ='Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday'
y=int(input('Enter year: (e.g., 2008): '))
m =int(input('Enter month : 1-12 :'))
d =int(input('Enter the day of the month: 1-31:'))
k = y %100
j = y //100if m ==1or m ==2:
m_ = m +12
y_ = y -1
k = y_ %100
j = y_ //100
h =(d +(26*(m_ +1)/10)+ k +(k /4)+(j /4)+(5* j))%7print(a[math.floor(h)])else:
h =(d +(26*(m +1)/10)+ k +(k /4)+(j /4)+(5* j))%7print(a[math.floor(h)])
第十八题
import numpy as np
num = np.random.randint(0,13)
c = np.random.randint(0,4)
a ='Ace','2','3','4','5','6','7','8','9','10','jack','Queen','King'
b ='Clubs','diamonds','spades','hearts'print('The card you picked is the %s of %s'%(a[num],b[c])
第十九题
a =str(input('Enter a three-digit integer :'))if a[0]== a[2]:print('%s is a palindrome '%a)else:print('%s is not a palindrome'%a)
第二十题
a , b , c =map(int,input('Enter three edges :').split(','))if a + b > c and a + c > b and b + c > a :
d = a + b + c
print('the perimeter is %g'%d)else:print('输入不合法!!!')
第二十一题
num1 =0
num2 =0
he =0for i inrange(200):
a =int(input('请输入整数:'))if a ==0:breakelse:if a >0:
num1 +=1else:
num2 +=1
he += a
ping =float( he /(num1 + num2))print('您输入的正数有%d个,负数有%d个,平均值是%g'%(num1,num2,ping))
第一题import mathr = eval(input('Enter the length from the center to a vertex:'))s = 2 * r * math.sin(math.pi/5) area = 5 * s ** 2 / (4 * math.tan(math.pi/5))print('The area of the pentagon is %.2f...