Quiz 2. CSCI 115. Programming Fundamentals

(6 pts., -1 each incorrect) Suppose we have the list type variables x and declared as below:

OnPaste.20200916-233018
What are the boolean values of the following expressions, True or False? Choose the correct answer by picking 'True' or 'False' column.
True
False

x != y

x[2] > y[2]

x[1] >= y[1]

x > y or 3 in x

bool(x)

bool(x[1]-4)

(5 pts) Convert the following for-loop code into an equivalent while-loop.
OnPaste.20200916-232150
(4 pts., -1 each incorrect) What are the estimated values of the variables s1, s2, and s3 after executing the following code shown on the left? Write the individual outputs in the “Output” column below.

OnPaste.20200916-232537

Answer
S1
S2
S3
C1
(10 pts) Given a list of integer values A. Please, write a code for finding and printing a list of elements inside the given list A that divide both 5 and 3. For example, if A = [4,5,2,10,15,30], your program should copy values of 15 and 30 that divide both 5 and 3 into another list B and then printing that list B = [15, 30].
 
Input: [4,5,2,10,15,30]
Expected output: [15, 30]
(3 pts.) What are the estimated values of the variables s1, s2, and s3 after executing the following code shown on the left? Write the individual outputs in the “Output” column below.

OnPaste.20200916-232555

Answer

s1

S2
S3

(6 pts.) Suppose we have three individual variables declared as below:

OnPaste.20200916-232433

What are the outputs of the following code? Write the output in the second column.

>>>y[2][0][3]
>>>z.get ('2F')
>>>x.append (55); print (x)
X.insert (2,13);print (x)
X.remove (3); print (x)
Del (x[0:2]); print (x)
{"name":"Quiz 2. CSCI 115. Programming Fundamentals", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"(6 pts., -1 each incorrect) Suppose we have the list type variables x and y declared as below: What are the boolean values of the following expressions, True or False? Choose the correct answer by picking 'True' or 'False' column., @page { margin: 0.79in } p { margin-bottom: 0.1in; direction: ltr; line-height: 120%; text-align: left; orphans: 2; widows: 2 } x != y","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker