Quiz
Quiz
Quiz
Quiz
Quiz
100

qšwefwsedhndrtjk

dsagsadfga

100

5 // 2

2

100

a = open(b, c)
d = a.read()

answers:

a.close()

close(b)

b.close()

None of the above

a.close()

100

def fn(x, y):
    z = x + y

print(fn(1, 2)) 

What will this result in?

Syntax error

12 

None

3

None

100

What is the Git operation (and command) called when you want to save a snapshot of your repository?

Commit

200

What kind of loop should a programmer usually choose when the number of iterations is known in advance (e.g. do something 10 times)?

for loop

200

Every if statement must have a corresponding else statement.

False

200

text = "Enjoy the test" 

  result = text.strip().split()[0]

What will this result in?

list

str (string)

int (integer)

A different type (not listed), but it will work.

None of the above. This code has an error and will not work.

str (string)


200

Which one of the following is the Git command to use to create a new repository?

Answers:

git new

git create

git init

git add


git init

200

def process(x, y=2, z=3):

    return x + y + z

Answers:

keyword arguments

default argument values

multiple return values

both a and b

default argument values

300

x = 10
while x > 4:
    print(x, end=" ")
    x = x - 2

Outputs of x, in order:

10 8 6

300

nums1 = [1, -5, 2, 0, 4, 2, -3]
nums2 = [1, -5, 2, 4, 4, 2, 7]
result = 0
j = 0
while j < len(nums1):
    if nums1[j] != nums2[j]:
        result = result + 1
    j = j + 1

output of j:

2

300

x = str(1.0)  
x[-1] = '2'

Answers:

NameError: name 'x' is not defined

ValueError: invalid literal for int() with base 10: '1.0'

TypeError: 'str' object does not support item assignment

IndexError: string index out of range

TypeError: 'str' object does not support item assignment

300

Which one of the following is not a state that your files can be in when using Git?

Answers:

Working directory

Checkout area

Staging area

Repository

Checkout area

300

before = [1, 4, 0, -1]
after = before.sort()
print(after[0])

Answers:

-1

0

1

None of the above

None of the above

400

result = 0
for j in range(0, len(numbers)):
    if numbers[j] < 0:
        result = result + 1

whats the purpose of this?

to add 1 to each of the negative numbers in the list

to sum the negative numbers in the list

to count the negative numbers in the list

to find the index of the first negative number in the list

to find the smallest number in the list

To count the negative numbers in the list

400

x = 5
y = 10
if x < 10:
    if y > 10 and x > 5:
        print("A")
else:
    print("B")

Answers:

The condition "y > 10 and x > 5" is invalid.

There is no else statement for the second if statement.

The indenting is incorrect. 

None of the above. There is nothing wrong with this code.

None of the above. There is nothing wrong with this code.

400

for i in range(1, 10, 4):
    print(i, i * 2, end=" ")

What is output?

5, 10

400

One great tool used in IDEs like Python is the ability to rename variables/functions/classes/etc. throughout a project, which is called ...

Refactor

400

words = ["aye", "bee", "sea", "bee"]
words.remove("bee")
print(words.pop())

output:

bee


500

x = 5
for i in range(x):  

    x = x + i  

    print(x, end=" ")

print all x outputs in order!:

5 6 8 11 15

500

try:  

    x = int("zero")  

    print(10 / x)  

except ZeroDivisionError:  

    print("div")  

except NameError:  

    print("name")  

except ValueError:  

    print("value")  

except:  

    print("other")

what will it print?

value

500

Which of the following is true about the following function header?
(Note that this is intentionally just one line of code; it is missing the body of the function.) 

def func_2():

Answers:

Something is required between the brackets

The function name is invalid

This function would take no parameters and return nothing 

None of the above

None of the above

500

To perform interactive debugging and get the IDE to stop executing your code at a certain point, you add a ______.

 Breakpoint

500

values = [1, 2, 3, 2]
values.remove(2)
print(values)

Answers:

[1, 2, 2]

[1, 3]

[1, 3, 2]

None of the above

[1, 3, 2]

M
e
n
u