Python Programming Class Notes
Python Programming Class Notes
=============================
Introduction to Python
---------------------
- Python is a high-level, interpreted programming language.
- Known for readability and versatility.
- Used in web development, data science, and automation.
Basic Syntax
------------
- **Variables**: No type declaration needed. Example: x = 5
- **Comments**: Use # for single-line comments.
- **Indentation**: Use 4 spaces for code blocks (e.g., under loops or functions).
Data Types
----------
- **Integers**: Whole numbers, e.g., 42
- **Floats**: Decimal numbers, e.g., 3.14
- **Strings**: Text, e.g., "Hello" (use single or double quotes)
- **Lists**: Ordered, mutable, e.g., [1, 2, "apple"]
Control Structures
------------------
- **If Statements**:
if x > 0:
print("Positive")
else:
print("Non-positive")
- **Loops**:
- For: for i in range(5): print(i) # Prints 0 to 4
- While: while x < 5: x += 1
Functions
---------
- Define with def keyword:
def greet(name):
return "Hello, " + name
- Call: print(greet("Alice")) # Outputs: Hello, Alice
Conclusion
----------
Practice these basics to build simple programs. Explore libraries like pandas or
tkinter next.
---
Word Count: 150