6.189: Introduction to Programming in Python
Session 1 - Course Syllabus
Topics Covered:
1. **Administrivia.** Variables and Types.
2. **Functions.** Basic Recursion.
3. **Control Flow:** Branching and Repetition.
4. **Introduction to Objects:** Strings and Lists.
5. **Project 1:** Structuring Larger Programs.
6. **Python Modules.** Debugging Programs.
7. **Introduction to Data Structures:** Dictionaries.
8. **Functions as a Type,** Anonymous Functions
and List Comprehensions.
9. **Project 2:** Working in a Team.
10. **Quiz & Wrap-up.**
Notes/Homework
1. Install Python
- **Linux & macOS users:** Python should already be installed.
Check with `python --version`. Upgrade if below version 2.3.
- **Windows users:** Download Python
from [python.org](https://www.python.org/).
Run IDLE (Python GUI) after installation.
2. Reading
- Read **Sections 1.1-1.2, 1.8-1.9, and Chapter 2** of the textbook.
3. Writing Programs
- A program is a set of instructions for a computer to execute.
- Example program:
```python
print("Hello World!")
print("How are you?")
Output:
Hello World!
How are you?
print("| |\n| |\n| |")
Expected Output:
| |
| |
| |
**4. Interpreter Mode**
- Run `python` in terminal (Linux/macOS) or start IDLE (Windows).
- Example:
```python
print("Test message")
**5. Variables**
- Variables store information.
- Example:
```python
a = "Hello World!"
print(a)
Output:
Hello World!
```
Variables can be updated:
a = "Hello World!"
a = "Goodbye.."
print(a)
Output:
Goodbye..
Task: Write a program that assigns values to a variable and prints them:
a = 5
print(a)
a = 7
print(a)
Expected Output:
5
7
**6. Operators**
Basic arithmetic:
a = 5 + 7
print(a) # Output: 12
Complex expressions:
a = (3 + 4 + 21) / 7
b = (9 * 4) / (2 + 1) - 6
print((a * b) - (a + b)) # Output: 14
String concatenation:
print("Hello" + " World") # Output: Hello World
Task: Predict the output of the following:
print(13 + 6) # Output: _____
print(2 ** 3) # Output: _____
print(2 * (1 + 3)) # Output: _____
print(8 / 9) # Output: _____
print("13" + "6") # Output: _____
print("13" + 6) # Output: _____ (Error?)
**7. Review**
What is a program? How to write them.
Using interpreter mode for quick tests.
Variables store different types of information (Boolean, Integer, Float, String).
Operators: Arithmetic (+
, -
, *
, /
, **
) and their precedence.
String operations: Concatenation.
This concludes Session 1. Happy coding! 🚀
To mark this module as complete, you must finish this quiz. Once submitted, you'll need to wait 2 hours before attempting it again.