Owen C137
Administrator
Staff
LEVEL 5
225 XP
Intro to Python – Writing Your First Program
Python is one of the most popular programming languages in the world. It’s simple to learn, beginner-friendly, and used in everything from web development to artificial intelligence.
In this tutorial, we’ll install Python, write your first program, and run it.
You should see:
Congratulations! You’ve just written and run your first Python program. This is the first step into the world of programming — keep experimenting and building new things!
Python is one of the most popular programming languages in the world. It’s simple to learn, beginner-friendly, and used in everything from web development to artificial intelligence.
In this tutorial, we’ll install Python, write your first program, and run it.
1. What is Python?
- Python is a versatile, high-level programming language.
- It’s known for its easy-to-read syntax.
- It can be used for web apps, data analysis, games, automation, and more.
2. Installing Python
- Go to the official website: Download Python.
- Choose the latest version for your operating system (Windows, Mac, or Linux).
- During installation on Windows, tick the box that says **"Add Python to PATH"**.
3. Writing Your First Python Program
Open a text editor (like Notepad, VS Code, or Sublime Text) and paste this:
Python:
print("Hello, World!")
- Save the file as hello.py (make sure the extension is `.py`).
- Open a terminal/command prompt.
- Navigate to the folder where you saved the file.
- Run:
Code:
python hello.py
You should see:
Code:
Hello, World!
4. How This Works
- print() is a built-in function that outputs text to the screen.
- Anything inside the quotation marks will be displayed.
- Every Python program starts with simple statements like this.
5. Doing More with Python
Here’s an example with variables and user input:
Python:
name = input("What is your name? ")
print("Hello, " + name + "!")
- input() asks the user for information.
- We store it in the variable `name` and then print it back.
6. Next Steps
Now that you can run Python programs:- Learn about variables, loops, and conditions.
- Experiment with simple math:
Python:
print(2 + 3)
- Check out the official Python tutorial for more.
Congratulations! You’ve just written and run your first Python program. This is the first step into the world of programming — keep experimenting and building new things!