NEW
Font size
WorksheetsPython Programming-Quizz
Total questions: 12
Worksheet time: 6mins
What is the main difference between a list and a tuple in Python?
Lists are immutable; tuples are mutable
Lists are mutable; tuples are immutable
Lists can contain numbers only; tuples can contain strings only
Lists are slower than tuples
What will be the output of the following code?
x = 10 y = 3 print(x // y, x % y)
3 1
3 0
3.33 1
3 3
How do you create a lambda function to calculate the square of a number n?
square = lambda n: n + n
square = lambda n: n * n
square(n) = n ** 2
def square(n): return n * n
Which Python function is used to read a file line by line?
read()
readline()
write()
openfile()
How do you extract "Python" from the string "I love Python programming" using slicing?
s[7:13]
s[7:12]
s[8:13]
s[7:14]
Which regex pattern matches exactly 3 digits anywhere in a string?
\d{2}
\d{3}
[0-9]{2}
[0-9]{4}
Which block is executed whether or not an exception occurs?
try
except
finally
raise
How do you start a thread to run a function print_numbers() in Python?
t = Thread(target=print_numbers); t.start()
t = threading.Thread(print_numbers)
Thread.run(print_numbers)
thread.start(print_numbers)
How do you create a NumPy array of integers from 1 to 10?
np.array(1,2,3,...10)
np.arange(1,11)
np.linspace(1,10)
np.list(1,10)
Which function reads a CSV file into a pandas DataFrame?
pd.DataFrame("sales.csv")
pd.read_csv("sales.csv")
pd.readfile("sales.csv")
pd.csv("sales.csv")
Which Tkinter widget is used to accept text input from a user?
Label
Entry
Button
Text Area
In PyGame What is Sprite?
Sound Effect
Moving object in a game
type of collision
game level
