Module 1 Study Guide
What is Python & Getting Started
Free Python Learning Platform • Safaa Dabagh
1. What is Python?
Python: A high-level, interpreted, general-purpose programming language known for its clear, readable syntax. Created by Guido van Rossum; first released in 1991.
Key Characteristics
| Feature | What It Means |
|---|---|
| High-level | Handles complex details (memory, hardware) automatically so you focus on problem-solving |
| Interpreted | Code runs line by line (not compiled all at once); easy to test and debug |
| Dynamically typed | No need to declare variable types; Python figures them out (x = 5 not int x = 5) |
| Indentation-based | Uses whitespace to define code blocks instead of curly braces {} |
| General-purpose | Suitable for web, data science, AI, automation, games, science, and more |
Brief History
- 1989: Guido van Rossum begins working on Python
- 1991: First public release (version 0.9.0)
- 2000: Python 2.0 released
- 2008: Python 3.0 released (major redesign)
- 2020: Python 2 officially retired
- Today: Python 3 is the standard; consistently #1-2 most popular language
The name "Python" comes from Monty Python's Flying Circus, not the snake!
Real-World Applications
| Area | Examples |
|---|---|
| Web Development | Django, Flask (Instagram, Pinterest) |
| Data Science | pandas, NumPy, matplotlib |
| AI/ML | TensorFlow, PyTorch, scikit-learn |
| Automation | File management, web scraping, email |
| Scientific Computing | NASA, CERN, university research |
| Game Development | Pygame for 2D games |
2. Installing Python
Installation Steps
Windows
- Go to python.org/downloads
- Download the latest Python 3.x installer
- Run the .exe installer
- CHECK "Add python.exe to PATH" (critical!)
- Click "Install Now"
Most common Windows mistake: forgetting to check "Add Python to PATH." If forgotten, uninstall and reinstall with the checkbox checked.
Mac
- Go to python.org/downloads
- Download the macOS installer (.pkg)
- Run the installer and follow prompts
- Use
python3command (notpython) in Terminal
Linux
- Python 3 often comes pre-installed
- Check with:
python3 --version - If needed:
sudo apt install python3 python3-pip(Ubuntu/Debian)
Verifying Installation
python --version # or python3 --version on Mac/Linux
Should display something like: Python 3.12.1
PATH: An environment variable that tells your operating system where to look for programs. Python must be in your PATH for the
python command to work in the terminal.
Text Editors & IDEs
| Editor | Best For | Note |
|---|---|---|
| IDLE | Getting started immediately | Comes with Python |
| VS Code | Best overall choice | Free, install Python extension |
| Thonny | Absolute beginners | Built-in Python, great debugger |
| Sublime Text | Fast, lightweight editing | Free evaluation available |
3. Your First Python Program
The print() Function
print(): A built-in Python function that displays text or values on the screen. The most basic way to see output from your program.
Usage Patterns
# Basic text
print("Hello, World!")
# Numbers (no quotes needed)
print(42)
print(3.14)
# Multiple items (spaces added automatically)
print("The answer is", 42)
# Math inside print
print("Sum:", 3 + 4) # Output: Sum: 7
# Empty line
print()
print("Hello, World!")
# Numbers (no quotes needed)
print(42)
print(3.14)
# Multiple items (spaces added automatically)
print("The answer is", 42)
# Math inside print
print("Sum:", 3 + 4) # Output: Sum: 7
# Empty line
print()
Strings (Text)
- Text must be wrapped in quotes (single
'or double") - Both work the same:
"hello"and'hello' - Use double quotes when text has apostrophes:
"It's fun" - Use single quotes when text has double quotes:
'She said "hi"'
Comments
Comments: Notes in your code that Python ignores. Start with
#. Used to explain code, leave notes, or disable lines temporarily.
# This entire line is a comment
print("Hello") # This part is a comment
# print("This won't run")
print("Hello") # This part is a comment
# print("This won't run")
Python Files
- Save with
.pyextension (e.g.,hello.py) - Use lowercase and underscores:
my_program.py - No spaces in filenames
- Never name a file
python.py - Run from command line:
python hello.py - Run from IDLE: press F5
Common Errors
| Error | Cause | Fix |
|---|---|---|
| SyntaxError: invalid syntax | Missing quotes around text | Add quotes: print("Hello") |
| SyntaxError: unterminated string | Mismatched quotes | Match open/close quotes |
| SyntaxError: Missing parentheses | Forgot parentheses | Use: print("text") |
| NameError: name 'Print' not defined | Wrong capitalization | Use lowercase: print |
Python is CASE-SENSITIVE.
print() works. Print(), PRINT() do NOT.
4. The Python Interpreter (REPL)
REPL: Read-Eval-Print-Loop. An interactive environment where you type Python code one line at a time and see results immediately.
Starting and Exiting
# Start the interpreter
python # (or python3 on Mac/Linux)
# Exit the interpreter
exit() # or quit()
# Ctrl+D (Mac/Linux) or Ctrl+Z then Enter (Windows)
python # (or python3 on Mac/Linux)
# Exit the interpreter
exit() # or quit()
# Ctrl+D (Mac/Linux) or Ctrl+Z then Enter (Windows)
Arithmetic Operators
| Operator | Name | Example | Result |
|---|---|---|---|
+ | Addition | 5 + 3 | 8 |
- | Subtraction | 10 - 4 | 6 |
* | Multiplication | 6 * 7 | 42 |
/ | Division (always float) | 15 / 4 | 3.75 |
// | Integer division | 15 // 4 | 3 |
% | Modulo (remainder) | 15 % 4 | 3 |
** | Exponentiation | 2 ** 10 | 1024 |
Order of Operations (PEMDAS)
Parentheses → Exponents → Multiplication/Division → Addition/Subtraction
2 + 3 * 4 = 14 (multiplication first)(2 + 3) * 4 = 20 (parentheses first)
Data Types (Preview)
| Type | Name | Examples |
|---|---|---|
int | Integer | 42, -7, 0, 1000 |
float | Floating-point | 3.14, -0.5, 2.0 |
str | String | "hello", 'Python', "42" |
bool | Boolean | True, False |
Useful Built-in Functions
| Function | Purpose | Example |
|---|---|---|
print() | Display output | print("Hello") |
type() | Check data type | type(42) → <class 'int'> |
help() | Get documentation | help(print) |
Interpreter vs. Script File
| Use Interpreter For | Use Script File For |
|---|---|
| Quick calculations | Programs you want to save |
| Testing ideas | Multi-line programs |
| Exploring with type()/help() | Complete applications |
| Learning new functions | Homework assignments |
| Debugging values | Code to share with others |
In the REPL, typing an expression shows its value automatically.
In a script file, you must use print() to see output.
In a script file, you must use print() to see output.
Key Reminders
1. Python is case-sensitive: print() not Print()
2. Always check "Add to PATH" on Windows
3. Python files end in .py
4. Comments start with # and are ignored by Python
5. / gives float, // gives integer division
6. Quotes make text strings; no quotes for numbers
7. Use the REPL for testing, scripts for saving
2. Always check "Add to PATH" on Windows
3. Python files end in .py
4. Comments start with # and are ignored by Python
5. / gives float, // gives integer division
6. Quotes make text strings; no quotes for numbers
7. Use the REPL for testing, scripts for saving
Module 1: What is Python & Getting Started
Free Python Learning Platform • Safaa Dabagh • sdabagh.github.io
© 2025