Introduction to Python Porgramming

Introduction to Python Porgramming- Cmpnote

Introduction to Python Programming

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

  1. Go to the official website: Python.org.
  2. Download the latest version for Windows.
  3. 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 .py extension.
  • Click the Play button at the top right to run.
If you don't have a laptop yet, you can download Pydroid 3 from the Google Play Store to run these Python lessons on your Android phone!

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 in your program.

1. Common Data Types

Python automatically recognizes the type of data you put into a variable. Here are the most important ones:

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

2. Variable Naming Rules

To keep your code clean and avoid errors, follow these rules:

  • Variables must start with a letter or an underscore (_).
  • They cannot start with a number.
  • No spaces allowed (use student_name instead of student name).
  • Variables are case-sensitive (age and Age are different).
# Example of creating variables
website = "Cmpnote.blogspot.com"
earnings = 15.50
is_active = True

print(type(website)) # This tells you the data type

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.

name = input("What is your name? ")
print("Hello " + name + "!")

B. For Numbers (Casting)

Use int() to allow mathematical operations.

age = int(input("Enter birth year: "))
current_age = 2026 - age
print("You are", current_age, "years old.")

๐Ÿ“ Test Your Knowledge

1. Who created Python in 1991?

2. Which command displays text on the screen?

3. To do math with a user's input, you must use:

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