Introduction to CS and Programming Using Python
MIT 6.100L Intro to CS and Programming using Python, lecture 1, explained in plain English
Want this lecture to stick? In LessonBound you get checked practice questions for every part, can ask about anything you don't get, and can listen with your screen off. Free, no ads.
Learn this lecture freeWatch or read the original lecture: MIT OpenCourseWare.
Part 1 · 0:00–10:00
This part explains that programming means writing step-by-step recipes for a computer, and that practice and computational thinking are central to the course.
Key ideas
- Programming is a skill, like math or reading, so you learn it by practicing often, not just by watching someone type code. 2:08
- Computational thinking means asking how computation can solve a problem, instead of first reaching for a math formula or a brute-force method. 3:31
- A statement of fact is declarative knowledge, but a computer needs imperative knowledge, which is a recipe that says how to do something. 5:17
- A recipe for a computer is an algorithm. It has a sequence of steps, a flow of control that can repeat or choose steps, and a way to stop. 8:12
- Computers are fast and can store huge amounts of data, but they do not decide anything on their own. They only do what you tell them to do. 9:16
Words to know
- declarative knowledge
- A statement of fact that says what is true, without saying how to get there.
- imperative knowledge
- A set of instructions that says how to do something, step by step, like a recipe.
- algorithm
- A clear sequence of steps that solves a problem or does a task. A recipe is one example.
- flow of control
- The rules that decide which step comes next, such as repeating steps or choosing between steps based on a check.
Example
A cake recipe is an algorithm. You follow the steps in order, repeat a check with a toothpick until it comes out clean, and then you stop. The computer works the same way: it follows the steps you give it, checks what you told it to check, and stops when you told it to stop.
3 checked practice questions for this part are in the app.
Part 2 · 10:00–20:00
This part explains how computers follow instructions exactly, how programming languages are built from simple pieces, and why a program can run without errors yet still do the wrong thing.
Key ideas
- Early pocket calculators could not store a sequence of steps for reuse. Stored-program computers could keep instructions in memory, like data, and an interpreter (a program that reads and carries out instructions) ran them one at a time. 10:41
- A computer has memory to hold values, an arithmetic logic unit (the part that does math and comparisons), and a control unit that tracks which instruction comes next. It only does the steps it is given, in order. 11:44
- Any task a computer can do can be built from a small set of basic building blocks, called primitives. Python gives you more convenient primitives, so you can get more done with less writing. 15:02
- Some mistakes are easy to catch. A program can be written in valid form (correct syntax, meaning the rules of spelling and structure) and still have no meaning, like adding text to a number. 17:37
- A program has only one meaning to the computer, but that meaning may not match what you intended. That gap is where most bugs come from, and it is why programs crash, run forever, or give wrong answers. 19:24
Words to know
- interpreter
- A program that reads instructions and carries them out, one step at a time.
- primitives
- The basic building blocks of a language, such as numbers, text, and simple operators, that bigger things are built from.
- syntax
- The rules for how words and symbols must be put together to make a valid sentence or expression.
- static semantic error
- A mistake where the code is written correctly but the operation makes no sense, such as adding text and a number.
Example
Think of a recipe card read by a robot cook who does exactly what it says and nothing more. If the card says 'add salt' but you meant 'add sugar', the robot will still add salt, and the dish turns out wrong even though every step was followed perfectly.
3 checked practice questions for this part are in the app.
Part 3 · 20:00–30:00
This part explains that every object in Python has a type that controls what you can do with it, and shows how to check a type and convert (cast) a value from one type to another.
Key ideas
- Programming mostly means creating objects and then manipulating them. Each object has a type, and the type decides what you are allowed to do with it. 21:48
- Python has scalar types, which are simple single values: int (whole numbers), float (numbers with a decimal point), bool (True or False), and NoneType (only the value None). 24:11
- You can find an object's type by typing type() with the object inside the brackets. Python then shows the type as its output. 25:36
- Casting turns an object into another type, such as float(3) giving 3.0. Casting does not change the original object. It makes a new object in memory. 28:27
- int() cuts off the decimal part without rounding, so int(5.9) gives 5. Round() does round, so round(5.9) gives 6. 29:10
Words to know
- type
- The category an object belongs to. It tells Python which actions are allowed on that object.
- float
- A number with a decimal point, such as 3.27 or 2.0. Python treats 2.0 as a float even though it equals 2.
- cast
- Changing a value into a different type, such as turning the integer 3 into the float 3.0. The original value stays the same.
- truncates
- Cuts off the decimal part of a number without rounding it up or down.
Example
Think of a type like the category on a kitchen tool. A measuring cup can measure flour, but you cannot use it to hammer a nail. Python's types work the same way: the type of an object tells Python which jobs that object can do.
3 checked practice questions for this part are in the app.
Part 4 · 30:00–40:00
This part explains how Python works out math expressions, what kind of number each result is, and how the order of operations decides what gets calculated first.
Key ideas
- Python reads an expression, works it out to one single value, and stores only that value. It does not keep the expression itself. 31:53
- You can put an expression almost anywhere, such as inside the type command. The whole expression then acts like one value. 31:31
- Adding, subtracting, and multiplying give a whole number (int) if both numbers are whole. If either number is a float (a number with a decimal point), the result is a float. Division always gives a float. 36:52
- The // operator gives the whole-number part of a division, and the % operator gives the remainder. For example, 5 // 3 is 1 and 5 % 3 is 2. 37:41
- Python does the power (**) step first, then multiplication, division, and remainder, then addition and subtraction. Parentheses let you change this order. 39:09
Words to know
- expression
- a piece of code that Python works out to give one value, such as 3 plus 2.
- operator
- a symbol that does something to values, such as plus, minus, or the percent sign.
- truncate
- to cut off the decimal part of a number and keep only the whole number. So 1 over 2 becomes 0.
- remainder
- what is left over after dividing one whole number by another. For 5 divided by 3, the remainder is 2.
Example
Think of a calculator. You type in 13 minus 4, then divide, and the screen shows only the final answer, not every key you pressed. Python works the same way: it keeps the final value and throws away the expression you wrote.
3 checked practice questions for this part are in the app.
Part 5 · 40:00–50:00
This part explains how programs use variables to give names to values, and why clear names and comments make code easier to read.
Key ideas
- Giving a name to a value means you can reuse it in many places without copying it again and again. This makes programs easier to read and write. 40:42
- In computer science, the equal sign is an assignment, not a statement of equality. It binds a name to a value, so x = 6 means x now stands for 6. 44:29
- When Python runs an assignment, it first works out the value on the right side of the equal sign. Then it binds that one value to the name on the left. 44:49
- Variable names have rules. The name xy is allowed, but x * y is not, because operators like * are special and cannot be part of a name. 45:53
- Pick names that say what the value is for, and add comments (lines that start with a hash) to explain the code. This helps you and others read the program later. 47:18
Words to know
- variable
- A name that stands for a value stored in the computer's memory. You can use the name anywhere you want that value.
- assignment statement
- A line of code that gives a value to a name, using the equal sign. The name on the left gets the value on the right.
- expression
- A piece of code, such as 3 plus 4 or pi times radius, that Python works out into one single value.
- comment
- A note in the code that starts with a hash. Python skips it when running the program. It is there to help people read the code.
Example
Think of a label on a jar in your kitchen. If the label says sugar, you know what is inside without opening it, and you can find it quickly. A variable name works the same way: a clear name tells you what value it holds, so you do not have to check every line of code to find out.
3 checked practice questions for this part are in the app.
Part 6 · 50:00–1:03:18
This part shows how Python names and values work: a name can be moved to a new value, and each line runs in order.
Key ideas
- A variable name can be moved from one value to another. When you rebind it, the name lets go of the old value, and that old value just sits in memory. 50:37
- In an assignment, Python first works out the right side, then attaches the result to the name on the left. So radius = radius + 1 is allowed in computer science, even though it would be false in math. 52:25
- Lines run one after another, from top to bottom. If area was calculated before radius changed, area keeps its old value until you calculate it again. 54:33
- If you reassign a variable before saving its old value, you can lose the only name pointing to that value. A temporary variable can hold the value so it is not lost. 58:33
- Python Tutor is a website where you step through code one line at a time and see every variable's value after each line. It is a useful way to find bugs. 55:37
Words to know
- binding
- The link between a name and a value. Saying x = 5 binds the name x to the value 5.
- assignment
- Giving a name a value with the equal sign. In Python, the right side is worked out first, then the result is attached to the name on the left.
- evaluate
- To work something out until you get a single final value.
- garbage collection
- A process where Python clears out values that no name points to anymore, to free up memory.
Example
Think of a variable name like a sticky note on a box. When you move the note to a different box, the first box is no longer labeled, and nothing can find it again unless you write the label back on it. This is what happens when a name is rebound to a new value.
3 checked practice questions for this part are in the app.
Lecture 2: Strings, Input/Output, and Branching →
Notes written by AI (Claude) from the lecture's official transcript, so check anything important against the lecture. MIT OpenCourseWare · CC BY-NC-SA 4.0 · not affiliated with or endorsed by MIT. These notes are shared under the same license.
LessonBound · Free lecture notes · Privacy · Terms · New York