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

The name "Python" comes from Monty Python's Flying Circus, not the snake!

Real-World Applications

AreaExamples
Web DevelopmentDjango, Flask (Instagram, Pinterest)
Data Sciencepandas, NumPy, matplotlib
AI/MLTensorFlow, PyTorch, scikit-learn
AutomationFile management, web scraping, email
Scientific ComputingNASA, CERN, university research
Game DevelopmentPygame for 2D games

2. Installing Python

Installation Steps

Windows

  1. Go to python.org/downloads
  2. Download the latest Python 3.x installer
  3. Run the .exe installer
  4. CHECK "Add python.exe to PATH" (critical!)
  5. Click "Install Now"
Most common Windows mistake: forgetting to check "Add Python to PATH." If forgotten, uninstall and reinstall with the checkbox checked.

Mac

  1. Go to python.org/downloads
  2. Download the macOS installer (.pkg)
  3. Run the installer and follow prompts
  4. Use python3 command (not python) in Terminal

Linux

  1. Python 3 often comes pre-installed
  2. Check with: python3 --version
  3. 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

EditorBest ForNote
IDLEGetting started immediatelyComes with Python
VS CodeBest overall choiceFree, install Python extension
ThonnyAbsolute beginnersBuilt-in Python, great debugger
Sublime TextFast, lightweight editingFree 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()

Strings (Text)

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")

Python Files

Common Errors

ErrorCauseFix
SyntaxError: invalid syntaxMissing quotes around textAdd quotes: print("Hello")
SyntaxError: unterminated stringMismatched quotesMatch open/close quotes
SyntaxError: Missing parenthesesForgot parenthesesUse: print("text")
NameError: name 'Print' not definedWrong capitalizationUse 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)

Arithmetic Operators

OperatorNameExampleResult
+Addition5 + 38
-Subtraction10 - 46
*Multiplication6 * 742
/Division (always float)15 / 43.75
//Integer division15 // 43
%Modulo (remainder)15 % 43
**Exponentiation2 ** 101024

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)

TypeNameExamples
intInteger42, -7, 0, 1000
floatFloating-point3.14, -0.5, 2.0
strString"hello", 'Python', "42"
boolBooleanTrue, False

Useful Built-in Functions

FunctionPurposeExample
print()Display outputprint("Hello")
type()Check data typetype(42)<class 'int'>
help()Get documentationhelp(print)

Interpreter vs. Script File

Use Interpreter ForUse Script File For
Quick calculationsPrograms you want to save
Testing ideasMulti-line programs
Exploring with type()/help()Complete applications
Learning new functionsHomework assignments
Debugging valuesCode 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.

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

Module 1: What is Python & Getting Started

Free Python Learning Platform • Safaa Dabagh • sdabagh.github.io

© 2025