Skip to main content

Coding Quiz 04

Mejbah Ahammad

Python Coding Quiz

Python Coding Quiz

Answer the coding questions below by selecting all applicable options:

Time Remaining: 10:00

1. What is the output of the following code?

def calculate_total(a, b):
    return a + b

print(calculate_total(3, 4))

2. What will the following code output?

my_list = [1, 2, 3, 4]
print(my_list[-1])

3. What is the output of the following code?

x = "Hello"
y = x
y += " World"
print(x)

4. What is the output of this code snippet?

for i in range(5):
    if i == 3:
        break
    print(i)

5. What will be printed by the following code?

x = [1, 2, 3]
y = x
y.append(4)
print(x)

6. What will be the result of the following code?

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

7. What does the following code output?

my_set = {1, 2, 3}
my_set.add(2)
print(my_set)

8. What will the following code output?

x = [1, 2, 3]
y = x.copy()
y.append(4)
print(x)

9. What will the following code output?

def func(x=[]):
    x.append(1)
    print(x)

func()
func()

10. What will be the result of the following code?

x = [1, 2]
y = x
y += [3]
print(x, y)