Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python I need the solution

Hello, @Sree Chandini.

It would be appreciated if you could post your code into a formatted block. You can learn how to do this here: https://codeforum.org/threads/how-to-post-your-code-into-threads.183/ - this makes your code able to be read, copied, and it means we don't need to deal with downloading/uploading files.

Along with that, could you also please explain what the code does and what you're trying to achieve? Or is there another problem that we don't know about(e.g. you cannot run the program, there are missing components, etc.)?

Thank you.
 
I can't write this all for you because it's a pretty large assignment, but I do have an existing project that has everything you need - Multiple choice questions...

Or here is my Python IPIP BFFM code:

Either one of these should point you in the right direction for building your Python script.

Also here is a Python script I made for taking answers from someone (a customer service rep uses this script to determine the price for a customer) and providing pricing information (with scaling discounts, etc). This is probably the most similar to what you need to do, but obviously there will be quite a bit of work involved no matter which example of mine you use:
Python:
wizard_active = "true"
while(wizard_active == "true"):
    print("Welcome to the Aura Pricing Wizard, by Wubur LLC")
    print("Just follow these prompts...\n")
    print("Hello, this is *NAME* with *COMPANY*, How can I help you today?\n")
    print("Select an option from below by typing in the corresponding number (1-5)")

    category = "false"
    while(category == "false"):
        try:
            service = int(input(" 1: Air Duct Cleaning \n 2: Carpet Cleaning \n 3: Remodeling \n 4: Water Damage \n 5: Mold Remediation\nType your answer and press Enter!\n"))
            category = "true"
        except ValueError:
            print("You must enter a valid number (integer)!")
            category = "false"

    if(service == 1):
        ac_units = "false"
        while(ac_units == "false"):
            try:
                ac_units = int(input("\nASK: How many AC units do you have?\nEnter a number and press Enter!\n"))
            except ValueError:
                print("You must enter a valid number (integer)!")
                ac_units = "false"

        num_years = "false"
        while(num_years == "false"):
            try:
                num_years = int(input("\nASK: When was the last time your system was cleaned?\nEnter a number (of years - Type 1 for anything under 1 year) and press Enter!\n"))
            except:
                print("You must enter a valid number (integer)!")
                num_years = "false"

        dirty_level = "false"
        while(dirty_level == "false"):
            try:
                print("\nASK: How dirty are your air ducts / overall HVAC system?\nEnter a rating based on the customer's answer!")
                dirty_level = int(input(" 1: Very Clean \n 2: No Visible Dust \n 3: Average \n 4: Very Dirty \n 5: Extremely Dirty\n\nType in a number between 1 and 5, and press Enter!\n"))

            except:
                print("You must enter a valid number (integer)!")
                dirty_level = "false"

        if(num_years >= 10):
            min_duct_cleaning = 169 # basic air duct cleaning
            mid_duct_cleaning = 239 # duct cleaning & vent cover cleaning
            max_duct_cleaning = 439 # full system cleaning    
        elif(num_years >= 6):
            min_duct_cleaning = 129 # basic air duct cleaning
            mid_duct_cleaning = 199 # duct cleaning & vent cover cleaning
            max_duct_cleaning = 399 # full system cleaning
        elif(num_years >= 3):
            min_duct_cleaning = 99 # basic air duct cleaning
            mid_duct_cleaning = 179 # duct cleaning & vent cover cleaning
            max_duct_cleaning = 379 # full system cleaning
        else:
            min_duct_cleaning = 89 # basic air duct cleaning
            mid_duct_cleaning = 169 # duct cleaning & vent cover cleaning
            max_duct_cleaning = 359 # full system cleaning

        if(dirty_level >= 4):
            min_duct_cleaning = min_duct_cleaning + (7*dirty_level) # basic air duct cleaning
            mid_duct_cleaning = mid_duct_cleaning + (5*dirty_level) # duct cleaning & vent cover cleaning
            max_duct_cleaning = max_duct_cleaning + (3*dirty_level) # full system cleaning
        elif(dirty_level <= 2):
            min_duct_cleaning = min_duct_cleaning - ((5-dirty_level)*5) # basic air duct cleaning
            mid_duct_cleaning = mid_duct_cleaning - ((5-dirty_level)*7) # duct cleaning & vent cover cleaning
            max_duct_cleaning = max_duct_cleaning - ((5-dirty_level)*9) # full system cleaning
           

        if(ac_units <= 2 and dirty_level <= 3):
            discount = 20
        elif(ac_units == 3 and dirty_level <= 3):
            discount = 15
        elif(ac_units > 3 and dirty_level <= 3):
            discount = 10
        elif(ac_units <= 2 and dirty_level > 3):
            discount = 15
        elif(ac_units == 3 and dirty_level > 3):
            discount = 10
        elif(ac_units > 3 and dirty_level > 3):
            discount = 5
        else:
            discount = 0
           
        min_duct_cleaning_discount = (min_duct_cleaning * ac_units) * ((100 - discount)/100)
        mid_duct_cleaning_discount = (mid_duct_cleaning * ac_units) * ((100 - discount)/100)
        max_duct_cleaning_discount = (max_duct_cleaning * ac_units) * ((100 - discount)/100)

        if((min_duct_cleaning_discount / ac_units) < 87):
            if(ac_units >= 4):
                min_duct_cleaning_discount = 83 * ac_units
            elif(ac_units == 3):
                min_duct_cleaning_discount = 85 * ac_units
            else:
                min_duct_cleaning_discount = 87 * ac_units

        if((mid_duct_cleaning_discount / ac_units) < 149):
            if(ac_units >= 4):
                mid_duct_cleaning_discount = 129 * ac_units
            elif(ac_units == 3):
                mid_duct_cleaning_discount = 139 * ac_units
            else:
                mid_duct_cleaning_discount = 149 * ac_units


        if((max_duct_cleaning_discount / ac_units) < 329):
            if(ac_units >= 4):
                max_duct_cleaning_discount = 319 * ac_units
            elif(ac_units == 3):
                max_duct_cleaning_discount = 339 * ac_units
            else:
                max_duct_cleaning_discount = 329 * ac_units

       

        print("\nPresent the customer with the following options:")
        print("Basic Air Duct Cleaning (Brush + Vacuum): $" + str(min_duct_cleaning_discount) + " (" + str(ac_units) + " AC Units) (Discount Applied: " + str(discount) + "%)")
        print("Air Duct + Vent Cover Cleaning: $" + str(mid_duct_cleaning_discount) + " (" + str(ac_units) + " AC Units) (Discount Applied: " + str(discount) + "%)")
        print("Full HVAC System Cleaning: $" + str(max_duct_cleaning_discount) + " (" + str(ac_units) + " AC Units) (Discount Applied: " + str(discount) + "%)")


        input("\nPress ANY key and then press Enter to view max discounts, but only if the customer refuses to schedule an appointment and will be lost!\n")
        print("min duct is " + str(min_duct_cleaning_discount) + " and math *.20 is: " + str(min_duct_cleaning_discount*.2) + " with 50*ac="+str(50*ac_units))
        if((min_duct_cleaning_discount * 0.20) <= (50*ac_units) and (((min_duct_cleaning_discount*0.8)/ac_units) >= 87)):
            min_duct_cleaning_discount = min_duct_cleaning_discount * 0.8
            new_min_discount = 20
        elif((min_duct_cleaning_discount * 0.15) <= (50*ac_units) and ((min_duct_cleaning_discount*0.85)/ac_units) > 87):
            min_duct_cleaning_discount = min_duct_cleaning_discount * 0.85
            new_min_discount = 15
        elif((min_duct_cleaning_discount * 0.1) <= (50*ac_units) and ((min_duct_cleaning_discount*0.9)/ac_units) > 87):
            min_duct_cleaning_discount = min_duct_cleaning_discount * 0.9
            new_min_discount = 10
        elif((min_duct_cleaning_discount * 0.05) <= (50*ac_units) and ((min_duct_cleaning_discount*0.95)/ac_units) > 87):
            min_duct_cleaning_discount = min_duct_cleaning_discount * 0.95
            new_min_discount = 5
        else:
            min_duct_cleaning_discount = min_duct_cleaning_discount
            new_min_discount = 0

        print(str((min_duct_cleaning_discount * 0.20)) + " is the discount*.20 and ac unit price is: " + str((min_duct_cleaning_discount*0.8)/ac_units))

        if((mid_duct_cleaning_discount * 0.20) <= (50*ac_units) and ((mid_duct_cleaning_discount*0.8)/ac_units) >= 165):
            mid_duct_cleaning_discount = mid_duct_cleaning_discount * 0.8
            new_mid_discount = 20
        elif((mid_duct_cleaning_discount * 0.15) <= (50*ac_units) and ((mid_duct_cleaning_discount*0.85)/ac_units) >= 165):
            mid_duct_cleaning_discount = mid_duct_cleaning_discount * 0.85
            new_mid_discount = 15
        elif((mid_duct_cleaning_discount * 0.1) <= (50*ac_units) and ((mid_duct_cleaning_discount*0.9)/ac_units) >= 165):
            mid_duct_cleaning_discount = mid_duct_cleaning_discount * 0.9
            new_mid_discount = 10
        elif((mid_duct_cleaning_discount * 0.05) <= (50*ac_units) and ((mid_duct_cleaning_discount*0.05)/ac_units) >= 165):
            mid_duct_cleaning_discount = mid_duct_cleaning_discount * 0.95
            new_mid_discount = 5
        else:
            mid_duct_cleaning_discount = mid_duct_cleaning_discount
            new_mid_discount = 0

        if((max_duct_cleaning_discount * 0.20) <= (50*ac_units) and ((max_duct_cleaning_discount*0.8)/ac_units) >= 359):
            max_duct_cleaning_discount = max_duct_cleaning_discount * 0.8
            new_max_discount = 20
        elif((max_duct_cleaning_discount * 0.15) <= (50*ac_units) and ((max_duct_cleaning_discount*0.85)/ac_units) >= 359):
            max_duct_cleaning_discount = max_duct_cleaning_discount * 0.85
            new_max_discount = 15
        elif((max_duct_cleaning_discount * 0.1) <= (50*ac_units) and ((max_duct_cleaning_discount*0.9)/ac_units) >= 359):
            max_duct_cleaning_discount = max_duct_cleaning_discount * 0.9
            new_max_discount = 10
        elif((max_duct_cleaning_discount * 0.05) <= (50*ac_units) and ((max_duct_cleaning_discount*0.05)/ac_units) >= 359):
            max_duct_cleaning_discount = max_duct_cleaning_discount * 0.95
            new_max_discount = 5
        else:
            max_duct_cleaning_discount = max_duct_cleaning_discount
            new_max_discount = 0

        print("\nPresent the customer with these FINAL price options:")
        print("Basic Air Duct Cleaning (Brush + Vacuum): $" + str(min_duct_cleaning_discount) + " (" + str(ac_units) + " AC Units) (Discount Applied: " + str(new_min_discount) + "%)")
        print("Air Duct + Vent Cover Cleaning: $" + str(mid_duct_cleaning_discount) + " (" + str(ac_units) + " AC Units) (Discount Applied: " + str(new_mid_discount) + "%)")
        print("Full HVAC System Cleaning: $" + str(max_duct_cleaning_discount) + " (" + str(ac_units) + " AC Units) (Discount Applied: " + str(new_max_discount) + "%)")

        print("\nPlease Note: It is possible for the customer to already be at their maximum discount!")

    elif(service == 2):
        print("\nTELL CUSTOMER: Great, we offer very competitive pricing for steam cleaning and affordable options for any needed stain treatments.")
        small_rooms = "false"
        while(small_rooms == "false"):
            try:
                small_rooms = int(input("\nASK: How many small rooms need to be steam cleaned?\n(Under 200 sq ft, small bedrooms, offices, etc)\n"))
            except ValueError:
                print("You must enter a Number (Integer) of small rooms (0+)!")

        large_rooms = "false"
        while(large_rooms == "false"):
            try:
                large_rooms = int(input("\nASK: How many large rooms need to be steam cleaned?\n(200+ sq ft, living rooms, master bedrooms, etc)\n"))
            except ValueError:
                print("You must enter a Number (Integer) of large rooms (0+)!")


        closets = "false"
        while(closets == "false"):
            try:
                closets = int(input("\nASK: How many closets in these rooms need to be steam cleaned?\n"))
            except ValueError:
                print("You must enter a Number (Integer) of closets (0+) that must be cleaned!")

        stairs = "false"
        while(stairs == "false"):
            try:
                stairs = int(input("\nASK: How many staircases need to be steam cleaned?\n"))
            except ValueError:
                print("You must enter a Number (Integer) of staircases (0+) that must be cleaned!")

        small_spot_stains = "false"
        while(small_spot_stains == "false"):
            try:
                small_spot_stains = int(input("\nASK: How many small or light stains need to be cleaned and treated?\n"))
            except ValueError:
                print("You must enter a Number (Integer) of small spot stains (0+) that must be cleaned!")

        large_spot_stains = "false"
        while(large_spot_stains == "false"):
            try:
                large_spot_stains = int(input("\nASK: How many large or deep stains need to be cleaned and treated?\n"))
            except ValueError:
                print("You must enter a Number (Integer) of large spot stains (0+) that must be cleaned!")

        small_room_cost = small_rooms * 35
        large_room_cost = large_rooms * 70
        closet_cost = closets * 15
        stairs_cost = stairs * 25
        small_stains_cost = small_spot_stains * 15
        large_stains_cost = large_spot_stains * 25
        total_cost = small_room_cost + large_room_cost + closet_cost + stairs_cost + small_stains_cost + large_stains_cost
        if(total_cost <= 89):
            total_cost = 89

        print("\nPresent the customer with the following pricing options:")
        print("TOTAL COST: $" + str(total_cost))
        print("   "+str(small_rooms)+" Small Rooms: $"+ str(small_room_cost))
        print("   "+str(large_rooms)+" Large Rooms: $"+ str(large_room_cost))
        print("   "+str(closets)+" Closets: $"+ str(closet_cost))
        print("   "+str(stairs)+" Stairs: $"+ str(stairs_cost))
        print("   "+str(small_spot_stains)+" Small Stains: $"+ str(small_stains_cost))
        print("   "+str(large_spot_stains)+" Large Stains: $"+ str(large_stains_cost))

        input("\nPress ENTER to view discounted pricing, if the customer will not schedule an appointment.\n")
        print("\nPresent the customer with the following pricing options:")
        small_room_cost = small_rooms * 30
        large_room_cost = large_rooms * 60
        closet_cost = closets * 10
        stairs_cost = stairs * 20
        small_stains_cost = small_spot_stains * 10
        large_stains_cost = large_spot_stains * 20
        total_cost = small_room_cost + large_room_cost + closet_cost + stairs_cost + small_stains_cost + large_stains_cost
        if(total_cost <= 89):
            total_cost = 89

        print("\nPresent the customer with the FINAL discounted pricing options:")
        print("TOTAL COST: $" + str(total_cost))
        print("   "+str(small_rooms)+" Small Rooms: $"+ str(small_room_cost))
        print("   "+str(large_rooms)+" Large Rooms: $"+ str(large_room_cost))
        print("   "+str(closets)+" Closets: $"+ str(closet_cost))
        print("   "+str(stairs)+" Stairs: $"+ str(stairs_cost))
        print("   "+str(small_spot_stains)+" Small Stains: $"+ str(small_stains_cost))
        print("   "+str(large_spot_stains)+" Large Stains: $"+ str(large_stains_cost))
       

       
    wizard_continue = input("\nType 'Q' and Press ENTER to close the pricing wizard.\nPress ANY other key to start the price wizard again!\n")
    if(wizard_continue == "q" or wizard_continue == "Q"):
        wizard_active = "false"

Just curious though - What is this for? This Python challenge looks like it's from a school, but there's no way they would start you on this without teaching you basic Python first. Are you trying this on your own, or is this for a class?
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom