Quiz Home
Python_b_quiz1 Quiz
1: What will be the output of the following Python code snippet?

def hello_world():
    print("Hello, world!")

hello_world()


  Hello, world!
  None
  Nothing
  Error



2: What is the output of the code above?

x = 10
y = 5
print(x + y)

  15
  10
  5
  105



3: What does this code print?

if 5 > 2:
    print("Five is greater than two!")

  Five is greater than two!
  True
  False
  Nothing



4: What is the value of y when it is printed?

x = 4
y = x + 2
x = 2
print(y)

  4
  6
  2
  8



5: What is the output of the code snippet?
list = [1, 2, 3, 4]
print(list[2])

  1
  2
  3
  4



6: What are the values printed by this loop?
for i in range(3):
    print(i)

  0 1 2
  1 2 3
  0 1 2 3
  1 2



7: What happens when this code is executed?
x = 5
y = 'Hello'
print(x + y)

  Prints '5Hello'
  Adds 5 and 'Hello' together
  Throws an error
  Prints 'Hello5'



8: What is the output of the code?
def multiply(a, b):
    return a * b

result = multiply(3, 4)
print(result)

  12
  7
  34
  Error



9: What values are printed by this code?
x = 10
def print_x():
    x = 5
    print(x)

print_x()
print(x)

  5 10
  10 5
  5 5
  10 10



10: What is the final value of x printed by this code?
x = ['apple', 'banana', 'cherry']
x.append('orange')
print(x)

  ['apple', 'banana', 'cherry']
  ['apple', 'banana', 'cherry', 'orange']
  ['banana', 'cherry', 'orange']
  ['orange', 'apple', 'banana', 'cherry']