# python❀运算符号作业

Demo01
'''

1、提示用户输入华氏温度
2、将华氏温度转换摄氏温度
3、输出转化后的值
'''
Celsius = float(input("Enter a degree in Celsius："))
fah = (9 / 5) * Celsius +32
print("%.0f Celsius is %.1f Fa"%(Celsius,fah))
#.0保留0位小数、 .1保留一位小数

Demo02
'''

1、提示输入：高、半径
2、分别计算面积和体积
3、输出数据
'''
π = 3.1415926
volume = area * length
print("The area is：%f\nThe volume is：%d"%(area,volume))

Demo03
"""

1.输入一个不超过三位的数字num=123
2.num对10取余 得到 个位 3 - num1
3.num整除10 12
4.num对10取余 得到 十位 2 - num2
5.num整除10 1
6.num对10取余 得到 百位 1 - num3
7.将num1+num2+num3
"""
number = int(input("Enter a number between 0 and 1000:"))
number = abs(number)
num1 = number % 10
number = number // 10
num2 = number % 10
number = number // 10
num3 = number % 10
total = num1 + num2 + num3
# print("The sum of the digits is " + str(total))
print("The sum of the digits is ", total)

Demo04
'''

2、将分钟转化为天数和年数
3、输出天数和年数
'''
minutes = int(input('Enter the number of minuyes：'))
days = minutes / 1440
years = days / 365
print('%.0f minutes is approximately %.0f years and %.0f days'%(minutes,years,days))

Demo05
'''

2、计算出所需热量Q
3、输出所需热量
'''
M = float(input("Enter the amount of water in kilograms："))
initialTemperature = float(input("Enter the initial Temperature:："))
finalTemperature = float(input("Enter the final Temperature："))
Q = M * (finalTemperature - initialTemperature) * 4184
print("The energy needed is %0.1f"%Q)

Demo06
'''

2、计算风寒温度
3、输出风寒温度
'''
temperature = float(input("Enter the temperature in Fahrenheit between -58 and 41 ： "))
speed = float(input("Enter the wind speed in miles per hour："))
chill = 35.74 + 0.6215 * temperature - 35.75 * (speed ** 0.16) + 0.4275 * temperature * (speed ** 0.16)
print('The wind chill index is :%f'%chill)

Demo07
'''

2、计算最短跑道长度
3、输出求得参数
'''
v,a = eval(input("Enter speed an acceleration："))
length = (v ** 2) / (2 * a)
print('The minimum runway length for this airplane is ：%f meters'%length)

Demo08
"""

1.输入一个四位的数字num=1234
2.num对10取余 得到 个位 4 - num1
3.num整除10
4.num对10取余 得到 十位 3 - num2
5.num整除10
6.num对10取余 得到 百位 2 - num3
7.num整除10
8.num对10取余 得到 百位 1 - num4

"""
integer = int(input('Enter an integer：'))
num1 = integer % 10
integer = integer // 10
num2 = integer % 10
integer = integer // 10
num3 = integer % 10
integer = integer // 10
num4 = integer % 10
print('%d\n%d\n%d\n%d'%(num1,num2,num3,num4))

Demo09
"""

1.提示用输入三个点坐标
2.两两计算边长
3.计算半周长s
4.计算面积
"""
x1, y1, x2, y2, x3, y3 = eval(input("Enter three points for a triangle:"))
side1 = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
side2 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
side3 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
s = (side1 + side2 + side3) / 2
area = (s * (s - side1) * (s - side2) * (s - side3)) ** 0.5
print("The area of the triangle is %.1f" % area)
Demo12

python
'''

2、带入公式，算出六个月后的金额
3、输出
'''
monthly = float(input('Enter the monthly saving amount:'))

value1 = (monthly * (1 + 0.00417))
value2 = float(monthly + value1) * (1 + 0.00417)
value3 = (monthly + value2) * (1 + 0.00417)
value4= (monthly + value3) * (1 + 0.00417)
value5 = (monthly + value4) * (1 + 0.00417)
value6 = (monthly + value5) * (1 + 0.00417)
print('After the sixth month,the account value is %0.2f'%value6)


Demo13

'''

2、带入公式
3、输出为例投资额
'''
amount = float(input('Enter investmen amount:'))
rate = float(input('Enter annual interest rate:'))
month = float(input('Enter number of month:'))
vlaue = amount * ((1 + ((rate * 0.01) / 12)) ** month)
print('Accumlated value is %0.2f'%vlaue)


Demo15

'''

2、根据公式计算面积
3、输入面积
'''
import math
number = float(input('Enter the number of sides:'))
side = float(input('Enter the side:'))
area = (number * (side ** 2)) / (4 * math.tan(math.pi/ number))
print('The area of the polygon is %f'%area)


Demo16

'''

2、把个位十位百位千位剥离出来
3、反向输出
'''
integer = int(input('Enter an integer:'))
num1 = integer % 10
integer = integer // 10
num2 = integer % 10
integer = integer // 10
num3 = integer % 10
integer = integer // 10
num4 = integer % 10
print('%d%d%d%d'%(num1,num2,num3,num4))


Demo18

'''

2、计算出税后所得和扣税多少
3、输出
'''
name = str(input('Enter employee‘s name:'))
hours = float(input('Enter number of hours worked in a week:'))
hourly = float(input('Enter hourly pay rate:'))
federal = float(input('Enter federal tax withholding rate:'))
state = float(input('Enter state tax withholding rate:'))
a = hours * hourly
b = a * 0.2
c = a * 0.09
d = b + c
e = a - d

print('Employee Name:%s'%name)
print('Hours Worked:%.2f'%hours)
print('Pay Rate:$%.2f '%hourly) print('Gross Pay:$%.2f'%a)
print('Deductions:')
print('\tFederal Withholding(0.2):$%.2f'%b) print('\tState Withholding(0.09):$%.2f'%c)
print('\tTotal Deduction:$%.2f'%d) print('Net Pay:$%.2f'%e)

`

09-22
01-23 7869
02-12 730