This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = int(input("Введите число:")) | |
o = 0 | |
for i in range(1, N + 1): | |
o = o + i | |
print(o, " (", end="") | |
for i in range(1, N+1): | |
print(f"{i} +", end=" ") | |
print("\b\b\b)", end="") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
цикл for\ range \ итератор \ laze evaluation | |
итератор - обьект который позволяет перебирать элементы по | |
одному запоминая своё текущее положение | |
итерация - один шаг цикла | |
range() - встроенная функция котораягенерирует последовательность цисел | |
range(start, stop, step) -> range(1, 10, 3) | |
- start ( по иумолчанию 0) | |
- stop конечное число ( не включается в последовательность) | |
- step (по умолчанию 1) шаг изменения чисел | |
------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
задача 1 | |
N = int(input("Введите число")) | |
a = 0 | |
for i in range(1, N + 1): | |
a +=i | |
print(a) | |
задача 2 | |
N = int(input("Введите число")) | |
for i in range(1, 11): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
задача 1 | |
num = int(input("Введите число")) | |
count = 0 | |
while True: | |
count += 1 | |
x = num * count | |
print(x) | |
if x > 50: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
задача 1 | |
begin = int(input("begin >> ")) | |
end = int(input("end >>")) | |
if begin >= end: | |
print("не верное значение") | |
i = begin | |
s = 0 | |
while (i <= end): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
цикл с условием (While) если условие верно | |
agestudent = 0 | |
agestudent += 1 | |
синтаксис | |
While = пока | |
break = pfdthitybt wbrkf | |
continue пропуск иттерации = это одан шаг | |
count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = int(input("Введите целое число")) | |
if x % 2 == 0: | |
print("Четное") | |
else: | |
print("Нечетное") | |
if x % 5 == 0: | |
print("Кратно 5") | |
else: | |
print("Не кратно 5") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
задача 1 | |
x = int(input("Введите первое число")) | |
y = int(input("Введите второе число")) | |
z = int(input("Введите третье число")) | |
viv = int(input("сумма = 0; произведение = 1")) | |
if viv == 0: | |
print(x + y + z) | |
elif viv == 1: | |
print(x * y * z) | |
задача 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[and | or | not] | |
x=6, y=16, z= -43 | |
expression = ((x<y) and (y>z) and (x!=0)) | |
в () либо true либо false | |
таблица истинности | |
and | |
1 0 0 | |
0 1 0 | |
1 1 1 | |
or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
R1 = 2 | |
R2 = 3 | |
R3 = 4 | |
R0 = 1/(1/R1+1/R2+1/R3) | |
print(R0) | |
pi = 3.14 | |
L = 5 | |
R = L/(2*pi) | |
S = pi*R**2 |