Python programs can perform all sorts of mathematical computations and display the result. To display the addition, subtraction, multiplication, and division of two numbers, xand y, use the following code:
1 # Compute expression
>>> print((150-3.5) + (542-6))
682.5
>>> print((150-3.5) - (542-6))
-389.5
>>> print((150-3.5) * (542-6))
78524.0
>>> print((150-3.5) / (542-6))
0.2733208955223881
>>>
print(x + y)
print(x – y)
print(x * y)
print(x / y)
>>> print((150-3.5) + (542-6))
682.5
>>> print((150-3.5) - (542-6))
-389.5
>>> print((150-3.5) * (542-6))
78524.0
>>> print((150-3.5) / (542-6))
0.2733208955223881
>>>
No comments:
Post a Comment