Class Notes: Introduction to Python Programming
Instructor: Prof. John Doe
Date: 16/5/2015
1. Basics of Python
High-level, interpreted language.
Used in web dev, data science, AI, and automation.
2. Syntax Rules
Indentation: Blocks use indentation (no curly braces).
Comments: Use # for single-line comments.
3. Variables and Data Types
Variables: Dynamically typed (e.g., x = 5).
Data types: int, float, str, bool, list, dict.
4. Control Structures
If-Else Example:
if x > 10:
print ( " Greater " )
else :
print ( " Smaller " )
Loops:
for loop: for i in range(5):
while loop: while x < 10:
1
5. Functions
def add (a , b ):
return a + b
Example: Factorial Function
def factorial ( n ):
if n == 0:
return 1
else :
return n * factorial (n -1)
Summary
Python’s readability and simplicity make it ideal for beginners. Practice writing small pro-
grams to reinforce concepts.
Review Questions
1. Write a Python program to check if a number is prime.
2. Explain the difference between a list and a dictionary.
References
Python Crash Course by Eric Matthes.
Official Python Documentation: https://www.python.org