Python Fundamentals:
1. What is Python? List three key features of Python.
Answer: Python is a high-level programming language. Key features include readability, simplicity, and a large standard library.
2. Explain the concept of dynamic typing in Python.
Answer: Dynamic typing means that variable types are determined during runtime, allowing variables to change types.
3. Define automatic memory management in Python.
Answer: Automatic memory management refers to Python’s ability to allocate and de-allocate memory for variables automatically.
4. How do you write comments in Python? Provide an example.
Answer: Comments are written using the `#` symbol. Example: `# This is a comment`.
Identifiers and Keywords:
5. Question: What are identifiers in Python? Give three examples.
Answer: Identifiers are names given to variables, functions, classes, etc. Examples: `variable_name`, `functionName`, `Class123`.
6. Question: Name five keywords in Python.
Answer: `if`, `else`, `while`, `for`, `def`.
Data Types:
7. Question: List five built-in data types in Python.
Answer: Integers, floats, strings, lists, and dictionaries.
8. Question: Explain the boolean data type. Provide an example.
Answer: The boolean data type represents either `True` or `False`. Example: `is_valid = True`.
Operators:
9. Question: Differentiate between the `/` and `//` operators in Python.
Answer: `/` performs regular division, while `//` performs floor division.
10. Question: How does the `**` operator work in Python?
Answer: The `**` operator is used for exponentiation. Example: `2**3` evaluates to 8.
Variables:
11. Question: What is the purpose of variables in Python?
Answer: Variables are used to store and manipulate data.
12. Question: Explain the rules for naming variables in Python.
Answer: Variable names must start with a letter or underscore, followed by letters, digits, or underscores.
Numeric Data Types:
13. Question: Describe the integer data type. Provide an example.
Answer: Integers are whole numbers without decimal points. Example: `x = 5`.
14. Question: How is a float different from an integer?
Answer: A float is a number with a decimal point, while an integer is a whole number.
Strings:
15. Question: Define a string in Python. Give an example.
Answer: A string is a sequence of characters enclosed in single, double, or triple quotes. Example: `”Hello, world!”`.
16. Question: Explain string concatenation with an example.
Answer: String concatenation is combining strings using the `+` operator. Example: `”Hello, ” + “world!”`.
Lists and Tuples:
17. Question: What is a list in Python? Provide an example.
Answer: A list is an ordered collection of elements. Example: `my_list = [1, 2, 3]`.
18. Question: Differentiate between a list and a tuple.
Answer: A list is mutable (modifiable), while a tuple is immutable (unchangeable).
String Methods:
19. Question: How do you convert a string to uppercase using a string method?
Answer: Use the `upper()` method. Example: `”hello”.upper()` returns `”HELLO”`.
20. Question: Explain the `split()` method for strings.
Answer: The `split()` method divides a string into a list of substrings based on a specified delimiter.
List Methods:
21. Question: Describe the `append()` method for lists.
Answer: The `append()` method adds an element to the end of a list.
22. Question: How does the `remove()` method work in lists?
Answer: The `remove()` method removes the first occurrence of a specified value from a list.
Dictionary:
23. Question: What is a dictionary in Python? Provide an example.
Answer: A dictionary is an unordered collection of key-value pairs. Example: `my_dict = {“name”: “John”, “age”: 25}`.
24. Question: How do you access the value associated with a specific key in a dictionary?
Answer: Use square brackets and the key name. Example: `my_dict[“name”]` returns `”John”`.
Conditional Statements (if-else):
25. Question: Explain the purpose of the `if` statement.
Answer: The `if` statement is used for conditional execution of code based on whether a condition is true.
26. Question: What is the difference between the `if` and `else` statements?
Answer: The `if` statement executes a block of code if a condition is true, while the `else` statement provides an alternative block if the condition is false.
if-elif-else Structure:
27. Question: Define the purpose of the `if-elif-else` structure.
Answer: The `if-elif-else` structure allows you to check multiple conditions sequentially and execute the first true block of code.
28. Question: How is the `elif` statement different from the `else` statement?
Answer: `elif` is used to check additional conditions, whereas `else` provides a default block when none of the preceding conditions are true.
Looping (for and while):
29. Question: What is the role of the `for` loop in Python?
Answer: The `for` loop is used to iterate over a sequence and execute a block of code for each element.
30. Question: Differentiate between a `for` loop and a `while` loop.
Answer: A `for` loop iterates over a sequence, while a `while` loop repeats as long as a specified condition is true.
31. Question: Explain the concept of an infinite loop.
Answer: An infinite loop runs continuously without stopping, often caused by a condition that is always true.
Debugging:
32. Question: Define debugging in Python.
Answer: Debugging is the process of identifying and fixing errors (bugs) in code to ensure its proper functionality.
33. Question: How can you use the `print()` function for debugging?
Answer: You can use `print()` to display variable values and intermediate steps in the code.

