Question: Write a program that prompts the user for two integers and then prints The sum The difference The product The average The distance (absolute value

Write a program that prompts the user for two integers and then prints

The sum

The difference

The product

The average

The distance (absolute value of the difference)

The maximum (the larger of the two)

The minimum (the smaller of the two)

hint: python defines max and min functions that accept a sequence of values, each separated with a comma.

Code:

a=int(input('Enter first number :')) #value of a taken from user b=int(input('Enter second number :')) #value of b taken from user add=a+b; difference=a-b; product=a*b; distance=difference #(absolute value of the difference) if(a>b): maximum=a; minimum=b; elif(a

print("The sum is %d "%add); print("The Difference is %d "%difference); print("The Product is %d "%product); print("The Distance is %d "%distance); print("The Maximum Number is %d "%maximum); print("The Minimum Number is %d "%minimum);

output:

Enter first number :15 Enter second number :5 The sum is :20 The Difference is :10 The Product is :75 The Distance is :10 The Maximum Number is :15 The Minimum Number is :5

1. enhance the output of exercise above so that the numbers are properly aligned. ( look at the code above, the code is only for question 1, the rest of the questions are independent)

sum: 45

difference: -5

product: 500

average: 22.50

distance: 5

maximun: 25

minimum: 20

2. write a program that displays the olympic rings. color urge rings in the olympic colors. the olympic colors are blue, black, red, yellow and green.

3. the following pseudocode describes how a bookstore computes the price of an order from the total price and the number of the books that were ordered.

- read the total book price and the number of books

- compute the tax (7.5 percent of the total book price)

- compute the shipping charge ($2 per book)

- the price of the order is the sum of the total book price, the tax and the shipping charge

- print the price of the order

( translate this pseudocode into a python program)

(ALL PROGRAMS MUST BE WRITTEN IN PYTHON! Java or C++ will not be accepted)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!