Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please help debugging this code!!! Overview Be able to recognize common programming errors. Description This lab will cover both interpreter errors and logic errors. You

Please help debugging this code!!!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 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. LAB ACTIVITY 16.8.1: LAB 4 D: Code Debugging 0/25 ACTIVITY 16.8.1: LAB 4 D: Code Debugging 0/25 main.py main.py Load default template... Load defaut template . 2 ## Fix the error in the line below 36 = x 4 y = int(input('Enter a number: ')) 5 ## Fix the error in the line below 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 ########################################################### 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 ## Hint: If you change a variable name/identifier make sure to change it in all places 19 20 ## Fix the error with the code below 21 22 A - input('What message do you want to print? ') 23 print("A") 24 25 ######################################################### 26 ## Arithmetic Expresssions 27 W = int(input('Enter number to cube: ' 28 ## Fix the error in the line below 29 print(w," to the 3rd power is ", w3) 30 ##########################***#**##***###**####****#***## 31 ## Arithmetic Expresssions 32 centimeterConstant = 2.54 33 inches = int(input('How many inches? ' 34 ## Fix the error in the line below 35 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 with AI-Powered 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

Students also viewed these Databases questions