20 questions • Select the best answer for each question
What is the main purpose of a function in Python?
What will be the output? def greet(): print("Hello") greet()
What will happen when this code runs? def test(): x = 10 print(x)
What will be the output? x = 5 def show(): x = 10 print(x) show() print(x)
Why does a variable inside a function not affect the global one by default?
What will be the output? x = 1 def change(): global x x = 10 change() print(x)
Using global inside functions is generally discouraged because:
Which of the following is a complex number?
Which data type is IMMUTABLE?
Which of the following can be modified after creation?
What is the output? data = {"a": 1, "b": 2} print(data["b"])
What does a function return if no return statement is used?
What will this print? print(type(True))
What will be the output? nums = [1, 2, 3] nums = tuple(nums) print(type(nums))
What is the output? r = range(3) print(list(r))
What is the key difference between set and frozenset?
Which of the following represents a bytes object?
Why can the random module help explain variable behavior?
Why does misunderstanding scope cause bugs?
What is the biggest takeaway from understanding scope and data types?