Answered step by step
Verified Expert Solution
Question
1 Approved Answer
## Question 1 : debugging ( 9 marks ) , The following code is supposed to print out the Fibonacci sequence up to
## Question : debugging marks
"The following code is supposed to print out the Fibonacci sequence up to the number of terms specified by the user.
"For example, if the user enters the output should be:
"Fibonacci sequence of terms:
"However, the program contains a number of errors. Your task is to fix the code until it works correctly.
"For each error that you find in the program, add a comment to explain the error."
"celltype": "code",
"executioncount": null,
id: eac
"metadata":
"outputs":
"source":
"numterms inputEnter the number of terms:
t
t
"counter # counter for checking when to stop
if numterms
printNo terms number is not positive
"else:
while counter numterms:
printFibonacci sequence of numterms, terms:
if counter numterms : # the last term
printt
else:
printt end
nextterm t t
# update values
t t
t nextterm"
"celltype": "markdown",
id: b
"metadata":
"source":
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started