introduction_to_python_programming_-_class_notes
introduction_to_python_programming_-_class_notes
1. What is Python?
Python is a high-level, interpreted programming language known for its readability and broad
2. Setting Up Python
3. Basic Syntax
# Print statement
print("Hello, World!")
# Variables
x=5
name = "Alice"
4. Data Types
- int: 10
- float: 3.14
- str: "Hello"
- bool: True/False
# Conditional Statements
if x > 0:
print("Positive")
elif x == 0:
print("Zero")
else:
print("Negative")
# Loops
for i in range(5):
print(i)
while x > 0:
x -= 1
6. Functions
def greet(name):
print(greet("Alice"))
7. File Handling
file.write("This is a file.")
8. Libraries and Modules
import math
print(math.sqrt(16))
9. Error Handling
try:
print(10 / 0)
except ZeroDivisionError:
10. Conclusion
Python is a powerful, easy-to-learn language that's great for beginners and professionals alike.
End of Notes