Creating Your Own Python Project

by nusaybahali05 in Circuits > Computers

57 Views, 2 Favorites, 0 Comments

Creating Your Own Python Project

Screenshot 2024-10-16 at 2.15.43 AM.png

This is an instruction set on how to create a simple step-by-step guide on how to set up a basic Python project. This will be aimed at beginners who are new to Python programming. The guide will cover the most important steps, including installing Python, setting up a project folder, writing a basic Python script, and running it in the terminal.

Supplies

-computer

-internet connection

Install Python

Go to the Python website:

Visit the official Python website and download the latest version of Python for your operating system (Windows, macOS, or Linux).

Install Python

Run the installer:

After downloading Python, run the installer. For Windows, make sure to check the box that says "Add Python to PATH" before continuing. This step ensures you can run Python commands from the terminal.

Verify Your Python Installation

Screenshot 2024-10-07 at 1.08.56 PM.png

Open a terminal and check the version:

Once Python is installed, open a terminal (Command Prompt for Windows, Terminal for macOS/Linux) and type:

"python--version" -as seen in picture

This command should show you the installed Python version, confirming everything is set up correctly.

Create a Project Folder

Screenshot 2024-10-07 at 1.09.55 PM.png

Set up a new folder for your project:

Navigate to your file system and create a new folder. Name it something like MyFirstPythonProject. This will be the home for all your Python scripts.

Choose a Text Editor

Pick your text editor:

Open the project folder in a text editor of your choice. You can use any text editor, but popular options include:

  1. VS Code
  2. Sublime Text
  3. Notepad++

Create a Python Script

Screenshot 2024-10-07 at 1.09.39 PM.png

Write your first script:

Inside the project folder, create a new file and name it hello_world.py. Open the file and add the following code:

print ('hello world!")

Save the File

Save your script:

Once you've written the code, save the file in your project folder. Make sure the filename is hello_world.py with the .py extension.


Run Your Python Script

Screenshot 2024-10-07 at 1.09.24 PM.png
Screenshot 2024-10-16 at 2.10.56 AM.png

Navigate to the project folder in the terminal:

Open your terminal and change the directory to your project folder by typing:

"cd path/to/your/project/folder" - as seen in pic

Execute Your Script

Screenshot 2024-10-16 at 2.12.21 AM.png

Run your Python file:

With the terminal open in your project folder, type:

python hello_world.py

You should see the message "Hello, world!" displayed in the terminal.


Conclusion

You’ve now successfully set up a Python project and run your first script in just 9 simple steps. Continue exploring by writing more Python code and experimenting with different features of the language.