Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Practice/PetrFedotov/lecture2-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def test1 (a, b):
if a > b:
print(f"{a}more, than {b}")
elif b > a:
print(f"{b} more, than {a}")
elif a == b:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наверное, здесь уже можно просто else, чтоб не выполнять уже лишнюю операцию сравнения.

print(f"{a} equal {b}")
test1(3, 4)
test1(5, 6)
test1(7, 7)

10 changes: 10 additions & 0 deletions Practice/PetrFedotov/lecture2-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def test2 (a, b):
if a > b:
print(f"{a}")
elif b > a:
print(f"{b}")
elif a == b:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наверное, здесь уже можно просто else, чтоб не выполнять уже лишнюю операцию сравнения.

print(f"enter different values")
test2(3, 1)
test2(3, 5)
test2(3, 3)
9 changes: 9 additions & 0 deletions Practice/PetrFedotov/lecture4-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def fizzbuzz():
for i in range(1, 101):
if i % 3 == 0:
print("fizz")
elif i % 5 == 0:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выравнивание поехало и сравнение лучше начинать с 15, т.к. все, что кратно 15 - кратно и 3, и 5.

print("buzz")
elif i % 15 == 0
print ("fizzbuzz")

9 changes: 9 additions & 0 deletions Practice/PetrFedotov/lecture4-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
input_num = input("enter a five-digit number: ")

def line(number):
count = 1
for i in number:
print(f"{count} number is {i}")
count += 1

line(input_num)
13 changes: 13 additions & 0 deletions Practice/PetrFedotov/lecture4-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def sorting(arr):
for i in range(len(arr)):
min_value = i
for j in range(i + 1, len(arr)):
if arr[j] < arr[min_value]:
min_value = j
temp = arr[i]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше применять swap-операцию (обмен переменных значениями) в питоническом стиле: a, b = b, a

arr[i] = arr[min_value]
arr[min_value] = temp

arr = [0, 3, 24, 2, 3, 7]
sorting(arr)
print(arr)