User Icon

Clisto Agni

"Embrace challenges; they nurture growth."



back

Python Assessment - 3

60

Questions

21. What will be the output of the following code?

def mystery_function(n):
    if n == 0:
        return 0
    return n + mystery_function(n-1)

print(mystery_function(4))

22. What does the `enumerate()` function do in Python?

23. What is the purpose of the `zip()` function in Python?

24. How do you remove an item from a list in Python?

25. What is the output of the following code?

my_dict = {"a": 1, "b": 2, "c": 3}
result = sum(my_dict.values())
print(result)

26. How do you check if a key exists in a dictionary?

27. What does the `range()` function return?

28. How do you convert a string to uppercase in Python?

29. What will be the output of the following code?

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

30. What is the output of the following code?

my_string = "Hello World"
result = my_string.split(" ")
print(len(result))