print("Hello, Jupyter!")
Hello, Jupyter!
.exe
file in your downloads folder and double-click it to run the installer.cmd
in the Start menu.python --version
and press Enter. You should see the installed version of Python..pkg
file and double-click it to launch the installer.Command + Space
and typing “Terminal”).python3 --version
and press Enter. You should see the installed version of Python.After installing Python, it’s a good idea to install pip, Python’s package manager, which is included by default in the latest Python versions. You can use pip to install additional libraries and packages as needed.
For Windows: - To install a package, open Command Prompt and type: bash pip install package_name
For macOS: - Open Terminal and type: bash pip3 install package_name
That’s it! You’re now ready to start programming in Python.
Visual Studio Code (VSCode) is a powerful and popular code editor developed by Microsoft. It is highly extensible, lightweight, and supports a wide range of programming languages, including Python. With its robust features such as IntelliSense, debugging capabilities, and integrated terminal, VSCode is an excellent choice for Python development.
To start using Python in VSCode, follow these steps:
Install VSCode: If you haven’t already, download and install Visual Studio Code from the official website.
Install the Python Extension:
Ctrl + Shift + X
.Select the Python Interpreter:
Ctrl + Shift + P
to open the Command Palette, then type and select Python: Select Interpreter.File > New File
or pressing Ctrl + N
..py
extension (e.g., script.py
).View > Terminal
or pressing Ctrl + `
(backtick). In the terminal, type python script.py
(replacing script.py
with your file name) to execute the script.Shift + Enter
.VSCode provides powerful debugging features to help you troubleshoot your code:
Set Breakpoints: Click in the gutter next to the line numbers to set breakpoints where you want the execution to pause.
Start Debugging: Press F5
or go to the Debug view by clicking on the Debug icon in the Activity Bar.
You can then start debugging your Python script. The Debug Console will allow you to inspect variables, step through code, and evaluate expressions.
VSCode has a wide variety of extensions to enhance your Python development experience:
Linting: The Python extension includes linting capabilities that help you catch errors and enforce coding standards. You can enable it in the settings (Settings > Python > Linting
).
IntelliSense: Take advantage of IntelliSense for code suggestions, autocompletions, and quick documentation. Simply start typing, and relevant suggestions will appear.
Jupyter Notebooks: If you want to work with Jupyter Notebooks directly in VSCode, install the Jupyter extension. This allows you to create, edit, and run notebooks seamlessly.
Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text. It is widely used in data science, machine learning, and scientific computing, making it a versatile tool for both beginners and advanced users. In a Jupyter Notebook, you can write and execute code in a variety of programming languages, including Python. It provides an interactive environment where you can document your thought process alongside your code, visualize data, and quickly test ideas without the need for a complete development setup.
Once you have Jupyter Notebook up and running, you will typically start by opening a new notebook. Here are the key components and features of Jupyter Notebook to help you navigate and utilize it effectively:
Upon launching Jupyter Notebook, you’ll be greeted with a dashboard showing your files and notebooks. You can create a new notebook by selecting “New” and then choosing the desired kernel (like Python 3).
To write code in a code cell:
To execute the code, you can either click the “Run” button in the toolbar or press Shift + Enter
. This will run the code and display the output directly below the cell.
Markdown cells allow you to document your code using plain text. You can format your text using Markdown syntax.
To create a markdown cell with a header, simply type:
After running the cell, it will render as a formatted header.
You can also create bullet points, numbered lists, links, and more:
Jupyter Notebook supports various visualization libraries like Matplotlib, Seaborn, and Plotly, allowing you to create plots and graphs inline.
import matplotlib.pyplot as plt
# Sample data
x = [1, 2, 3, 4, 5]
y = [2, 3, 5, 7, 11]
# Creating a plot
plt.plot(x, y)
plt.title("Sample Plot")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()
After running this code, the plot will be displayed directly beneath the code cell.
You can save your notebook by clicking the save icon or using the shortcut Ctrl + S
(or Cmd + S
on Mac). Jupyter Notebooks are saved with a .ipynb
extension.
To share your notebook, you can export it to different formats, such as HTML or PDF, by using the “File” menu. You can also share the .ipynb
file directly, which can be opened in any Jupyter environment.
Jupyter Notebook has many handy keyboard shortcuts that can improve your efficiency. Here are a few essential ones:
Enter
: Edit the selected cell.Esc
: Command mode (no editing).A
: Insert a new cell above.B
: Insert a new cell below.DD
: Delete the selected cell.Z
: Undo the last cell deletion.Shift + Enter
: Run the current cell and move to the next one.Ctrl + Enter
: Run the current cell and stay in it.