2. In many jurisdictions a small deposit is added to containers to encourage people to recycle them. In one particular jurisdiction, containers holding one litre or less have a $0.10 deposit, and containers holding more than one litre have a $0.25 deposit. Write a Python script that reads the number of containers of each size from the user. The script should compute and display the refund that will be received for returning those containers. Format the output so that it includes a dollar sign and displays exactly two decimal places.

Respuesta :

Answer:

Here is the Python program:

small_container = int(input("Enter the number of small containers you recycled?"))

large_container = int(input("Enter the number of large containers you recycled?"))

refund = (small_container * 0.10) + (large_container * 0.25)

print("The total refund for returning the containers is $" + "{0:.2f}".format(float(refund)))

Explanation:

The program first prompts the user to enter the number of small containers. The input value is stored in an integer type variable small_container. The input is basically an integer value.

The program then prompts the user to enter the number of large containers. The input value is stored in an integer type variable large_container. The input is basically an integer value.

refund = (small_container * 0.10) + (large_container * 0.25)  This statement computers the refund that will be recieved for returning the small and larger containers. The small containers holding one litre or less have a $0.10 deposit so the number of small containers is multiplied by 0.10. The large containers holding more than one litre have a $0.25 deposit so the number of large containers is multiplied by 0.25. Now both of these calculated deposits of containers of each side are added to return the refund that will be received for returning these containers. This whole computation is stored in refund variable.

print("The total refund for returning the containers is $" + "{0:.2f}".format(float(refund))) This print statement displays the refund in the format given in the question. The output includes a $ sign and displays exactly two decimal places by using {0:.2f} where .2f means 2 decimal places after the decimal point. Then the output is represented in floating point number using. format(float) is used to specify the output type as float to display a floating point refund value up to 2 decimal places.

Ver imagen mahamnasir
fichoh

The required code which calculates the amount of refund made by returning the containers written in python 3 goes thus :

small_size = eval(input('Enter number of 1L or less containers to be returned: '))

#prompts user to enter the number of small sized containers to be returned

big_size = eval(input('Enter number of containers greater than 1L to be returned: '))

#prompts user to enter the number of big size containers to be returned

small_refund = (small_size * 0.10)

#calculates the total refund on small sized containers

big_refund = (big_size * 0.25)

# calculates the total refund on big size containers

total_refund = float((small_refund + big_refund))

#calculates the Cummulative total refund

print('Your total refund is

+ '{0:.2f}'.format(total_refund))

#displays the total refund rounded to 2 decimal places.

Learn more :https://brainly.com/question/14353514

Ver imagen fichoh