python 10.30

python 10.30,第1张

python 10.30


文章目录
  • 第一题
  • 第二题
  • 第三题
  • 第四题
  • 第五题
  • 第六题
  • 第七题

第一题
# 第一题
kahao = int(input("请输入你的卡号:"))
sum_list_1 = []
sum_list_1.append(kahao//1000)
sum_list_1.append((kahao % 1000)//100)
sum_list_1.append((kahao % 100)//10)
sum_list_1.append(kahao%10)
for i in range(len(sum_list_1)):
    sum = sum_list_1[i] + sum
print(sum == 16)
第二题
# 第二题
for i in range(2):
    print(int(input("请输入一个整数:"))%2 != 0)

第三题
# 第三题
print(int(input("请输入一个整数:"))%7 == 0)

第四题
# 第四题
year = int(input("请输入年份:"))
print((year % 4 == 0 or year % 100 != 0) and year % 400 == 0)

第五题
# 第五题
length = int(input("请输入长度:"))
wide = int(input("请输入宽度:"))
print(f"周长是{length*2 + wide *2},面积是:{length * wide}")


第六题
# 第六题
m = 10
n = 17
# 方法一:
m, n = n, m
# 方法2
sum = m + n
n = sum - m
m = sum - n
# 方法3
sum_1 = m ^ n
m = sum_1 ^ n
n = sum_1 ^ m
# 方法四
temp = m
m = n
n = temp
第七题
# 第七题
commodoty1 = ["T恤", 245, 2]
commodoty2 = ["网球鞋", 570, 1]
commodoty3 = ["网球拍", 320, 1]
sum = commodoty1[1]*commodoty1[2] + commodoty2[1]*commodoty2[2] + commodoty3[1]*commodoty3[2]
discount = sum * 0.8
give_change = 1500 - discount
integral = (sum // 100) * 3
print("商品tt单价tt个数tt金额")
print(f"{commodoty1[0]}tt{commodoty1[1]}tt{commodoty1[2]}tt{commodoty1[1]*commodoty1[2]}")
print(f"{commodoty2[0]}t{commodoty2[1]}tt{commodoty2[2]}tt{commodoty2[1]*commodoty2[2]}")
print(f"{commodoty3[0]}t{commodoty3[1]}tt{commodoty3[2]}tt{commodoty3[1]*commodoty3[2]}")
print()
print(f"消费总金额:{sum}")
print("实际缴费:1500")
print(f"找钱:{give_change}")
print(f"本次次消费获得积分(每消费100元加3积分):{integral}。")

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4830445.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-10
下一篇 2022-11-10

发表评论

登录后才能评论

评论列表(0条)

保存