Introduction To Python Basic 5 Computer Studies Lesson Note
Topic: Introduction To Python
Learning Objectives: By the end of the lesson, pupils should be able to:
- Describe the meaning of Python
- Put Python syntax to use
What is Python?
Python is a popular computer programming language that is easy to learn and use. It was created in the early 1990s by Guido van Rossum and is named after the British comedy group “Monty Python.”
Key characteristics of Python:
- Easy to read – Uses simple, English-like words
- Beginner-friendly – Great first programming language
- Powerful – Can create complex programs and applications
- Popular – Used by many companies and programmers worldwide
Uses of Python:
- Web Development
- Creating websites – Building web pages and web applications
- Web servers – Programs that serve web pages to users
- Web frameworks – Tools like Django and Flask for web development
- Examples: Instagram, Pinterest, Mozilla use Python
- Data Science and Analysis
- Analyzing data – Processing and understanding large amounts of information
- Creating charts and graphs – Visualizing data to understand patterns
- Machine learning – Teaching computers to learn from data
- Examples: Netflix uses Python to recommend movies
- Artificial Intelligence (AI)
- Smart programs – Creating programs that can think and learn
- Chatbots – Programs that can talk with people
- Image recognition – Programs that can identify objects in pictures
- Examples: Google’s AI systems use Python
- Game Development
- Simple games – Creating games like puzzles and arcade games
- Game logic – Programming how games work and respond
- Graphics – Creating visual elements in games
- Examples: Some parts of popular games use Python
- Automation
- Repetitive tasks – Making computers do boring, repetitive work
- File management – Organizing and managing computer files automatically
- Web scraping – Automatically collecting information from websites
- Examples: Automating email sending, file organization
- Education
- Teaching programming – Great language for learning programming concepts
- School projects – Students use Python for science and math projects
- Research – Universities use Python for research projects
- Examples: Many schools teach Python as first programming language
Python Syntax and Commands:
What is Syntax? Syntax refers to the rules and structure of how to write code in a programming language. Just like grammar rules in English, programming languages have syntax rules that must be followed.
Python Syntax Features:
- Indentation matters – Spaces at the beginning of lines are important
- Case sensitive – Capital and lowercase letters are different
- Uses English words – Many commands use regular English words
- Simple structure – Less complicated than many other programming languages
Basic Python Commands:
- Print Command The print() command displays text or information on the screen.
print(“Hello, World!”)
print(“My name is Python”)
print(“I am learning programming”)
Output:
Hello, World!
My name is Python
I am learning programming
- Variables Variables store information that can be used later in your program.
name = “Alice”
age = 12
favorite_color = “blue”
print(“My name is”, name)
print(“I am”, age, “years old”)
print(“My favorite color is”, favorite_color)
Output:
My name is Alice
I am 12 years old
My favorite color is blue
Simple Python Programs:
Program 1: Personal Information
# Get user information
name = input(“What is your name? “)
age = input(“How old are you? “)
school = input(“What school do you attend? “)
# Display the information
print(“\n— Your Information —“)
print(“Name:”, name)
print(“Age:”, age)
print(“School:”, school)
print(“Thank you for sharing!”)
Program 2: Simple Calculator
# Simple calculator
print(“Simple Calculator”)
num1 = float(input(“Enter first number: “))
num2 = float(input(“Enter second number: “))
print(“Addition:”, num1 + num2)
print(“Subtraction:”, num1 – num2)
print(“Multiplication:”, num1 * num2)
print(“Division:”, num1 / num2)
Program 3: Favorite Things List
# Create a list of favorite things
print(“Let’s make a list of your favorite things!”)
favorites = []
favorites.append(input(“Favorite food: “))
favorites.append(input(“Favorite color: “))
favorites.append(input(“Favorite sport: “))
favorites.append(input(“Favorite subject: “))
print(“\nYour favorite things:”)
for i, item in enumerate(favorites):
    print(f”{i+1}. {item}”)
Python Syntax Rules:
- Indentation Python uses indentation (spaces) to group code together.
if 5 > 3:
    print(“This is indented”) # 4 spaces
    print(“This is also indented”) # 4 spaces
print(“This is not indented”)Â # 0 spaces
- Case Sensitivity Python treats uppercase and lowercase letters as different.
name = “John”
Name = “Jane” # This is different from ‘name’
print(name)Â # Prints: John
print(Name)Â # Prints: Jane
- Quotation Marks Use quotation marks for text (strings).
print(“Hello”)Â # Double quotes
print(‘Hello’)Â # Single quotes (both work the same)
- Comments Use # to add comments to your code.
# This is a comment
print(“Hello”)Â # This is also a comment
Getting Started with Python:
Step 1: Install Python
- Download Python from python.org
- Install on your computer
- Open Python IDLE (Python’s built-in editor)
Step 2: Write Your First Program
- Type: print(“Hello, Python!”)
- Press Enter to run the code
- See your first Python output!
Step 3: Practice Basic Commands
- Try different print statements
- Create variables with your information
- Experiment with numbers and math
Step 4: Build Simple Programs
- Start with programs that ask for your name
- Create simple calculators
- Make lists of your favorite things
LESSON 3: INTRODUCTION TO PYTHON (Multiple Choice Questions)
- Python is: a) Only used for games b) A computer programming language c) A type of calculator d) Only for adults to use
- The print() command in Python: a) Makes paper copies b) Displays text or information on screen c) Deletes information d) Only prints numbers
- In Python, variables are used to: a) Delete information b) Store information for later use c) Only display text d) Make the computer run faster
- Python syntax refers to: a) The color of the code b) How fast the program runs c) The rules for writing Python code correctly d) The size of the program
- Which is a correct Python print statement? a) print Hello World b) print(“Hello World”) c) print[Hello World] d) print{Hello World}