The __________ function immediately terminates the program.
Practice Python Libraries Questions – The __________ function immediately terminates the program.
Practice Python Libraries Questions – The __________ function immediately terminates the program.
Practice Inbuilt Functions Questions – What is round(6.5)?
Practice Strings Questions – What is “Good”.replace(“o”, “e”)?
Practice Python Basics Questions – To run python script file named t.py, use the command ________.
Practice Python Dictionary Questions – Which of the following is a Python set?
Practice Sets Programming – Given two sets s1 and s2, s1 < s2 is _________.
Practice Exception Handling – What is displayed when the following program is run?
def main():
try:
f()
print(“After the function call”)
except ZeroDivisionError:
print(“Divided by zero!”)
except:
print(“Exception”)
def f():
print(1 / 0)
main()
Practice Operators Questions – What is x after the following statements?
x = 1
y = 2
x *= y + 1
Practice Recursion Questions – Fill in the code to complete the following function for sorting a list.
def sort(lst):
_________________________ # Sort the entire list
def sortHelper(lst, low, high):
if low < high:
# Find the smallest number and its index in lst[low .. high]
indexOfMin = low
min = lst[low]
for i in range(low + 1, high + 1):
if lst[i] < min:
min = lst[i]
indexOfMin = i
# Swap the smallest in list(low .. high) with list(low)
lst[indexOfMin] = lst[low]
lst[low] = min
# Sort the remaining list(low+1 .. high)
sortHelper(lst, low + 1, high)
Practice Tuples Questions – Suppose t = (1, 2, 4, 3, 8, 9), [t[i] for i in range(0, len(t), 2)] is _________.
Practice Relational Operators – Suppose isPrime is a boolean variable, which of the following is the correct and best statement for testing if isPrime is true.
Practice Expressions Questions – The following code reads two number. Which of the following is the correct input for the code?
x, y = eval(input(“Enter two numbers: “))
Practice Operators Questions – The order of the precedence (from high to low) of the operators +, *, and, or is:
Practice while loop Questions – What will be displayed when the following code is executed?
number = 6
while number > 0:
number -= 3
print(number, end = )
Practice Tuples Questions – Suppose t = (1, 2, 4, 3), t[1 : -1] is _________.