Python Basic LeveladminNovember 21, 2026Uncategorized 1. Which keyword is used to define a function in Python? def function define func 2. Which of the following is a valid Python variable name? class 2value my-value my_value 3. Which dictionary method returns a value for a key without raising an error if the key is missing? value() fetch() find() get() 4. Which keyword is used to handle exceptions? except finally error catch 5. Which function is used to get input from a user? scan() get() read() input() 6. Which statement is used to make a decision in Python? import def for if 7. Which keyword skips the current loop iteration and moves to the next one? skip pass continue break 8. Which method adds one item to the end of a list? append() extend_one() insert_end() add() 9. Which string method converts text to lowercase? small() tolower() lower() casefolding() 10. Which data type stores True or False values? int list str bool 11. Which statement imports Python’s math module? include math load(math) using math import math 12. What is the index of the first character in a Python string? 1 0 -1 It has no index 13. Which symbol is used for a single-line comment in Python? // — /* # 14. What does the range(5) function produce when used in a loop? 0 to 4 0 to 5 1 to 4 1 to 5 15. Which built-in function returns the number of items in a list? size() len() total() count() 16. How do you create a tuple containing the values 1, 2 and 3? [1, 2, 3] (1, 2, 3) {1, 2, 3} 17. Which data structure stores key-value pairs? list tuple dictionary set 18. Which loop is commonly used to iterate over a sequence? loop repeat for foreach 19. Which collection is ordered and changeable? list frozenset tuple set 20. Which operator is used for exponentiation in Python? % // ^ ** 21. Which keyword exits a loop immediately? break continue exit stop 22. What is the purpose of the return statement in a function? To send a value back to the caller To print a value automatically To import a module To repeat the function 23. What is the result of 17 // 5? 3 4 3.4 2 24. Which block is used to wrap code that may raise an exception? error check try safe Loading … Question 1 of 24