Python Jupyter Notebooks Quiz

Python
0 Passed
0% acceptance

A 50-question quiz covering Jupyter Notebooks, from interface basics and cell types to magic commands, kernel execution, and advanced features.

50 Questions
~100 minutes
1

Question 1

What is the primary file extension for a Jupyter Notebook?

A
.py
B
.ipynb
C
.jupyter
D
.json
2

Question 2

Which keyboard shortcut runs the current cell and advances to the next one?

A
Ctrl + Enter
B
Shift + Enter
C
Alt + Enter
D
Esc + Enter
3

Question 3

What are the two main modes in the Jupyter Notebook interface?

A
Read Mode and Write Mode
B
Command Mode and Edit Mode
C
Code Mode and Text Mode
D
Run Mode and Stop Mode
4

Question 4

How do you enter Command Mode from Edit Mode?

A
Press Enter
B
Press Esc
C
Click the Run button
D
Press Ctrl+M
5

Question 5

What does the 'Kernel' menu allow you to do?

A
Change the font size.
B
Interrupt, restart, or change the computational engine running your code.
C
Install Python packages.
D
Save the file.
6

Question 6

In a code cell, what is displayed in the `Out[ ]:` area?

javascript

x = 10
x + 5
                
A
Nothing, unless you use `print()`.
B
The result of the last expression in the cell (15).
C
All intermediate calculations.
D
The variable assignment.
7

Question 7

How do you suppress the output of the last line in a code cell?

javascript

plt.plot(data)____
                
A
Add a semicolon `;` at the end.
B
Wrap it in `silent()`.
C
Use `#` at the start.
D
It is not possible.
8

Question 8

What indicates that a code cell is currently running?

A
A green checkmark.
B
An asterisk `In [*]:`.
C
The cell turns red.
D
A loading spinner in the toolbar.
9

Question 9

Can you execute code from languages other than Python in a Jupyter Notebook?

A
No, it is Python only.
B
Yes, if you install the appropriate Kernel (e.g., R, Julia).
C
Yes, but only C++.
D
Only JavaScript.
10

Question 10

What happens to variables defined in one cell when you run a subsequent cell?

A
They are lost.
B
They are available (state persists).
C
They must be re-imported.
D
They become read-only.
11

Question 11

How do you change a cell from Code to Markdown in Command Mode?

A
Press `M`
B
Press `Y`
C
Press `C`
D
Press `T`
12

Question 12

Which syntax creates a second-level heading in a Markdown cell?

A
* Heading
B
**Heading**
C
## Heading
D
H2: Heading
13

Question 13

How do you render a mathematical equation using LaTeX syntax?

javascript

The equation is: ____
                
A
`$ E = mc^2 $`
B
{{ E = mc^2 }}
C
<math>E = mc^2</math>
D
LATEX(E = mc^2)
14

Question 14

How do you create a bulleted list in Markdown?

A
Start lines with `*` or `-`.
B
Start lines with `1.`.
C
Use `<list>` tags.
D
Use `[]`.
15

Question 15

Can you execute Python code inside a Markdown cell?

A
Yes, using `{{ code }}`.
B
No, Markdown cells are for text only.
C
Yes, using magic commands.
D
Yes, if you install an extension.
16

Question 16

What does 'Restart Kernel & Clear Output' do?

A
It saves the file and closes it.
B
It restarts the Python process (wiping all variables) and removes all cell outputs.
C
It deletes the notebook file.
D
It runs all cells from the top.
17

Question 17

If you run cells out of order (e.g., Cell 3, then Cell 1, then Cell 2), what determines the variable state?

A
The visual order of cells (top to bottom).
B
The order in which they were executed.
C
Alphabetical order.
D
Random order.
18

Question 18

How do you interrupt an infinite loop running in a cell?

A
Close the browser tab.
B
Press the 'Stop' (square) button in the toolbar or `I, I` shortcut.
C
Delete the cell.
D
Wait for it to timeout.
19

Question 19

What does the execution count number `In [5]:` represent?

A
The number of lines in the cell.
B
The 5th cell in the document.
C
The 5th cell executed since the kernel started.
D
The priority of the cell.
20

Question 20

Why might you choose to 'Restart & Run All'?

A
To make the notebook look pretty.
B
To verify that the code works linearly from start to finish without relying on hidden state or out-of-order execution.
C
To speed up execution.
D
To save memory.
21

Question 21

Which library is commonly used to display rich HTML, images, or videos directly in the notebook output?

A
IPython.display
B
sys.stdout
C
flask.render
D
html.parser
22

Question 22

How do Matplotlib plots appear in the notebook?

A
In a separate pop-up window.
B
Inline below the code cell (usually automatic or with `%matplotlib inline`).
C
They are saved to disk only.
D
As text ASCII art.
23

Question 23

Can a single cell produce multiple outputs?

A
No, only the last line is shown.
B
Yes, if you use `print()` or `display()` multiple times.
C
Only if they are images.
D
No, it errors.
24

Question 24

What happens if a cell produces a very long text output?

A
The notebook crashes.
B
The output area becomes scrollable.
C
The output is truncated.
D
It is hidden.
25

Question 25

How do you clear the output of a specific cell?

A
Delete the cell.
B
Right-click (or use Cell menu) -> Current Outputs -> Clear.
C
Restart Kernel.
D
Backspace.
26

Question 26

What is the prefix for 'line magics' that affect a single line of code?

A
%%
B
%
C
!
D
$
27

Question 27

What is the prefix for 'cell magics' that affect the entire cell?

A
%%
B
%
C
!!
D
#
28

Question 28

Which magic command measures the execution time of a line or cell?

A
%timer
B
%timeit
C
%measure
D
%clock
29

Question 29

How do you run a shell command (like `ls` or `pip install`) from a notebook cell?

javascript

____ pip install numpy
                
A
%
B
!
C
$
D
>
30

Question 30

Which magic command lists all variables currently in the global namespace?

A
%who
B
%vars
C
%ls
D
%list
31

Question 31

What does the `%%writefile filename.py` magic do?

A
It reads a file.
B
It writes the contents of the cell to a file named `filename.py`.
C
It deletes the file.
D
It runs the file.
32

Question 32

How can you inspect the documentation for a function directly in the notebook?

javascript

print____
                
A
?
B
!
C
help
D
doc
33

Question 33

What is the `%debug` magic used for?

A
It turns on verbose logging.
B
It opens an interactive debugger (pdb) at the point of the last exception.
C
It checks for syntax errors.
D
It profiles memory usage.
34

Question 34

Can you use `input()` in a notebook?

A
No, it hangs the kernel.
B
Yes, it creates an interactive text box for user input.
C
Only in terminal mode.
D
Yes, but it requires a plugin.
35

Question 35

How do you reset the namespace (delete all variables) without restarting the kernel?

A
%reset
B
%clear
C
%delete
D
%empty
36

Question 36

Which tool allows converting `.ipynb` files to HTML, PDF, or Python scripts?

A
nbconvert
B
nbformat
C
jupyter-export
D
pandoc
37

Question 37

What is `ipywidgets` used for?

A
Creating static plots.
B
Adding interactive GUI elements (sliders, buttons, dropdowns) to the notebook.
C
Exporting files.
D
Managing kernels.
38

Question 38

How do you install a library directly from a notebook cell to ensure it installs in the current kernel's environment?

A
!pip install package
B
%pip install package
C
install package
D
import package
39

Question 39

What is a 'Raw NBConvert' cell?

A
A cell that executes raw binary code.
B
A cell whose content is not formatted or executed but passed directly to `nbconvert` (e.g., for LaTeX).
C
A broken cell.
D
A cell for raw data storage.
40

Question 40

Where are notebook checkpoints (autosaves) typically stored?

A
In the `.ipynb_checkpoints` hidden folder.
B
In the `tmp` directory.
C
They are not saved.
D
In the cloud.
41

Question 41

What does the `%matplotlib notebook` magic do compared to `%matplotlib inline`?

A
It makes the plots interactive (zoomable, pannable) within the notebook.
B
It saves the plot to a file.
C
It disables plotting.
D
It makes the plot 3D.
42

Question 42

How can you hide the input code of a cell in the final exported HTML?

A
Delete the code.
B
Use cell tags (e.g., 'remove_input') and configure nbconvert.
C
Write in white font.
D
It is not possible.
43

Question 43

What is 'JupyterLab'?

A
A chemistry lab.
B
The next-generation web-based user interface for Project Jupyter.
C
A paid version of Jupyter.
D
A Python library.
44

Question 44

Can you run a Jupyter Notebook on a remote server?

A
No, it must be local.
B
Yes, by exposing the port and connecting via browser (often using SSH tunneling).
C
Only on Google Colab.
D
Only via FTP.
45

Question 45

What is the purpose of `%load filename.py`?

A
It runs the file.
B
It replaces the contents of the cell with the contents of the file.
C
It deletes the file.
D
It compiles the file.
46

Question 46

How do you create a slide deck from a notebook?

A
Take screenshots.
B
Use the 'Slide Type' cell toolbar and export as Reveal.js slides.
C
Copy paste to PowerPoint.
D
It is not supported.
47

Question 47

What is the difference between `%run script.py` and `import script`?

A
They are identical.
B
`%run` executes the script in the current namespace (like copy-pasting code); `import` creates a module namespace.
C
`import` is faster.
D
`%run` is deprecated.
48

Question 48

How do you enable line numbers in a code cell?

A
Press `L` in Command Mode.
B
Press `N`.
C
Type `%linenums`.
D
It is always on.
49

Question 49

What does the blue bar on the left of a cell indicate?

A
The cell is running.
B
The cell is selected/active.
C
The cell has an error.
D
The cell is a markdown cell.
50

Question 50

Can you use git to version control notebooks?

A
No, because they are binary.
B
Yes, but diffs are messy because of JSON structure and output data (tools like `nbdime` help).
C
Yes, it works perfectly like .py files.
D
Only if you zip them.

QUIZZES IN Python