Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview Be able to recognize common programming errors. Description This lab will cover both interpreter errors and logic errors. You will be given code that

image text in transcribedimage text in transcribed

Overview Be able to recognize common programming errors. Description This lab will cover both interpreter errors and logic errors. You will be given code that is not correct. Based on the comments in the code and the errors messages received when running the code, you should be able to fix the errors. Objective By the end of the program, you should be able to recognize the following types of errors: . Variable usage Bugs Identifier/ variable name Bugs String literal versus variable Bugs Arithmetic Bugs . Reminder: These are common bugs that people make when writing code. Learning how to find them and how to fix them will help you greatly in this class. It is also good practice to try to understand code you have not written. That will again make you a better coder. Extra Note About variable names: The chapter listed all the Python keywords that cannot be used as variable names. There are others that you should also never use, such as "input". Using "input" as a variable can cause drastic results and freeze your environment. Fix the bugs in the code that is given. As in last week's lab, do not immediately fix all the bugs you see. Instead, run the program first as it is given. Observe the error it is giving you. Then fix the first bug and run it again. Observe the next error message, fix it, and run it. Continue fixing the errors one at a time. Again the purpose is not to "get the right answer", it is to give you experience and practice in recognizing certain types of errors that occur when they are not introduced on purpose. main.py Load default template... 1 2 ## Fix the error in the lines below. 3 4 6 = x 5 y = input(int("Enter a number: ')) 6 x*y = y 7 print("Your number times 6 is", y) ## Hint: If x is 6 and y is 9, this should print 54. 8 ########################################################### 9 10 ## Fix the errors in the code below 11 12 1stplace = input('Who got first place? ') 13 Secondplace == "Jannet" 14 _3rdplace = "John" 15 16 print("First place was", 1stplace,"- second place was", Secondplace, "- third place was",_3rdplace.end=". ") 17 18 ## Hint: If you change a variable name/identifier make sure to change it in all places 19 ########################################################## 20 21 ## Fix the error with the code below 22 23 A = input('What message do you want to print?)' 24 print("A) 25 26 ################################ ################ 27 ## Arithmetic Expressions 28 # there are two errors in the two lines below. You need to fix both. 29 30 w = input('Enter an integer number to cube: ') 31 print(w," to the 3rd power is ", W^3) 32 33 ############################## ##################### 34 ## Arithmetic Expresssions 35 36 centimeterConstant = 2.54 37 inches = int(input('How many inches? ))) 38 39 ## Fix the error in the line below 40 print("The number of centimeters is", centimeterConstant x inches)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

What does need to change?

Answered: 1 week ago