Introduction to Python
Programming: Class Notes
Compiled on June 19, 2025 at 21:56 AEST
These notes provide a concise introduction to Python
programming for beginners, covering variables, loops, and
functions. Designed for students in introductory computer
science courses or self-learners.
Author: Anonymous Educator
Contents
1 Introduction 2
2 Variables and Data Types 2
3 Loops 2
3.1 For Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.2 While Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4 Functions 3
5 Conclusion 3
1
1 Introduction
These class notes introduce fundamental Python programming concepts. Python
is a versatile, high-level programming language widely used in data science, web
development, and automation. This document covers variables, loops, and func-
tions, with examples to aid learning.
2 Variables and Data Types
Variables store data in Python. They are created by assigning a value using the
= operator. Python supports several data types, including:
• int: Integer numbers (e.g., 42)
• float: Floating-point numbers (e.g., 3.14)
• str: Strings (e.g., ”Hello”)
• bool: Booleans (e.g., True, False)
Example:
name = ”Alice” # String variable
age = 25 # Integer variable
height = 1.65 # Float variable
is_student = True # Boolean variable
3 Loops
Loops allow repetitive execution of code. Python supports for and while loops.
3.1 For Loops
for loops iterate over a sequence (e.g., list, range).
Example:
for i in range(5): # Prints 0 to 4
print(i)
3.2 While Loops
while loops repeat as long as a condition is true.
Example:
2
count = 0
while count < 3:
print(”Count:”, count)
count += 1
4 Functions
Functions encapsulate reusable code. They are defined using the def keyword.
Example:
def greet(name):
return ”Hello,␣” + name + ”!”
message = greet(”Bob”)
print(message) # Outputs: Hello, Bob!
Functions can have multiple parameters and return values, enabling modular
programming.
5 Conclusion
These notes cover the basics of Python variables, loops, and functions. Practice
by writing small programs to reinforce these concepts. Additional resources are
available in Python’s official documentation (python.org).