python初级课程作业6

# q={1:10,'iambatman':'bulusiweien','liemoren':'jieluote'}
# print(q.keys())
# print(q.values())
# print(q.get(1))
# print(q.get(2))
# print(q.items())
# for key,value in q.items():
#     print(key,value)
# q.pop(1)
# print(q)
# q.popitem()
# print(q)
# def print_info(a,b,c):
#     print('身高{},体重{},智商{}'.format(a,b,c))
#
# x=int(input('身高'))
# y=int(input('体重'))
# z=int(input('智商'))
# print_info(x,y,z)

# a=int(input('摄氏度:'))
# b=a*1.8+32
# print(f'华氏:{b}')

# PI=3.1415926
# radius=float(input('请输入半径:'))
# length=float(input('请输入高:'))
# area=radius*radius*PI
# volume=area*length
# print(f'底面圆半径:{area}\t体积:{length}')

# 英尺米数转换
# a=float(input('英尺:'))
# b=a*0.305
# print(f'米数为:{b}')

# 计算小费
# a=float(input('小计:'))
# b=int(input('酬金率:'))
# b=a*b*0.01
# a+=b
# print(f'小费:{b:.2f}')
# print(f'合计:{a:.2f}')

# 对一个整数中的各位数字求和
# num = int(input("请输入一个0到1000之间的整数:"))
# if num < 0 or num > 1000:
#     print("输入不合法,请重新输入一个0到1000之间的整数")
# else:
#     digit_sum = sum(int(digit) for digit in str(num))
#     print("各位数字之和为:", digit_sum)

# 计算年数和天数
# m = int(input('请输入分钟数'))
# year = (m / 1440) / 365
# day = m / 1440
# print("年数为:%.2f\n天数为%.2f" % (year, day))

# 计算能量
# def calculate_energy(M, initialTemperature, finalTemperature):
#     Q = M * (finalTemperature - initialTemperature) * 4184
#     return Q
#
#
# M = float(input('水的质量:'))
# initialTemperature = float(input('初始温度:'))
# finalTemperature = float(input('目标温度:'))
#
# energy = calculate_energy(M, initialTemperature, finalTemperature)
# print("需要的能量为:", energy, "焦耳")

# 分割数字
# num = input("请输入一个四位整数:")
# print("个位:", num[-1])
# print("十位:", num[-2])
# print("百位:", num[-3])
# print("千位:", num[-4])

# 计算三角形的面积
# import math
#
#
# def calculate_distance(x1, y1, x2, y2):
#     return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
#
#
# def calculate_area(x1, y1, x2, y2, x3, y3):
#     side1 = calculate_distance(x1, y1, x2, y2)
#     side2 = calculate_distance(x2, y2, x3, y3)
#     side3 = calculate_distance(x3, y3, x1, y1)
#
#     s = (side1 + side2 + side3) / 2
#     area = math.sqrt(s * (s - side1) * (s - side2) * (s - side3))
#
#     return round(area, 1)
#
#
# if __name__ == "__main__":
#     x1, y1, x2, y2, x3, y3 = map(float, input().split())
#     print(calculate_area(x1, y1, x2, y2, x3, y3))

# 计算三角形的三个角
# import math
#
# def main():
#     x1, y1, x2, y2, x3, y3 = map(float, input().split())
#     a = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
#     b = math.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2)
#     c = math.sqrt((x1 - x3) ** 2 + (y1 - y3) ** 2)
#
#     A = math.degrees(math.acos((a * a - b * b - c * c) / (-2 * b * c)))
#     B = math.degrees(math.acos((b * b - a * a - c * c) / (-2 * a * c)))
#     C = math.degrees(math.acos((c * c - b * b - a * a) / (-2 * a * b)))
#
#     print("{:.2f}".format(B))
#     print("{:.2f}".format(C))
#     print("{:.2f}".format(A))
#
# if __name__ == "__main__":
#     main()

# 最小数量的硬币
# def min_coins(total):
#     coins = [100, 25, 10, 5, 1]
#     count = [0, 0, 0, 0, 0,]
#     total = float(total * 100)
#
#     for i in range(len(coins)):
#         count[i], total = divmod(total, coins[i])
#
#     return count
#
# total = float(input("请输入总金额:"))
# result = min_coins(total)
# print("一元硬币个数:", result[0])
# print("两角五分硬币个数:", result[1])
# print("一角硬币个数:", result[2])
# print("五分硬币个数:", result[3])
# print("一分硬币个数:", result[4])

# 正多边形的面积
# import math
#
# def polygon_area(n, s):
#     area = (n * s ** 2) / (4 * math.tan(math.pi / n))
#     return round(area, 2)
#
# n, s = map(float, input().split())
# print(polygon_area(n, s))

# 计算身体质量指数
# weight, height = map(float, input().split())
# bmi = weight / (height ** 2)
# if bmi < 18.5:
#     print("超轻")
# elif 18.5 <= bmi < 25.0:
#     print("标准")
# elif 25.0 <= bmi < 30.0:
#     print("超重")
# else:
#     print("肥胖")

# 中彩票
# import random
# random_num = random.randint(10, 99)
# user_input = int(input("请输入一个两位数:"))
# if user_input == random_num:
#     bonus = 10000
# elif sorted(str(user_input)) == sorted(str(random_num)):
#     bonus = 3000
# elif len(set(str(user_input)) & set(str(random_num))) == 1:
#     bonus = 1000
# else:
#     bonus = 0
# print("随机产生的两位数是:", random_num)
# print("您的奖金是:", bonus, "元")

# 解一元二次方程
# import math
#
# a, b, c = map(float, input().split())
# delta = b**2 - 4*a*c
#
# if delta > 0:
#     r1 = (-b + math.sqrt(delta)) / (2*a)
#     r2 = (-b - math.sqrt(delta)) / (2*a)
#     print(round(r1, 2))
#     print(round(r2, 2))
# elif delta == 0:
#     r = -b / (2*a)
#     print(round(r, 2))
# else:
#     print("无实数解")

# 解2×2线程方程
# def solve_equations(a, b, c, d, e, f):
#     ad_bc = a * d - b * c
#     if ad_bc == 0:
#         return "无解"
#     x = (e * d - b * f) / ad_bc
#     y = (a * f - e * c) / ad_bc
#     return round(x, 1), round(y, 1)
#
# a, b, c, d, e, f = map(float, input().split())
# result = solve_equations(a, b, c, d, e, f)
# if result == "无解":
#     print(result)
# else:
#     print(result[0])
#     print(result[1])

# 未来是周几
# def future_day(day, num):
#     result = (day + num) % 7
#     return result
#
# day, num = map(int, input().split())
# print(future_day(day, num))

# 本年中的第几天
# def day_of_year(year, month, day):
#     month_days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
#     if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
#         month_days[2] = 29
#     return sum(month_days[:month]) + day
#
#
# year, month, day = map(int, input().split())
# print(day_of_year(year, month, day))

# 三角形的周长
# def is_valid(a, b, c):
#     return a + b > c and a + c > b and b + c > a
#
#
# def perimeter(a, b, c):
#     return a + b + c
#
#
# a, b, c = map(float, input().split())
# if is_valid(a, b, c):
#     print(perimeter(a, b, c))
# else:
#     print("非法")

# 一周的星期几
# def zeller_congruence(year, month, day):
#     if month < 3:
#         month += 12
#         year -= 1
#     q = day
#     m = month
#     j = year // 100
#     k = year % 100
#     h = (q + (13 * (m + 1) // 5) + k + (k // 4) + (j // 4) - 2 * j) % 7
#     return h
#
#
# year, month, day = map(int, input().split())
# weekday = zeller_congruence(year, month, day)
# if weekday == 0:
#     print('星期六')
# elif weekday == 1:
#     print('星期天')
# elif weekday == 2:
#     print('星期一')
# elif weekday == 3:
#     print('星期二')
# elif weekday == 4:
#     print('星期三')
# elif weekday == 5:
#     print('星期四')
# else:
#     print('星期五')

# 直线的交点
# def line_intersection(x1, y1, x2, y2, x3, y3, x4, y4):
#     denominator = (y2 - y1) * (x4 - x3) - (x2 - x1) * (y4 - y3)
#     if denominator == 0:
#         return "两条直线平行"
#     x = ((x1 * y2 - y1 * x2) * (x4 - x3) - (x1 - x2) * (x4 * y3 - y4 * x3)) / denominator
#     y = ((x1 * y2 - y1 * x2) * (y4 - y3) - (y1 - y2) * (x4 * y3 - y4 * x3)) / denominator
#     return round(x,2),round(y,2)
#
#
# x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
# print(line_intersection(x1, y1, x2, y2, x3, y3, x4, y4))

# 回文数
# num = int(input("请输入一个三位整数:"))
# if 100 <= num <= 999:
#     str_num = str(num)
#     if str_num == str_num[::-1]:
#         print("Yes")
#     else:
#         print("No")
# else:
#     print("输入的数字不是三位整数")

# 两个矩形
# def rectangle_relation(rect1, rect2):
#     x1, y1, w1, h1 = rect1
#     x2, y2, w2, h2 = rect2
#
#     if x1 - w1/2 <= x2 - w2/2 and y1 - h1/2 <= y2 - h2/2 and x1 + w1/2 >= x2 + w2/2 and y1 + h1/2 >= y2 + h2/2:
#         return "包含"
#     elif x2 - w2/2 <= x1 - w1/2 and y2 - h2/2 <= y1 - h1/2 and x2 + w2/2 >= x1 + w1/2 and y2 + h2/2 >= y1 + h1/2:
#         return "被包含"
#     elif x1 - w1/2 < x2 + w2/2 and x1 + w1/2 > x2 - w2/2 and y1 - h1/2 < y2 + h2/2 and y1 + h1/2 > y2 - h2/2:
#         return "重叠"
#     else:
#         return "相离"
#
#
# rect1 = list(map(float, input().split()))
# rect2 = list(map(float, input().split()))
# print(rectangle_relation(rect1, rect2))

# count=0
# for i in range(1,8):
#     for j in range(i+1,8):
#         print("({},{})".format(i,j))
#         count+=1
#     print("共有{}个组合".format(count))

# 打印数字
# print("模式A")
# count_a = 1
# while count_a <= 6:
#     for i in range(1, count_a + 1):
#         print(i, end=" ")
#         if i == count_a:
#             print()
#     count_a += 1
# print("模式B")
# count_b = 6
# while count_b >= 0:
#     for i in range(1, count_b + 1):
#         print(i, end=" ")
#         if i == count_b:
#             print()
#     count_b -= 1
# print("模式C")
# count_c = 1
# while count_c <= 6:
#     for i in range(6, 0, -1):
#         if (i <= count_c):
#             print(i, end=" ")
#         else:
#             print(" ", end=" ")
#     print()
#     count_c += 1
# print("模式D")
# count_d = 1
# while count_d <= 6:
#     for i in range(1, count_d):
#         print(" ", end=" ")
#     for i in range(1, 8 - count_d):
#         print(i, end=" ")
#     print()
#     count_d += 1

# 最大公约数
# def gys(x: int, y: int) -> int:
#     if x % y == 0:
#         return y
#     elif x % y == 1:
#         return 1
#     else:
#         return gys(y, x % y)
# 
# 
# a, b = map(int, input("请输入两个数").split())
# num = gys(a, b)
# print(num)

# 最小公倍数
# def gbs(x:int,y:int) -> int:
#     if max(x, y) % min (x, y) == 0:
#         return max(x, y)
#     else:
#         for i in range(2, max(x, y)):
#             if (min(x, y))*i % max(x,y) == 0:
#                 return min(x, y)*i
#         return  x*y    
# 
# a,b=map(int,input("请输入两个数").split())
# num=gbs(a, b)
# print(num)

# 整数的素数因子
# def isprimefactor(num):
#     prime_factor=[]
#     i=2
#     while i<=num:
#         if num%i==0:
#             prime_factor.append(i)
#             num=num//i
#         else:
#             i+=1
#     return prime_factor
# num=int(input("请输入一个正整数:"))
# factors=isprimefactor(num)
# print("素因子为:",factors)

# count=0
# for i in range(1,5):
#     for j in range(1,5):
#         for k in range(1,5):
#             if i!=j and i!=k and j!=k:
#                 print(i,j,k)
#                 count+=1
# print("共有{}个三位数字".format(count))

# 青蛙跳台阶
# def yi(n: int) -> int:
#     if n == 1 or n == 2:
#         return n
#     return yi(n - 1) + yi(n - 2)
# 
# 
# n = int(input("请输入台阶数:"))
# for i in range(1, n + 1):
#     print(yi(i))

# 二进制转十进制
# bin=input("请输入一个二进制:")
# bin_list=[int(x) for x in str(bin)[::-1]]
# dec=0
# for i in range(len(bin_list)):
#     dec+=bin_list[i]*2**i
# print("十进制:",str(dec))

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值