Write a Python program that reads in two integers and displays the following: a.
ID: 3666660 • Letter: W
Question
Write a Python program that reads in two integers and displays the following:
a. the sum of the two numbers
b. the product of the numbers
c. the average of the two numbers
d. the minimum of the two numbers
e. the maximum of the two numbers
A sample run is shown below:
Enter first integer: 23
Enter second integer: 42
The sum of the two numbers is: 65
The product of the two numbers is: 966
The average of the two numbers is: 32.5
The minimum of the two numbers is: 23
The maximum of the two numbers is: 42
Explanation / Answer
"""program to accept two integers ,find their sum ,product,average,minimum and maximum of the two numbers"""
numberstring1=raw_input("Enter first integer : ")
number1=int(numberstring1)
numberString2=raw_input("Enter second integer: ")
number2=int(numberString2)
sum=float(number1+number2)
print "The sum of the two numbers is: " + str(sum)
product=number1*number2
print "The product of the two numbers is: " + str(product)
average=(sum/2)
print "The average of the two numbers is: " + str(average)
if(number1 > number2):
print"The minimum of two numbers is :" + str(number2)
print"The maximim of two numbers is :" + str(number1)
else:
print"The minimum of two numbers is :" + str(number1)
print"The maximum of two numbers is :" + str(number2)
output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.