Skip to content

Commit fcc5382

Browse files
committed
Added several tasks from CS course
1 parent 61cb58d commit fcc5382

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
# ----------------------

algorithms/fibonacci.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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

algorithms/insertsort.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Метод вставок
22
# Сначала отпределим функцию insertion_sort()
33
# на вход она примет у нас список insertion_sort(list)
4-
# Далее будем использовать цикл форб переберем элем. в пределе с 0 до длины списка - len(список)
4+
# Далее будем использовать цикл фор, переберем элем. в пределе с 0 до длины списка - len(список)
55
# или по другому указатель значений.
66
# Начинаем с самого левого значения списка. НО это не целесообразно, так как не с чем сравнивать.
77
# Начнем со второго, т.е. [1] ([0] самый левый)

0 commit comments

Comments
 (0)