v_out=v_in*pow(r_in/r_out,2)
from math import pi
r_cube = (d*p)/(pi*S)
r = r_cube**(1/3)
r = r/12
money = (P*r*((1+r)**N))/(((1+r)**N)-1)
y_0 = y-(14-m)/12
x = y_0+y_0/4-y_0/100+y_0/400
m_0 = m+12*((14-m)/12)-2
d_0 = (d+x+(31*m_0)/12) % 7
from math import acos, sin, cos
R = 6367000
x_1, y_1 = 49.87, -2.33
x_2, y_2 = 37.8, -122.4
d = R*acos(sin(x_1)*sin(x_2)+cos(x_1)*cos(x_2)*cos(y_1-y_2))
print(f'巴黎和旧金山两点间的大圆弧距离是:{d}m.')
# 巴黎和旧金山两点间的大圆弧距离是:5330001.193839m.
v = float(input())
def get_level(v):
if 74<=v<=95:
return 1
elif 96<=v<=100:
return 2
elif 101<=v<=130:
return 3
elif 131<=v<=154:
return 4
elif v>=155:
return 5
else:
return 0
print(f'飓风的级别是:{get_level(v)}')
card_num = list(map(int, list(input())))
def is_valid(card_num):
nums_1 = card_num[::-2]
sums_1 = sum(nums_1)
nums_2 = card_num[::2]
nums_2 = [str(2*x) for x in nums_2[::-1]]
nums_2 = "".join(nums_2)
sums_2 = sum(map(int, list(nums_2)))
sums = sums_1+sums_2
if str(sums)[-1] == 0:
return True
else:
return False
if is_valid(card_num):
print(f'信用卡号有效')
else:
print(f'信用卡号无效')
isbn = list(map(int, list(input())))
sums = 0
for i, num in enumerate(isbn[::-1], 2):
sums += i*num
for j in range(0, 11):
if (j+sums) % 11 == 0:
if j == 10:
check_sum = 'X'
else:
check_sum = j
isbn.append(check_sum)
ans = ''.join(list(map(str, isbn)))
print(f'ISBN号为{ans}.')
def majority(x,y,z):
lt=[x,y,z]
if lt.count(True)>=2:
return True
else:
return False
参考链接:LeetCode-Python-273. 整数转换英文表示
num = input()
def get_english(num):
n = int(num)
if n < 100: # 两位数的情况
return subhelper_1(num)
else: # 三位数的情况
return subhelper_2(num)
def subhelper_1(num):
n = int(num)
l1 = ["Zero", "One", "Two", "Three", "Four",
"Five", "Six", "Seven", "Eight", "Nine"]
l2 = ["Ten", "Eleven", "Twelve", "Thirteen", "Fourteen",
"Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"]
l3 = ["Twenty", "Thirty", "Forty", "Fifty",
"Sixty", "Seventy", "Eighty", "Ninety"]
if n < 10:
return l1[n]
if 10 <= n < 20:
return l2[n-10]
if 20 <= n < 100:
# 判断最后一位是否为0
if num[1] != 0: # 不是整十
return l3[int(num[0])-2]+' '+l1[int(num[1])]
else: # 整十
return l3[int(num[0])-2]
def subhelper_2(num):
l1 = ["Zero", "One", "Two", "Three", "Four",
"Five", "Six", "Seven", "Eight", "Nine"]
if num[1:] != '00': # 不是整百
return l1[int(num[0])] + ' hundred '+subhelper_1(num[1:])
else: # 整百
return l1[int(num[0])] + ' hundred '
print(f'{get_english(num)}')
来源:CSDN
作者:huxuedan01
链接:https://blog.csdn.net/m0_37586991/article/details/104144896