Question

Complete the following programs. Begin each program with a comment that includes: • Your name • The project/program • Brief dDrive-Rite Insurance would like to apply a 10% discount to the insurance rate for anyone who is at least 30 years old and whoIn Python.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program 1:

input code:

1 2 make function for find a bonus def program1(): take input from user unit=int(input(Enter number of Units produced:

output1:

Enter number of Units produced: 9 units is not valid. ... Program finished with exit code 0 Press ENTER to exit console. I

output2:

Enter number of Units produced:10000 This years production bonus will be $ 200 ... Program finished with exit code o Press E

code:

'''make function for find a bonus'''
def program1():
'''take input from user'''
unit=int(input("Enter number of Units produced:"))
count=0
  
'''check the validation of Units'''
if(unit<10 or unit>10000):
print("units is not valid.")
count=1
  
'''if entered value is valid than we find a bonus'''
if(count==0):
  
'''check bonus conditions'''
if(unit>=10 and unit<=1000):
bonus=25
elif(unit>1000 and unit<=3000):
bonus=50
elif(unit>3000 and unit<=6000):
bonus=100
elif(unit>6000 and unit<=10000):
bonus=200
  
print("This year's production bonus will be $",bonus)
  
'''call function'''
program1()

Program 2:

input code:

declare a constant named named=0.1 make function for find a discount 5- def program2(): take input from user rate=i

output1:

Enter current insurance rate: 500 Enter age:32 Enter the number of accidents:4, Congratulations, you are entitled to a $ 50.0

output2:

Enter current insurance rate:2900 Enter age:29 Enter the number of accidents:5, You do not qualify for a discount at this tim

code:

'''declare a constant named'''
named=0.1

'''make function for find a discount'''
def program2():
'''take input from user'''
rate=int(input("Enter current insurance rate:"))
age=int(input("Enter age:"))
accidents=int(input("Enter the number of accidents:"))
count=0
  
'''check the validation of rate,age and accidents'''
if(rate<0 or rate>3000):
print("Rate is not valid.")
count=1
elif(age<16 or age>90):
print("Age is not valid.")
count=1
elif(accidents>5 or accidents<0):
print("number of accidents is not valid.")
count=1
  
'''if entered value is valid than we find a discount'''
if(count==0):
  
'''check discount conditions'''
if(age>30 and accidents<5):
'''calculate discount'''
discount=rate*named
'''print discount'''
print("Congratulations,you are entitled to a $",discount)
print("\nThank you for Driving Safely.")
else:
'''print message'''
print("You do not qualify for a discount at this time.\n\nPlease remember to Drive Safely")

'''call function'''
program2()

Add a comment
Know the answer?
Add Answer to:
In Python. Complete the following programs. Begin each program with a comment that includes: • Your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A salesperson also receives a bonus at the end of each month, based on the following...

    A salesperson also receives a bonus at the end of each month, based on the following criteria: If the salesperson has been with the store for five years or less, the bonus is $10 for each year that he or she has worked there If the salesperson has been with the store for more than five years, the bonus is $20 for each year that he or she has worked there. The salesperson can earn an additional bonus as follows:...

  • Write a Python (3) program to simulate** a buffer overflow (this is a new script, not...

    Write a Python (3) program to simulate** a buffer overflow (this is a new script, not part of the intranet assignment), then implement input validation to prevent it. There are two parts to this assignment: 1) The program should display a welcome message and prompt the user for a username. Create a simulated buffer overflow condition by allowing a user to input more data than the size of the allocated memory (causing the program to crash). 2) Implement input validation...

  • (I would like this to be in five parts.) Write a program (Python module) that includes...

    (I would like this to be in five parts.) Write a program (Python module) that includes a function named studentrecords. This function must support execution of two loops. The first loop is to query the user whether they wish to enter additional records or not. It must accept responses of either yes or no as input, regardless of the letter-cases used for individual letters in the response. If the response is not recognized ( it isn’t yes or no) it...

  • I need help building code in python for this: Create a program that: Creates a sales...

    I need help building code in python for this: Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file...

  • In C language using printf and scanf statements: Write a program to display a histogram based...

    In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...

  • Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anythi...

    Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anything. No code outside of a function! Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...

  • *In Python please***** This program will display some statistics, a table and a histogram of a...

    *In Python please***** This program will display some statistics, a table and a histogram of a set of cities and the population of each city. You will ask the user for all of the information. Using what you learned about incremental development, consider the following approach to create your program: Prompt the user for information about the table. First, ask for the title of this data set by prompting the user for a title for data, and then output the...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • using this code to complete. it python 3.#Display Program Purpose print("The program will show how much...

    using this code to complete. it python 3.#Display Program Purpose print("The program will show how much money you will make working a job that gives a inputted percentage increase each year") #Declaration and Initialization of Variables userName = "" #Variable to hold user's name currentYear = 0 #Variable to hold current year input birthYear = 0 #Variable to hold birth year input startingSalary = 0 #Variable to hold starting salary input retirementAge = 0 #Variable to hold retirement age input...

  • Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses...

    Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program The program will reuse the DATE struct from the previous assignment.  You should also copy in the functions relating to a DATE. The program will create a PAYRECORD struct with the following fields: typedef struct...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT