Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Questions Python Code: For each line of code, write the type of error (syntax, semantics, runt-time), cause of the error, and your fix. (1)

1. Questions

Python Code: For each line of code, write the type of error (syntax, semantics, runt-time), cause of the error, and your fix.

(1) def fun(num letter)

(2) num == 7 + num

(3) return 'num' - letter

(4) result = fun(5, x)

2. Question

Python Code: Run the code below to check the outputs of the print() call on lines 12. And :

A) Analyze the application of the accumulation pattern and answer the following questions:

#1. a. What is the accumulator variable? ________________

#1. b. What's its data type? _____________

#1. c What's the purpose of it?

#2. a What's the loop variable? _____________

#2. b What's its data type? ________________

#2. c What's the purpose of it?

#3 How many iterations does the for loop have? _________

#4 Write the line(s) of code where the accumulator "accumulates" something into it ________________

#5 What gets accumulated into the accumulator? Explain in English.

B) Modify the value of labs variable such that it has the 9th element, 'lab6old'. Run the program again.

#1. What do you get? Copy and paste the output from Scratchpad in here.

#2. Explain the result.

labs = ['lab1a', 'lab1b', 'lab2', 'lab3', 'lab4a', 'lab4b', 'lab4c', 'lab5']

graded = ''

tutor_code = ''

for lab in labs:

lab_num = int(lab[3])

tutor_code = lab[3]

if len(lab) == 5:

tutor_code = tutor_code + lab[4]

graded = graded + lab + ' assigned to ' + tutor_code + ' '

elif len(lab) < 5:

graded = graded + lab + ' not assigned '

print(graded)

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions