0% found this document useful (0 votes)
23 views4 pages

Python QA Bold Questions

The document provides a comprehensive overview of Python programming concepts, including syntax, variable naming, data types, functions, loops, and control statements. It highlights key features such as readability, common applications, and built-in functions. Additionally, it addresses specific keywords and operators used in Python, along with examples and explanations of their usage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

Python QA Bold Questions

The document provides a comprehensive overview of Python programming concepts, including syntax, variable naming, data types, functions, loops, and control statements. It highlights key features such as readability, common applications, and built-in functions. Additionally, it addresses specific keywords and operators used in Python, along with examples and explanations of their usage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1. What is a key feature of Python that makes it easy to debug code?

Answer: Its readable and clear syntax.

2. Name three common applications of Python.

Answer: Web development, data analysis, and automation.

3. Provide an example of a valid Python variable name.

Answer: `user_name`

4. What is an identifier in Python?

Answer: The name used to identify variables, functions, classes, modules, or objects.

5. Which keyword in Python cannot be used as an identifier?

Answer: `class`

6. What is the correct syntax to add a comment in Python?

Answer: Use the hash symbol `#` followed by the comment.

7. Name one Python keyword used for looping.

Answer: `for`

8. Provide an example of a Python literal.

Answer: `42` (an integer literal)

9. Which function is used to convert data types in Python?

Answer: `int()`, `float()`, `str()`, etc.

10. What type does the expression type(3.14) return?

Answer: `<class 'float'>`

11. Which symbol is used for exponentiation in Python?

Answer: `**`

12. What is the correct order of operations in Python expressions?

Answer: Parentheses > Exponentiation > Multiplication/Division > Addition/Subtraction (PEMDAS)

13. What is the purpose of the print() function in Python?

Answer: To display output to the console.


14. How do you define a function in Python?

Answer: Using the `def` keyword, e.g., `def my_function():`

15. How do you call a function named my_function in Python?

Answer: Use `my_function()`

16. What does 'call by reference' mean in Python?

Answer: It means functions receive references to the objects passed, not copies.

17. Which type of argument is mandatory in a Python function?

Answer: Positional arguments.

18. Which argument type assigns a default value in Python?

Answer: Default arguments.

19. Which argument type allows you to pass unlimited arguments to a function?

Answer: `*args` or `**kwargs`

20. Name a built-in Python function used to display output.

Answer: `print()`

21. Which keyword is used for decision-making in Python?

Answer: `if`

22. What is the purpose of the else statement in Python?

Answer: To execute a block of code if the condition in `if` is false.

23. Which loop structure is best suited for iterating a fixed number of times?

Answer: `for` loop.

24. Which loop executes as long as a condition is true?

Answer: `while` loop.

25. Which Python statement is used to exit a loop immediately?

Answer: `break`

26. Which Python statement skips the remaining code in a loop iteration?

Answer: `continue`
27. What is the purpose of the pass statement in Python?

Answer: To act as a placeholder where code is syntactically required but not needed yet.

28. What is a nested loop in Python?

Answer: A loop inside another loop.

29. What happens if the else block is used with a for loop that completes normally?

Answer: The `else` block is executed.

30. What happens if the else block is used with a while loop that exits normally?

Answer: The `else` block is executed.

31. What will print(type("Hello")) display in Python?

Answer: `<class 'str'>`

32. What is the result of the expression 3+2 2 in Python?

Answer: SyntaxError (missing operator between `2` and `2`)

33. Name one mutable data type in Python.

Answer: List (`list`) is mutable.

34. What is the result of the expression 5//2 in Python?

Answer: `2` (floor division)

35. Which operator is used to check equality in Python?

Answer: `==`

36. Which keyword is used to define a function in Python?

Answer: `def`

37. Which of the following is not a valid Python data type: dict, set, array, or tuple?

Answer: `array` (not a core built-in type without importing `array` module)

38. What is the result of not True in Python?

Answer: `False`

39. Which keyword is used to import a module in Python?

Answer: `import`
40. Which operator is used to concatenate strings in Python?

Answer: `+`

You might also like