Write a program: input wo integers, calculate the difference ofsquares..
时间: 2024-02-17 18:01:01 浏览: 64
This program is to get the numbers of different characters
Sure, here's a Python program that takes two integers as input from the user, and calculates the difference of their squares:
```python
x = int(input("Enter the first integer: "))
y = int(input("Enter the second integer: "))
diff_of_squares = x ** 2 - y ** 2
print("The difference of squares is:", diff_of_squares)
```
In this program, we first prompt the user to enter two integers, `x` and `y`. We then calculate the difference of their squares using the formula:
- Difference of squares = x^2 - y^2
Finally, we print out the result to the user.
Note that we use the `**` operator to calculate the square of each integer. This operator raises a number to a power, so `x ** 2` means `x` raised to the power of 2 (i.e., `x` squared).
阅读全文