2. Programming
Python Basics — Quiz
Test your understanding of python basics with 5 practice questions.
Practice Questions
Question 1
Which of the following is the correct way to define a function in Python?
Question 2
What will be the output of the following code snippet?
$\texttt{a = 5}$
$\texttt{b = 3}$
$\texttt{print(a // b)}$
$\texttt{a = 5}$
$\texttt{b = 3}$
$\texttt{print(a // b)}$
Question 3
Which of the following statements correctly describes the role of the
if statement in Python?Question 4
What is the result of the following code?
$\texttt{my_list = [1, 2, 3]}$
$\texttt{my_list.append([4, 5])}$
$\texttt{print(len(my_list))}$
$\texttt{my_list = [1, 2, 3]}$
$\texttt{my_list.append([4, 5])}$
$\texttt{print(len(my_list))}$
Question 5
Which of the following is the correct way to open a file named
data.txt for reading in Python?