Programming 101 - Class Notes
1. Introduction to Programming
• Definition: Programming is the process of giving instructions to a computer to perform tasks.
• Programs: A set of instructions written in a programming language.
• Programming Languages: Tools used to communicate with computers (e.g., Python, Java, C++,
JavaScript).
2. Basics of Programming
• Syntax: The set of rules that defines how programs must be written.
• Semantics: The meaning behind the syntax (what the program actually does).
• Compilers/Interpreters: Translate code into machine-readable format.
• Errors:
• Syntax Error: Mistakes in grammar of the programming language.
• Runtime Error: Errors while the program is running.
• Logic Error: Program runs but produces incorrect output.
3. Programming Concepts
• Variables: Storage for data values.
• Data Types:
• Integers (whole numbers)
• Floats (decimal numbers)
• Strings (text)
• Booleans (True/False)
• Operators:
• Arithmetic (+, -, *, /)
• Comparison (==, !=, >, <)
• Logical (and, or, not)
• Input/Output:
• input() to get user input.
• print() to display output.
4. Control Structures
• Conditional Statements:
• if , elif , else
• Loops:
• for loops
• while loops
1
• Break & Continue: Control loop execution.
5. Functions
• Definition: A reusable block of code that performs a specific task.
• Syntax:
def function_name(parameters):
# code block
return value
• Benefits: Reusability, readability, modularity.
6. Data Structures
• Lists: Ordered, changeable collection of items.
• Tuples: Ordered, unchangeable collection.
• Dictionaries: Key-value pairs.
• Sets: Unordered collection of unique items.
7. Object-Oriented Programming (OOP)
• Concepts:
• Classes: Blueprint for creating objects.
• Objects: Instances of classes.
• Attributes: Variables inside a class.
• Methods: Functions inside a class.
• Principles:
• Encapsulation
• Inheritance
• Polymorphism
• Abstraction
8. Debugging & Best Practices
• Debugging: Process of finding and fixing errors.
• Best Practices:
• Write readable code (use meaningful variable names).
• Comment code where necessary.
• Keep code modular.
• Test code regularly.
2
9. Introduction to Algorithms
• Definition: A step-by-step procedure to solve a problem.
• Examples: Sorting, searching, recursion.
• Complexity:
• Time complexity (speed)
• Space complexity (memory usage)
10. Summary
• Programming is about problem-solving.
• Learn the syntax, then focus on logic.
• Practice is key—write code daily.
• Start small, then build bigger projects.