and Answers Graded A+
How do you create a variable in Python?
✔✔By assigning a value to a name using the equal sign (e.g., `x = 10`).
What does the `print()` function do in Python?
✔✔It outputs text or values to the console.
How do you write a comment in Python?
✔✔By using the `#` symbol before the text (e.g., `# This is a comment`).
What is the difference between a list and a tuple in Python?
✔✔A list is mutable (can be changed), while a tuple is immutable (cannot be changed).
What does the `len()` function do in Python?
✔✔It returns the number of items in an object like a list, string, or tuple.
1
, How do you define a function in Python?
✔✔By using the `def` keyword followed by the function name and parentheses (e.g., `def
my_function():`).
What is the purpose of the `return` statement in a Python function?
✔✔It sends a value back to the caller, exiting the function.
What is an example of a Python loop?
✔✔A `for` loop can be written as `for i in range(5):`, which repeats code 5 times.
What is the difference between `==` and `=` in Python?
✔✔`==` is used for comparison to check equality, while `=` is used for assignment.
How do you create a dictionary in Python?
✔✔By using curly braces `{}` with key-value pairs (e.g., `my_dict = {'key': 'value'}`).
What does the `input()` function do in Python?
✔✔It allows the user to enter data from the keyboard during program execution.
2