Write a Python script to input two numbers and find their sum and prOduct.
Answers
Answered by
18
Heya mate,
Here is your answer .
Attachments:
Answered by
1
A Python script to input two numbers and find their sum and product:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
sum = num1 + num2
product = num1 * num2
print("Sum of {} and {} is: {}".format(num1, num2, sum))
print("Product of {} and {} is: {}".format(num1, num2, product))
- In this script, the input function is used to get the two numbers as input from the user.
- The int function is used to convert the input from string to integer type.
- The sum and product of the two numbers are calculated and stored in the sum and product variables, respectively.
- Finally, the print function is used to display the results.
- The format method is used to insert the values of num1, num2, sum, and product into the string that is printed.
#SPJ3
Similar questions