Question

In: Computer Science

In python: In many jurisdictions a small deposit is added to drink containers to encourage people...

In python:

In many jurisdictions a small deposit is added to drink containers to encourage people to recycle them. In one particular jurisdiction, drink containers holding one liter or less have a 0.10???????,??????????????????ℎ???????????ℎ??????????ℎ????0.10deposit,anddrinkcontainersholdingmorethanoneliterhavea0.25 deposit. Write a program that reads the number of containers of each size from the user as variables. Your program should continue by computing and displaying the refund that will be received for returning those containers.

Solutions

Expert Solution

#Python program that prompts user to enter two types of container bottles
#Then find the total deposit of each type of container and add to total deposit variable.
#Then print the total deposit of containers on display output. 
def main():

    #Set values for less than and more than one litre
    LESS_THAN_ONE_LITRE=0.10
    MORE_THAN_ONE_LITRE = 0.25
    #set total_deposit to 0
    total_deposit=0

    #continue reading input from user
    while True:

        #read number of containers of type1 of less than 1 litre
        type1=int(input('Enter number of containsers less than 1 litre : '))
        # read number of containers of type2 of less than 1 litre
        type2 = int(input('Enter number of containsers more than 1 litre : '))

        #check if type1 is more than 0
        if type1 >0:
            #add amount to total_deposit
            total_deposit=total_deposit+type1*LESS_THAN_ONE_LITRE
        # check if type1 is more than 0
        if type2>0:
            # add amount to total_deposit
            total_deposit = total_deposit + type2 * MORE_THAN_ONE_LITRE
        #print total_deposit on display
        print('Depsit amount :$ {0:.2f}'.format(total_deposit))

#calling main method to start the program
main()

-------------------------------------------------------------------------------------

Sample Output:

Enter number of containsers less than 1 litre : 1
Enter number of containsers more than 1 litre : 1
Depsit amount :$ 0.35
Enter number of containsers less than 1 litre : 2
Enter number of containsers more than 1 litre : 2
Depsit amount :$ 1.05


Related Solutions

This should be in Python Statement : A lot of people drink and drive. The legal...
This should be in Python Statement : A lot of people drink and drive. The legal blood alcohol level is .08%. Blood alcohol level largely depends on an individual’s BMI and the percentage and amount of whatever it is they consumed. This program could potentially help users estimate how long to wait before driving, if they must drive. Program Description This program will: Give the most recent statistics of drinking and driving in California. It will allow user to create...
Many people in the small town of Econville have complained that there is no park for...
Many people in the small town of Econville have complained that there is no park for children to use afterschool. There are 20 households in the town, 10 who have children and 10 who do not. The households with children value the park being built at $100 each while the other households value it at $20 each. The town estimates that the cost of building a park is $600. All households earn the same income. (a) Would describe the park...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
In rural Appalachia, many people live in small communities of modest-sized houses built on the narrow...
In rural Appalachia, many people live in small communities of modest-sized houses built on the narrow flood plains of streams. Surrounding these valley communities are steep, wooded mountainsides. Logging companies operate on these mountainsides. Occasionally the small streams flood, causing significant property damage in the communities. Many people who live in these rural communities believe that the activities of the logging companies on the mountains (building dirt roads and removing trees) have increased the amount of water that runs off...
Write the following Python script: Problem Statement We want to know how many different people have...
Write the following Python script: Problem Statement We want to know how many different people have eaten at a restaurant this past week. The parameter meals has strings in the format "name:restaurant" for a period of time. Sometimes a person eats at the same restaurant often. Return the number of different people who have eaten at the eating establishment specified by parameter restaurant. For example, "John Doe:Moes" shows that John Doe ate one meal at Moes. Write function howMany that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT