Answers Graded A+
How do you concatenate two strings in Python?
✔✔ Use the `+` operator, like `'Hello' + ' World'`.
What is the result of `3 ** 2` in Python?
✔✔ The result is `9`, as `**` is the exponentiation operator.
How do you create a variable that holds a floating-point number in Python?
✔✔ Assign a decimal value to a variable, like `x = 3.14`.
What does the `input()` function do in Python?
✔✔ The `input()` function allows the user to enter data from the console.
What is the output of `print(10 % 3)`?
✔✔ The output is `1`, as `%` gives the remainder of division.
1
, How do you convert a string to an integer in Python?
✔✔ Use the `int()` function, like `int('123')`.
What is the difference between `is` and `==` in Python?
✔✔ `is` checks if two variables point to the same object in memory, while `==` checks if their
values are equal.
What is a dictionary in Python?
✔✔ A dictionary is an unordered collection of key-value pairs.
How do you access a value in a dictionary by its key?
✔✔ Use square brackets with the key, like `my_dict['key']`.
What does the `break` statement do in a loop?
✔✔ The `break` statement exits the loop prematurely.
What is a tuple in Python?
✔✔ A tuple is an immutable, ordered collection of elements.
2