Introduction to Python Porgramming
Introduction to Python Programming
Comprehensive Study Notes for Secondary School Students
Compiled by Joseph Okolo, B.Sc. (Ed) Computer Science Specialist
1. What is Python?
Python is a high-level, interpreted programming language known for its simple and easy-to-read syntax. It was created by Guido van Rossum and first released in 1991.
For students, Python is the best language to start with because it reads almost like the English language. This allows you to focus on learning "Logic" rather than struggling with complicated symbols.
Why Learn Python?
- Easy to Learn: Simple syntax compared to C++ or Java.
- Versatile: Used in Web Development, Artificial Intelligence (AI), and Data Science.
- Career Demand: Python developers are some of the highest-paid in the tech industry.
How to Install and Run Python
Before you can start coding, you need to prepare your environment. Follow these steps to get Python working on your computer:
Step 1: Download & Install
- Go to the official website: Python.org.
- Download the latest version for Windows.
- Run the installer. IMPORTANT: Ensure you check the box that says "Add Python to PATH" before clicking "Install Now."
Step 2: Choosing Your Editor
There are two main ways to run your code. As a student, you can choose the one that fits your computer's speed:
Option A: Python IDLE
(Best for beginners & low battery)
- Comes installed with Python.
- Search for "IDLE" in your Start menu.
- Go to File > New File to write your script.
- Press F5 to run your code.
Option B: VS Code
(Professional & Powerful)
- Download from code.visualstudio.com.
- Install the Python Extension inside VS Code.
- Save your file with a
.pyextension. - Click the Play button at the top right to run.
3. Basic Syntax & Variables
To display information, we use the print() function. To store information, we use Variables.
name = "Ayo"
age = 15
score = 85.5
| Data Type | Description | Example |
|---|---|---|
| Integer (int) | Whole numbers | age = 15 |
| String (str) | Text data | name = "Ayo" |
| Float | Decimal numbers | score = 85.5 |
4. Taking Input from Users
Interaction is what makes a program "alive." We use the input() function to get data from the keyboard.
A. For Text (Strings)
Use this for names, colors, or messages.
print("Hello " + name + "!")
B. For Numbers (Casting)
Use int() to allow mathematical operations.
current_age = 2026 - age
print("You are", current_age, "years old.")
Comments
Post a Comment