Question

In: Computer Science

Into to PythonInstructions: • In this lab you are to debug the code found at...

Into to Python

Instructions: • In this lab you are to debug the code found at the end of these instructions: Find and correct all problems found in the code. Create comments in the code explaining what you found and how you corrected it • The purpose of this program is to calculate car insurance rates using the following rules: The base rate of insurance is $50 a month, Males pay a 25% premium over the base rate, Drivers in Michigan and Florida pay a 10% premium over the base rate, and Individuals under the age of 21 or over the 70 pay a 5% premium over the base rate

Grading: 2 – General, compiles, comments, proper indentation, etc 4

– Problem 1 found and corrected 4

– Problem 2 found and corrected 4

– Problem 3 found and corrected 4

– Problem 4 found and corrected

Source Code:

# Lab 3.2 #

BASE_RATE = 50

print('Car Insurance Rate Estimator/n')

age = int(input('Enter your current age: '))

sex = input('Enter your sex: ')

state = input('Enter your state of residence: ')

cost = BASE_RATE

if(sex = 'M'):

cost = BASE_RATE + (BASE_RATE * .25)

if(state == 'MI' or state == 'FL'):

cost = BASE_RATE + (BASE_RATE * .25)  

if(age < 21 or age > 70):

cost = BASE_RATE + (BASE_RATE * .25)

print('\nYou are a', age, 'year old ' + sex, 'and you live in ' + stateOfResidence)

print('Your insurance will cost $', format(cost, '.2f'), sep='')

Solutions

Expert Solution

#---------------------------------------

BASE_RATE = 50

print('Car Insurance Rate Estimator/n')

age = int(input('Enter your current age: '))

sex = input('Enter your sex: ')

state = input('Enter your state of residence: ')

cost = BASE_RATE

# assignment operator was used instead of comparison

if (sex == 'M'):

    cost = BASE_RATE + (BASE_RATE * .25)

if (state == 'MI' or state == 'FL'):

    #corrected the fraction and the formula

    cost = cost + (BASE_RATE * .1)

if (age < 21 or age > 70):

    #corrected the fraction and the formula

    cost = cost + (BASE_RATE * .05)

#wrong variable name used, corrected it

print('\nYou are a', age, 'year old ' + sex, 'and you live in ' + state)

print('Your insurance will cost $', format(cost, '.2f'), sep='')

#-----------------------------------------------


Related Solutions

20.14 Program BinarySearch Objectives Examine a binary search algorithm Debug existing code Instructions For this lab...
20.14 Program BinarySearch Objectives Examine a binary search algorithm Debug existing code Instructions For this lab you will code directly in ZyBooks. That means no uploading a file. If you wish, you can copy the template code into your IDE, work out a solution, and paste that into the code window. The problem The code does not work on certain data sets. Fix the sets but do not alter the binary search algorithm. The obvious Yes, this is a problem...
please debug this code by fixing all the mistakes. thank you. // Creates a HomeworkAssignment class...
please debug this code by fixing all the mistakes. thank you. // Creates a HomeworkAssignment class // instantiates two objects // and prompts the user for infromation about two courses using System; public class DebugSeven1 {     public static void Main()     {         HomeworkAssignment course1;         HomeworkAssignment course2;         string entryString;         int exercises;         // Get info for first class         Console.Write("What class do you have homework for? ");         entryString = Console.ReadLine(); // Fixed .ReadLine         course1.ClassName...
There is error in this java code. Pls debug. // Prompt user for value to start...
There is error in this java code. Pls debug. // Prompt user for value to start // Value must be between 1 and 20 inclusive // At command line, count down to blastoff // With a brief pause between each displayed value import java.util.*; public class DebugSix3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String userNumString; int userNum, val; final int MIN = 1; final int MAX = 20; System.out.println("Enter a number between " +...
//those who say that "whether the student wants to understand or debug the code, IT IS...
//those who say that "whether the student wants to understand or debug the code, IT IS IN THE COMMENTS, it says solve and that is all that is given for the code and no other instructions it says //SOLVE // the code already works you just have to finish the void functions that are given and run it and see if it works or not are those in the main are the test cases to test whether they work or...
I am given this starter code and I am suppose to debug it and all of...
I am given this starter code and I am suppose to debug it and all of that and it will not work after I change ">" to "<=" and then i'm not sure after that what else I have to do. Could someone help me solve this? // Start with a penny // double it every day // how much do you have in a 30-day month? public class DebugSix1 {    public static void main(String args[])    {      ...
Looking for code to this stepping stone lab 6 Prompt: In Stepping Stone Lab Five, you...
Looking for code to this stepping stone lab 6 Prompt: In Stepping Stone Lab Five, you created a Recipe Class. Now, in Stepping Stone Lab Six, you will focus your skills on developing your own driver class including custom methods to access elements of the Ingredient and Recipe classes. Specifically, you will need to create the following:  The instance variables for the class (listOfRecipes)  Accessors and mutators for the instance variable  Constructors  Three custom methods: printAllRecipeDetails(),...
code for the Intel x86 architecture (IA-32). Code solution using (AL_Template_Irvine32.asm) located at the bottom. Debug...
code for the Intel x86 architecture (IA-32). Code solution using (AL_Template_Irvine32.asm) located at the bottom. Debug your programs with VS2017/19. Must have all commands for the program to execute and have single line or block comments explaining the purpose or functionality of your code statements. Make sure It assembles without errors or warnings. Program – College Party Calculator: Write a program that calculates the profit amount after students pay expenses for a college party. Prompt the user for each student...
a java code In this lab you will implement an inorder traversal, and a search for...
a java code In this lab you will implement an inorder traversal, and a search for a 2-3-4 tree. The inorder traversal will print the contents (integers) of the tree, and the search method will return a boolean, indicating whether a given key was found in the tree. Examine the provided template. The main method is provided for you, as well as a template of the Node and 2-3-4 classes. The main method will read either "inorder" or an integer...
In the week 2 lab, you found the mean and the standard deviation for the HEIGHT...
In the week 2 lab, you found the mean and the standard deviation for the HEIGHT variable for both males and females. Use those values for follow these directions to calculate the numbers again. (From week 2 lab: Calculate descriptive statistics for the variable Height by Gender. Click on Insert and then Pivot Table. Click in the top box and select all the data (including labels) from Height through Gender. Also click on “new worksheet” and then OK. On the...
In a comparative Anatomy lab, you found some bones and the jaws are toothed and that...
In a comparative Anatomy lab, you found some bones and the jaws are toothed and that the anterior limbs are modified for flight. Determine whether this tetrapod is related phylogenetically to the subclass Archosauria of the Reptilia, to either the subclass Archaeornithes or the Neornithes of the Aves or to the subclass Eutheria of the Mammalia. Describe those aspects of the fossil which allows you to make your determination. IN OTHER WORDS, WHICH OF THE ABOVE ANIMALS POSSESS THE FEATURE,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT