1.1python语言有哪些数据类型
字符串、整型、浮点型、复数型、布尔值型、列表、元组、集合、字典
1.7
a = int(input("请输入一个整数:")) b = int(a/100) c = a % 10 d = int(a/10) % 10 print(b, c, d) if a == b*b*b + c*c*c + d*d*d & a > 99: print("%d是水仙花数" % a) else: print("%d不是水仙花数" % a)
1.8
import random a = random.randint(100, 1000) print(a) # a = int(input("请随机输入一个三位整数:")) b = a % 10 c = int(a / 100) a = b + c * 100 print(b, c, a)
1.9
x = int(input("请输入整数x:")) y = int(input("请输入整数y:")) z = int(input("请输入整数z:")) if x*x+y*y+z*z > 1000: print(x*x+y*y+z*z) print(int((x*x+y*y+z*z) / 10000)) else: print(x + y + z)
1.10
s = input("请输入您所运输的距离:") p = 10 w = 21 s = 34 if s < 250: d = 0 elif 250 <= s < 500: d = 2.5 elif 500 <= s < 1000: d = 4.5 elif 1000 <= s < 2000: d = 7.5 elif 2000 <= s < 2500: d = 9.0 elif 2500 <= s < 3000: d = 12.0 else: d = 15.0 f = p * w * s*(1 - d * 0.01) print("所需的运费为%.2f" % f)
1.11
y = int(input("请输入今天的年份:")) d = int(input("请输入今天的日:")) m = int(input("请输入今天的月份:")) year = y - (14 - m) // 12 x = year + year // 4 - year // 100 + year // 400 month = m + 12 * ((14 - m) // 12) - 2 date = (d + x + (31 * month) // 12) % 7 print(year, month, date) if date == 0: date = "日" elif date == 1: date = "一" elif date == 2: date = "二" elif date == 3: date = "三" elif date == 4: date = "四" elif date == 5: date = "五" else: date = "六" print("%d年%d月%d日是周%s" % (y, m, d, date))
1.12
N = float(input("您的存款年限为:")) r = float(input("您的年利率为:")) P = float(input("你的贷款金额为:")) N1 = float(12*N) r1 = float(r/12) s = (P*r1*pow((1+r1), N1))/(pow((1+r1), N1)-1) print(s)
1.13
import math R = 6370000 x1 = float(input("请输入地球上A点的经度:")) y1 = float(input("请输入地球上A点的纬度:")) x2 = float(input("请输入地球上B点的经度:")) y2 = float(input("请输入地球上B点的纬度:")) d = R * math.acos(math.acos(math.cos(math.radians(x1) -math.radians(x2)))*math.cos(math.radians(y1))*math.cos(math.radians(y2)) +math.sin(math.radians(y1))*math.sin(math.radians(y2))) print("地球上A、B两点的大圆弧距离为%f" % d)
1.14
for i in range(1, 1000): sum_of_factors = 0 for j in range(1, i): if i % j == 0: sum_of_factors += j if sum_of_factors == i: print("%d为完数" % i) else: print("%d不是完数" % i)
1.15
x = [1, 2, 3] y = [-1, -2, -3] print(zip(*zip(x, y))) zipped = zip(*zip(x, y)) print(list(zipped))
1.16
def judge(x: str): a = [i.isupper() for i in x] b = [i.islower() for i in x] c = [i.isdigit() for i in x] d = [not (i.isdigit() | i.isalpha()) for i in x] return map(sum, [a, b, c, d]) res = judge("aBNDE*&cs12") print(tuple(res))
1.17
import num2word int1 = int(input("请您输入一个整数:")) a = num2word.word(int1) print(a)
水平很低着,还请大家多多指正!