Python Quiz /30 The test begins as soon as you click the Start button. You may continue working until the time limit expires. When the time is up, your test will be submitted automatically, whether you have finished or not. Please manage your time carefully and review your answers before the deadline. When your time is up, your test will be submitted automatically, whether you have finished answering or not. Please manage your time wisely. Python Practice Quiz: 30 Logical & Coding Questions Test your Python knowledge with 30 carefully selected questions, ranging from basics to tricky logical problems. Perfect for beginners and intermediate learners. 1 / 30 What is the output? print("hello world".title()) 1. "hello world" 2. "HELLO WORLD" 3. "Hello World" 4. "Hello world" 2 / 30 Who developed Python? 1. James Gosling 2. Guido van Rossum 3. Dennis Ritchie 4. Bjarne Stroustrup 3 / 30 What is polymorphism? 1. Same function name different behaviors 2. Data encapsulation 3. Recursion 4. different function name different behaviors 4 / 30 What will be the output? a = [1, 2, 3] b = a b.append(4) print(a) 1. [1, 2, 3] 2. [1, 2, 3, 4] 3. Error 4. [4] 5 / 30 What is Python? 1. A markup language 2. A high-level programming language 3. A database 4. An operating system 6 / 30 Which of the following statements about Python are TRUE? 1. set([1,2,2,3]) == {1,2,3} 2. hash("abc") == hash("abc") within the same run 3. Python dictionaries preserve insertion order from Python 3.7+ 4. float("nan") == float("nan") returns True 7 / 30 What is the output? print({x: x**2 for x in range(3)}) 1. {1:1, 2:4, 3:9} 2. [0, 1, 4] 3. {0:0, 1:1, 2:4} 4. Error 8 / 30 Which method clears all elements from a list? 1. clear() 2. delete() 3. remove() 4. pop() 9 / 30 What will be the output? a = [] for i in range(3): a.append(lambda x: i * x) print([f(2) for f in a]) 1. [0, 2, 4] 2. [4, 4, 4] 3. [0, 0, 0] 4. [2, 4, 6] 10 / 30 How do you check if a key exists in a dictionary? 1. key in dict 2. dict.has(key) 3. dict.exist(key) 4. keyof dict 11 / 30 Which method returns sorted list without modifying original? 1. sort() 2. sorted() 3. arrange() 4. order() 12 / 30 What is the output? print(len(set([1,2,2,3,3,3]))) 1. 6 2. 5 3. 3 4. Error 13 / 30 Predict the output: print([x for x in "Python" if x in "aeiou"]) 1. ['a', 'o'] 2. ['o'] 3. [] 4. Error 14 / 30 Which function returns both index and value in a loop? 1. zip() 2. enumerate() 3. items() 4. keys() 15 / 30 Which prefix makes variable private in class? 1. $ 2. __ 3. _ 4. @@ 16 / 30 Which method returns dictionary items as pairs? 1. keys() 2. values() 3. items() 4. pairs() 17 / 30 What is a decorator in Python? 1. Modifies behavior of function 2. Deletes a function 3. Defines a new class 4. Creates variables 18 / 30 Which method removes the last element from the list? 1. delete() 2. pop() 3. remove() 4. discard() 19 / 30 What does **kwargs represent? 1. Variable positional arguments 2. Recursive arguments 3. Variable keyword arguments 4. Global arguments 20 / 30 What is the output? print(0.1 + 0.2 == 0.3) 1. True 2. False 3. Error 4. 0.3 21 / 30 What is the output of len({"a": 1, "b": 2}) 1. 1 2. 2 3. 3 4. 4 22 / 30 Predict the result: print({True: "yes", 1: "no", 0: "zero", False: "false"}) 1. {True: 'yes', 1: 'no', 0: 'zero', False: 'false'} 2. {True: 'no', 0: 'false'} 3. {1: 'no', 0: 'zero'} 4. Error 23 / 30 What does __repr__ return? 1. Memory address 2. None 3. User-friendly string 4. Developer representation 24 / 30 What is the output? def add(a, b=[]): b.append(a) return b print(add(1)) print(add(2)) 1. [1] [2] 2. [1, 2] [1, 2] 3. [1] [1, 2] 4. Error 25 / 30 Which decorator makes method belong to class not object? 1. @staticmethod 2. @property 3. @super 4. @classmethod 26 / 30 Which function checks the existence of a path? 1. os.exists() 2. os.path.exists() 3. path.exist() 4. os.check() 27 / 30 What does if __name__ == "__main__": do? 1. Defines constants 2. Runs code only when file executed directly 3. Defines classes 4. Imports file 28 / 30 Which method removes an element by value? 1. delete() 2. pop() 3. remove() 4. clear() 29 / 30 Which keyword calls parent class method? 1. parent 2. this 3. super() 4. __init__ 30 / 30 What keyword is used for exception handling? 1. catch 2. try 3. throw 4. error Your score is 0% Restart quiz