Questions and Answers 100% Pass
What is Python primarily used for?
✔✔ General-purpose programming, including web development, data analysis, and automation.
What is the correct way to define a function in Python?
✔✔ Using the `def` keyword followed by the function name and parentheses.
How do you import a module in Python?
✔✔ Using the `import` statement followed by the module name.
What does the `len()` function do in Python?
✔✔ It returns the number of elements in an object, such as a list or string.
How are comments written in Python?
✔✔ By starting the line with a `#` symbol.
1
, What data type is used to store a collection of key-value pairs in Python?
✔✔ Dictionary.
How do you create a list in Python?
✔✔ By enclosing elements in square brackets `[]`.
What is the difference between a tuple and a list in Python?
✔✔ A tuple is immutable, while a list is mutable.
What is the output of `print(2 ** 3)` in Python?
✔✔ 8.
How can you check the type of an object in Python?
✔✔ Using the `type()` function.
What is the purpose of the `if` statement in Python?
✔✔ To execute a block of code only if a specified condition is true.
2