Extra Practice: Python
1) What is the purpose of variables in Python?
Answer: To store and reuse values.
2) How do you join strings?
Answer: With +.
3) What is the difference between = and = =?
Answer: = assigns, = = compares.
4) What is the output of print (10//3)?
Answer: 3.
5) How do you create a function?
Answer: With the def keyword.
6) What is a loop used for?
Answer: To repeat tasks.
7) How do you stop a loop?
Answer: Using break.
8) What is the use of else with if?
Answer: Runs when the condition is false.
9) How do you add an item to a list?
Answer: Using append ().
10) What is indexing in Python?
Answer: Accessing items by position.
11) What is slicing?
Answer: Getting part of a list or string.
12) What does range (5) do?
Answer: Gives numbers 0 to 4.
13) What is the output of print (5>2)?
Answer: True.
14) How do you find the type of a value?
Answer: Using type ().
15) What is a syntax error?
Answer: A mistake in code writing.
16) What is concatenation?
Answer: Joining strings together.
17) What is a tuple?
Answer: An unchangeable list.
18) What is the difference between list and tuple?
Answer: List can change, tuple cannot.
19) What does while loop do?
Answer: Repeats while the condition is true.
20) What does import math do?
Answer: Loads math functions.