Python Forum
If statements and multiplication
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If statements and multiplication
#2
If you understood the problem well enough to explain it well you probably wouldn't have the problem in the first place. The catch-22 of programming is you don't know enough to know what it is that you don't know.

Think about the order of your comparisons. If a number is greater than 250 it is also greater than 100. If you first check if it is greater than 100, that test is going to succeed.

The exit() function is not meant to compensate for the programmer not knowing how to write an if statement. Read up on the if statement (if, elif, else) and you will see exit() is not needed for your program.

This is repeated multiple times to make up much of of the code in your program:
    bulk_discount=(round(float(amount_of_cable)*0.80,2))
    print(bulk_discount)
    input("prompt")
If you buy a lot of cable or very little the equation does not change. It is always bulk_discount = quantity * discount. The only difference between different incarnations is the discount number (0.8, 0.7, 0.5). You should limit your if statement to only setting the "discount" and then printing the bulk discount after the if statement. Your program should be about a dozen lines long.
Reply


Messages In This Thread
If statements and multiplication - by elroberto - Jun-22-2022, 10:32 AM
RE: If statements and multiplication - by deanhystad - Jun-22-2022, 05:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Find the maximum multiplication ercv 3 2,166 Nov-30-2020, 11:55 AM
Last Post: DeaD_EyE
  Multiplication Table Homework mcnhscc39 6 4,630 Nov-25-2018, 04:01 PM
Last Post: mcnhscc39
  creating a 3x3 multiplication table aditvaddi 1 3,626 Jun-18-2018, 06:05 AM
Last Post: volcano63
  Multiplication Table funnybone04 4 5,796 Apr-08-2018, 03:03 AM
Last Post: nilamo
  Nested Loop multiplication table SushiRolz 3 10,251 Feb-28-2018, 04:34 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020