Introduction to Python Porgramming

Introduction to Python Programming - Cmpnote

Introduction to Python Programming

Compiled by Joseph Okolo, B.Sc. (Ed) Computer Science Specialist

1. What is Python?

Python is a high-level, general-purpose, and 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:

Step 1: Download & Install

  1. Go to the official website: Python.org.
  2. Download the latest version for your Operating System.
  3. Run the installer. CRITICAL: Ensure you check the box that says "Add Python to PATH" before clicking "Install Now." If you miss this, your computer won't recognize Python commands!

Step 2: Choosing Your Editor

Option A: Python IDLE

(Best for beginners & older computers)

  • Comes installed with Python automatically.
  • 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 & Feature-rich)

  • Download from code.visualstudio.com.
  • Install the Python Extension (by Microsoft) inside VS Code.
  • Save your file with a .py extension.
  • Click the Play button at the top right to run.

Variables and Data Types

In Python, a Variable is like a container used to store data values. Think of it as a labeled box where you keep information so you can use it later.

1. Common Data Types

Type Meaning Example
String (str) Text or characters (must use quotes) name = "Cmpnote"
Integer (int) Whole numbers (no decimals) score = 90
Float Decimal numbers price = 15.50
Boolean (bool) True or False values is_on = True

2. Variable Naming Rules

  • Must start with a letter or an underscore (_).
  • Cannot start with a number.
  • No spaces allowed (use user_age, not user age).
  • Avoid using Python "Keywords" (like print or if) as names.

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)

By default, input() always treats data as text.

name = input("Enter name: ")
print("Hello " + name)

B. For Numbers (Casting)

Wrap input() in int() to do math!

year = int(input("Birth year: "))
age = 2026 - year
print("Age:", age)

⚠️ Pro-Tip: Case Sensitivity

Python is case-sensitive! This means print() works, but Print() or PRINT() will cause an error. Always pay attention to your capital letters.

๐Ÿ“ Test Your Knowledge

1. Who created Python in 1991?

2. Which of these is a correct variable name?

3. Why do we use int(input()) instead of just input() for math?

4. What data type is a whole number like 25?

Support Cmpnote: GTB 0229727053 | Joseph Okolo

© 2026 cmpnote.blogspot.com

Comments

Popular posts from this blog

Complete Computer Studies/ICT Curriculum for JSS 1 to SSS 3

90 Objective Examination Questions in Major Subjects

JSS 3 Objective Questions and Answers in Computer studies