Python Programming Fundamentals
Computer Science Study Guide · Getting Started with Python
1. Why Python
Python is a widely used, beginner-friendly programming language known for its readable syntax and
broad application across web development, data analysis, automation, and artificial intelligence.
2. Variables and Data Types
Variables store data values and do not require an explicit type declaration in Python; the interpreter
infers the type automatically.
Type Example Description
int age = 25 Whole numbers
float price = 9.99 Decimal numbers
str name = "Alex" Text data
bool is_active = True True or False values
list nums = [1, 2, 3] Ordered, mutable collection
3. Control Flow
Conditional Statements
if, elif, and else statements let a program branch its behavior based on whether a condition evaluates
to True or False.
Loops
A for loop iterates over a sequence such as a list or range, while a while loop repeats as long as a
condition remains true.
4. Functions
Functions group reusable blocks of code under a name, defined using the def keyword. They can
accept parameters and return values, making code more organized and easier to maintain.
● Parameters let a function accept input values.
● The return statement sends a result back to the caller.
● Default parameter values make arguments optional.
5. Data Structures
● List: an ordered, changeable collection, written with square brackets.
● Tuple: an ordered, unchangeable collection, written with parentheses.
● Dictionary: a collection of key-value pairs, written with curly braces.
● Set: an unordered collection of unique elements.
6. Quick Review Questions
● What is the difference between a list and a tuple?
● How does a while loop differ from a for loop?
● Why are functions useful for organizing code?
● What data type would you use to store unique, unordered values?