Files
2025PY/day04/11-作业.py
2025-05-22 16:50:44 +08:00

19 lines
528 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 编写一个程序,输入两个数字 x 和 y计算并输出它们的和、差、积、商、余数。
# 输入两个数字
x = float(input("请输入第一个数字 x: "))
y = float(input("请输入第二个数字 y: "))
# 计算并输出结果
sum_result = x + y
difference = x - y
product = x * y
quotient = x / y
remainder = x % y
# 输出结果
print(f"{x} + {y} = {sum_result}")
print(f"{x} - {y} = {difference}")
print(f"{x} * {y} = {product}")
print(f"{x} / {y} = {quotient}")
print(f"{x} % {y} = {remainder}")