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...
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[])    {      ...
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...
B. Manually analyze and debug the following logic and programming code. Write in the result column,...
B. Manually analyze and debug the following logic and programming code. Write in the result column, the value of the result variable when the variables i and j have the values ​​indicated in each row of the table (6 pts.). In the event that the result cannot be calculated, state it and the reason. Option Explicit Sub Calc () Dim i As Integer, j As Integer, n As Integer Dim result As Integer i = 0 j = 0 n...
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,...
In this Java lab, you use the flowchart and pseudocode found in the figure below to...
In this Java lab, you use the flowchart and pseudocode found in the figure below to add code to a partially created Java program. When completed, college admissions officers should be able to use the Java program to determine whether to accept or reject a student, based on his or her test score and class rank. Declare the variables testScoreString and classRankString. Write the interactive input statements to retrieve: A student’s test score (testScoreString) A student's class rank (classRankString) Write...
Please debug the code and answer the questions: #include <stdio.h> typedef struct node { int value;...
Please debug the code and answer the questions: #include <stdio.h> typedef struct node { int value; struct node *next; } node; int ll_has_cycle(node *first) { node * head = first; while (head->next) { head = head->next; if (head == first) return 1; } return 0; } void test_ll_has_cycle(void) { int i,j; node nodes[5]; for(i=0; i < sizeof(nodes)/sizeof(node); i++) { nodes[i].next = NULL; nodes[i].value = i; } nodes[0].next = &nodes[1]; nodes[1].next = &nodes[2]; nodes[2].next = &nodes[1]; printf("Checking first list for cycles....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT