Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Trace the code: sum = 20; numFound = 0 for ct in range(2, 17, 3): sum += ct if (ct %2 == 0) or (ct

  1. Trace the code:

sum = 20; numFound = 0 for ct in range(2, 17, 3): sum += ct if (ct %2 == 0) or (ct % 5==0): numFound +=1 print(ct, sum) print(numFound)

ct

sum

numFound

Output

20

0

  1. if age >= 21: print("Adult") if age > 12: print("Teenager")

a. Suppose the user is asked to enter a value for age, and they enter 21 What is the EXACT output? b. Correct the problems with the code.

  1. if x > 0: if y > 0: print(x,y,z, end=**) elif z > 0: if y < 0: print(x+y+z, end = **) else: print(x-y-z, end = **) print(End)

What is the output for the following input? x = 20; y = -1; z = 300 _____________________________ x = 20; y = 77; z = 300 _____________________________ x = -3; y = 77; z = 300 _____________________________

x = -3; y = -1; z = 300 _____________________________

  1. number = 0 while number < 10: number += 3 print(number, end='*')

Show the EXACT output:

  1. num = 0 for ct in range(0, 10, 4): num = num - ct*2 print(ct,num)

Show the EXACT output

6. def myFunc(x): tot = 0 for ct in range(x+1): tot += ct return tot result = myFunc(6) print (result)

1. What is the output?____________________

2. Correct the problem with the code:

7. def tripleItems(myList): for el in myList: el *= 3 scList = [11,21,31]; tripleItems(scList) print (scList)

Correct the problem with this code since the desired output is [33,63, 93] but instead, the output is [11,21,31]!

8. def someFunction(t1, t2, tot): tot = t1 + t2

return tot t1 = 100; t2 = 200; total = 0 someFunction(t1,t2,total); print(total)

Correct the problem with the code. The desired output is 300 but it does NOT produce that!

9. scores = [100, 85,60] for sc in scores: sc += 10 print(scores)

Correct the code. It is supposed to add 10 to every score.

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

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions