Suppose d = {“john”:40, “peter”:45}, the keys are __________
Practice Python Dictionary Questions – Suppose d = {“john”:40, “peter”:45}, the keys are __________
Practice Python Dictionary Questions – Suppose d = {“john”:40, “peter”:45}, the keys are __________
Practice Lists programming – What will be displayed by the following code?
myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
if myList[i] > max:
max = myList[i]
indexOfMax = i
print(indexOfMax)
Practice Relational Operators – What will be displayed by the following code?
isCorrect = False
print(“Correct” if isCorrect else “Incorrect”)
Practice Exception Handling – What is displayed when the following program is run?
try:
list = 10 * [0]
x = list[9]
print(“Done”)
except IndexError:
print(“Index out of bound”)
else:
print(“Nothing is wrong”)
finally:
print(“Finally we are here”)
Practice Tkinter Questions – To display a warning dialog named “Variable is assigned, but not used”, use __________
Practice for loop Questions – What is the number of iterations in the following loop:
for i in range(1, n + 1):
# iteration
Practice Functions Programming – __________ is to implement one function in the structure chart at a time from the top to the bottom.
Practice Tkinter Questions – To create a label under parent window, use _______.
Practice Input-output Questions – Suppose x is 345.3546, what is format(x, “10.3f”)? (note b represents a blank space)
Practice File Operations Questions – To read the entire remaining contents of the file as a string from a file object infile, use _________.
Practice Lists programming – What will be displayed by the following code?
list1 = [1, 3]
list2 = list1
list1[0] = 4
print(list2)
Practice Input-output Questions – If you enter 1 2 3 in three separate lines, when you run this program, what will be displayed?
print(“Enter three numbers: “)
number1 = eval(input())
number2 = eval(input())
number3 = eval(input())
# Compute average
average = (number1 + number2 + number3) / 3
# Display result
print(average)
Practice Operators Questions – Which of the following statements are the same?
(A) x -= x + 4
(B) x = x + 4 – x
(C) x = x – (x + 4)
Practice Logical Operators Questions – Given |x – 2| >= 4, Which of the following is true?
Practice Expressions Questions – The “less than or equal to” comparison operator is __________.