Creating a JupyterLab Project

In this activity, you will create a project in JupyterLab and execute a Python hello world print statement in a Jupyter Notebook.

Background

Congratulations! You’ve been hired by a large financial investment analytics firm, and today is your first day. Your manager has asked you to test out the status of the newly installed JupyterLab environment to ensure its functionality.

In order to test that the environment is working as expected, create a project in JupyterLab and execute a Python hello world print statement in a Jupyter Notebook.

Instructions

Running Code from a Notebook

Using JupyterLab, complete the following steps:

  1. Create a folder called Jupyter-Workspace.
  2. Navigate to the Jupyter-Workspace folder.
  3. Create a Python Jupyter Notebook.
  4. Type the following line of code into a cell in the notebook and execute the code in that cell by clicking the run buttong (or ‘Shift + Enter’) print("Hello World!")
  5. Now type this in a new cell in the same notebook and execute the code in that cell by clicking the run button (or ‘Shift + Enter’) print("Hello World from a new cell")

hello_world.ipynb

# print a statement: 'Hello World!'
# print a statement: 'Hello World from a new cell'

Answer

In [1]:

# print a statement: 'Hello World!'
print('Hello World!')

Out [1]:

Hello World!

In [2]:

# print a statement: 'Hello World from a new cell'
print('Hello World from a new cell')

Out [2]:

Hello World from a new cell

Running Code from a .py file

  1. Next, using JupyterLab, create a traditional Python file with the ‘.py’ ending and name it ‘hello_world.py’
  2. In this ‘.py’ file create the same print statements as above.
  3. Make sure you are in the same directory as this file, then open a terminal window using the launcher and execute the ‘.py’ file by running: python hello_world.py

hello_world.py

# print a statement: 'Hello World!'

# print a statement: 'Hello World from a new cell'

Answer

# print a statement: 'Hello World!'
print('Hello World!')
# print a statement: 'Hello World from a new cell'
print('Hello World from a new cell')

Hint

If you need help working in the JupyterLab environment, read the documentation to learn more.

We will be happy to hear your thoughts

Leave a reply