Bird
Raised Fist0
Data Analysis Pythondata~20 mins

Jupyter Notebook setup and usage in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Jupyter Notebook Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Output of a Jupyter Notebook cell with variable assignment and print
What is the output shown in the notebook cell after running this code?
Data Analysis Python
x = 10
print(x * 2)
x
A
10
20
B
20
10
C
20
20
D
10
10
Attempts:
2 left
💡 Hint
Remember that print outputs to the cell output, and the last expression's value is also shown.
❓ data_output
intermediate
2:00remaining
DataFrame display in Jupyter Notebook
What will be the displayed output of this Jupyter Notebook cell?
Data Analysis Python
import pandas as pd
df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
df
AA table with columns A and B, rows 0 and 1, values [[1,3],[2,4]]
B{'A': [1, 2], 'B': [3, 4]}
CA list of tuples: [(1,3), (2,4)]
DA printed string: ' A B\n0 1 3\n1 2 4'
Attempts:
2 left
💡 Hint
In Jupyter, returning a DataFrame displays it as a table.
🧠 Conceptual
advanced
2:00remaining
Kernel behavior in Jupyter Notebook
What happens when you restart the kernel in a Jupyter Notebook?
AThe notebook saves automatically and continues running without interruption.
BOnly variables are cleared; imports remain available.
CThe notebook interface closes and reopens automatically.
DAll variables and imports are cleared; you must rerun cells to restore state.
Attempts:
2 left
💡 Hint
Think about what a kernel controls in Jupyter Notebook.
🔧 Debug
advanced
2:00remaining
Identify the error in Jupyter Notebook cell execution order
You run these cells in order: Cell 1: a = 5; Cell 2: print(b); Cell 3: b = 10 What error occurs and why?
Data Analysis Python
Cell 1:
a = 5

Cell 2:
print(b)

Cell 3:
b = 10
ASyntaxError in Cell 2 due to missing variable declaration.
BNo error; output is 10.
CNameError in Cell 2 because b is not defined before print.
DTypeError in Cell 2 because b is not an integer.
Attempts:
2 left
💡 Hint
Variables must be defined before use in the same kernel session.
🚀 Application
expert
2:00remaining
Using magic commands to time code execution in Jupyter Notebook
Which option correctly uses a Jupyter magic command to time how long a single line of code takes to run?
Data Analysis Python
import time

# Code to time: time.sleep(1)
A%time time.sleep(1)
B%%time time.sleep(1)
C%timing time.sleep(1)
D%%timing time.sleep(1)
Attempts:
2 left
💡 Hint
Single line timing uses %time, cell timing uses %%time.

Practice

(1/5)
1. What is the main purpose of using a Jupyter Notebook in data science?
easy
A. To compile large software projects
B. To write and run code step-by-step with explanations
C. To create websites with HTML and CSS
D. To manage databases and run SQL queries

Solution

  1. Step 1: Understand Jupyter Notebook's role

    Jupyter Notebook allows running code in small pieces, making it easy to test and explain.
  2. Step 2: Compare with other options

    Options A, B, and D describe other tools or tasks not related to Jupyter Notebook's main use.
  3. Final Answer:

    To write and run code step-by-step with explanations -> Option B
  4. Quick Check:

    Jupyter Notebook = step-by-step code and explanations [OK]
Hint: Remember: Jupyter mixes code and notes for easy learning [OK]
Common Mistakes:
  • Confusing Jupyter with web development tools
  • Thinking Jupyter compiles code like an IDE
  • Assuming Jupyter manages databases directly
2. Which of the following is the correct way to start a Jupyter Notebook from the command line?
easy
A. jupyter notebook
B. start notebook
C. run jupyter
D. open notebook

Solution

  1. Step 1: Recall the command to launch Jupyter

    The official command to start Jupyter Notebook is jupyter notebook.
  2. Step 2: Check other options

    Options B, C, and D are not valid commands and will cause errors.
  3. Final Answer:

    jupyter notebook -> Option A
  4. Quick Check:

    Start Jupyter with 'jupyter notebook' command [OK]
Hint: Use 'jupyter notebook' exactly to launch [OK]
Common Mistakes:
  • Typing incomplete or incorrect commands
  • Using 'run' or 'open' instead of 'jupyter notebook'
  • Confusing with other software commands
3. Consider this Jupyter Notebook cell code:
for i in range(3):
    print(i)

What will be the output when you run this cell?
medium
A. Error: Indentation required
B. 0 1 2
C. [0, 1, 2]
D. 0 1 2

Solution

  1. Step 1: Understand the loop and print behavior

    The loop runs for i = 0, 1, 2. Each print outputs i on a new line.
  2. Step 2: Determine output format

    Print statements in Python output each value on a separate line, so output is '0\n1\n2'.
  3. Final Answer:

    0\n1\n2 -> Option D
  4. Quick Check:

    Print in loop outputs each value on new line [OK]
Hint: Remember print adds a new line after each call [OK]
Common Mistakes:
  • Thinking print outputs values on the same line
  • Confusing list output with print output
  • Assuming syntax error due to indentation
4. You run this code in a Jupyter Notebook cell:
for i in range(3)
    print(i)

What is the error and how do you fix it?
medium
A. SyntaxError: Missing colon after for loop; add ':' after range(3)
B. IndentationError: Indent print less
C. NameError: 'i' is not defined
D. No error; code runs fine

Solution

  1. Step 1: Identify syntax error in for loop

    The for loop is missing a colon ':' at the end of the line, which is required in Python.
  2. Step 2: Fix the syntax by adding colon

    Adding ':' after range(3) fixes the syntax and allows the code to run.
  3. Final Answer:

    SyntaxError: Missing colon after for loop; add ':' after range(3) -> Option A
  4. Quick Check:

    For loops need ':' at end [OK]
Hint: Always put ':' after for loops and if statements [OK]
Common Mistakes:
  • Forgetting colon at end of for loop
  • Misunderstanding indentation errors
  • Assuming variable 'i' is undefined
5. You want to share your Jupyter Notebook with a friend who does not have Python installed. Which option lets your friend view your notebook easily?
hard
A. Print the notebook and mail the paper copy
B. Send the .ipynb file and ask them to install Python
C. Export the notebook as HTML and send the file
D. Convert notebook to .exe file and send

Solution

  1. Step 1: Understand sharing options for Jupyter Notebooks

    Exporting as HTML creates a file that can be opened in any web browser without Python.
  2. Step 2: Evaluate other options

    A is impractical for interactive content, B requires Python installation, C is not a standard conversion.
  3. Final Answer:

    Export the notebook as HTML and send the file -> Option C
  4. Quick Check:

    HTML export = easy sharing without Python [OK]
Hint: Export as HTML to share without Python installed [OK]
Common Mistakes:
  • Assuming .ipynb files open without Python
  • Trying to convert notebook to executable
  • Ignoring interactive features by printing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard