Explore our extensive collection of questions and answers to enhance your learning experience and prepare for exams effectively
None is False in a boolean context, so ‘False’ is printed.
The return keyword sends a value back from a function, e.g., return x + y.
The def keyword defines a function, e.g., def my_function():.
add(3, 4) returns 7, as the function adds the arguments and prints the result.
len() counts the number of items in a list, e.g., len([1, 2, 3]) is 3.
range(3) produces [0, 1, 2], a sequence starting at 0 up to but not including 3.
range(1, 4) iterates over 1, 2, 3, printing each on a new line.
elif handles additional conditions in an if-elif-else structure.
The while loop prints 0, 1, 2 as i increments from 0 to 2.
The for loop is ideal for iterating over sequences like lists or ranges.