Question: my python close runs in pycharm and python idle but when run in windows debug / python after putting in the number of traffic violations

my python close runs in pycharm and python idle but when run in windows debug/python after putting in the number of traffic violations it closes the program instead of showing the output. my code: "def get_customer_info():
# This function gets the customer's name, age, and number of traffic violations.
# It validates the input and returns the values.
name = input("Enter the customer's name: ")
while True:
try:
age = int(input("Enter the customer's age: "))
if age <16 or age >105:
print("Drivers must be between 16 and 105 years of age.")
else:
break
except ValueError:
print("Invalid input. Please enter a valid age.")
while True:
try:
violations = int(input("Enter the number of traffic violations: "))
if violations <0:
print("Violations may not be less than 0.")
else:
break
except ValueError:
print("Invalid input. Please enter a valid number of violations.")
return name, age, violations
def calculate_risk_code(violations):
# This function calculates the risk code based on the number of traffic violations.
if violations >=4:
return 1
elif violations ==3 or violations ==2:
return 2
elif violations ==1:
return 3
else:
return 4
def calculate_insurance_quote(age, risk_code, violations):
# This function calculates the insurance quote based on the customer's age and risk code.
if age <25:
if risk_code ==1:
return 480.00
elif risk_code ==2 and violations ==3:
return 450.00
elif risk_code ==2 and violations ==2:
return 405.00
elif risk_code ==3:
return 380.00
else:
return 325.00
else:
if risk_code ==1:
return 410.00
elif risk_code ==2 and violations ==3:
return 390.00
elif risk_code ==2 and violations ==2:
return 365.00
elif risk_code ==3:
return 315.00
else:
return 275.00
def display_quote(name, risk_code, quote):
# This function displays the insurance quote to the customer.
risk_types ={1: "High", 2: "Moderate", 3: "Low", 4: "No"}
print(f"{name}, as a {risk_types[risk_code]} risk driver, your insurance will cost ${quote:.2f}.")
# Main program
name, age, violations = get_customer_info()
risk_code = calculate_risk_code(violations)
quote = calculate_insurance_quote(age, risk_code, violations)
display_quote(name, risk_code, quote)"

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 Programming Questions!