File tree Expand file tree Collapse file tree
Courses/Introduction to CS MITx/Week 2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Task 1
2+ iteration = 0
3+ count = 0
4+ while iteration < 5 :
5+ for letter in 'hello, world' :
6+ count += 1
7+ print ('Iteration ' + str (iteration ) + '; count is: ' + str (count ))
8+ iteration += 1
9+ print ('------------------------------------' )
10+
11+ # What is the value of the variable count that
12+ # is printed out (at the print statement) on iteration 0, 1, 2 ..?
13+ # Try to quess without running this part of code
14+
15+ # ----------------------
16+
17+ # Task 2
18+ iteration = 0
19+ while iteration < 5 :
20+ count = 0
21+ for letter in 'hello, world' :
22+ count += 1
23+ print ('Iteration ' + str (iteration ) + '; count is: ' + str (count ))
24+ iteration += 1
25+ print ('------------------------------------' )
26+ # What is the value of the variable count that
27+ # is printed out (at the print statement) on iteration 0, 1, 2 ..?
28+
29+ # ----------------------
30+
31+ # Task 3
32+ iteration = 0
33+ while iteration < 5 :
34+ count = 0
35+ for letter in 'hello, world' :
36+ count += 1
37+ if iteration % 2 == 0 :
38+ break
39+ print ('Iteration ' + str (iteration ) + '; count is: ' + str (count ))
40+ iteration += 1
41+ print ('------------------------------------' )
42+
43+ # ----------------------
Original file line number Diff line number Diff line change @@ -13,6 +13,5 @@ def fibonacci(n):
1313# fibonacci(3) = (fibonacci(2)+fibonacci(1))
1414# fibonacci(2) = (fibonacci(1)+fibonacci(0))
1515
16- print (fibonacci (3 )) #
1716
1817
Original file line number Diff line number Diff line change 11# Метод вставок
22# Сначала отпределим функцию insertion_sort()
33# на вход она примет у нас список insertion_sort(list)
4- # Далее будем использовать цикл форб переберем элем. в пределе с 0 до длины списка - len(список)
4+ # Далее будем использовать цикл фор, переберем элем. в пределе с 0 до длины списка - len(список)
55# или по другому указатель значений.
66# Начинаем с самого левого значения списка. НО это не целесообразно, так как не с чем сравнивать.
77# Начнем со второго, т.е. [1] ([0] самый левый)
You can’t perform that action at this time.
0 commit comments