Lecture 3: Iteration

preview_player
Показать описание
MIT 6.100L Introduction to CS and Programming using Python, Fall 2022
Instructor: Ana Bell

An introduction to control flow and iteration through loops. Looping mechanisms include while and for loops. Lots of syntax today, be sure to get lots of practice! While loops loop as long as a condition is true and you need to make sure you don’t enter an infinite loop. For loops can loop over ranges of numbers and elements of a string.

License: Creative Commons BY-NC-SA

Рекомендации по теме
Комментарии
Автор

Its so hard to find a good teacher. Thank you MiT for uploading this video online for free.

NinjaScorpio
Автор

First video has 250k views, this has 15k. Keep grinding boys

fatbagz
Автор

I prefer the new format .
Greetings from Lampasas Texas .

brucefrizzell
Автор

Chapters:
00:00 - Intro
04:45 - Zelda
07:49 - While Loops
30:40 - For Loops
45:52 - Summary

tmo
Автор

On the "AT HOME" Practice 1 section:
The answer is:
x = 15
for i in range(1, x+1):
if i%5 == 0:
print(i)

What is the == 0 do? I get the i%5 is Divide i by 5.

danielspinks
Автор

Now you can't get out... if you go right or Right...

where = input("You're in the Lost Forest. Go Left or Right? ")
while where == "Right" or "right":
where = input("You're in the Lost Forest. Go Left or Right? ")
print("You got out of the Lost Forest!")

zaairvasquez
Автор

mysum = 5
start = 3
end = 5
for i in range(start, end):
mysum += i
print(mysum)

You still get 12

zaairvasquez
Автор

For this YOU TRY IT (For this code to use variables start and end in the range, to get the
total sum between and including those values.
For example, if start=3 and end=5 the the sum should be 12) why not just change mysum = 0 to mysum = 5?

zaairvasquez
Автор

Please ad the Dr. in front of your name. Makes a huge difference.

Zakariah
Автор

The fingertip exercise's solution code of this lecture is not entirely correct. N has to be cast as a variable first as per the question.

Paradoxonium
Автор

Hello, thanks, How are you? From France, great Thanks. Do you Know the benefts of doing sports?

alexiscamio