19 lines
528 B
Python
19 lines
528 B
Python
# 编写一个程序,输入两个数字 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}")
|