22 - python & all web labs

This commit is contained in:
2026-05-02 20:27:02 +05:00
parent ef77f101fa
commit 19af922baf
5781 changed files with 770492 additions and 96 deletions

26
labPython/lab21/task_3.py Normal file
View File

@@ -0,0 +1,26 @@
def calc_gen4(a, r):
current = a
while True:
yield current
current *= r
while True:
print("геометрическая прогрессия")
print("1 - Запустить")
print("0 - Выход")
choice = input("Выбор: ")
if choice == "0":
break
if choice == "1":
try:
a = float(input("Первый член: "))
r = float(input("Знаменатель: "))
n = int(input("Сколько элементов вывести: "))
gen = calc_gen4(a, r)
for _ in range(n):
print(next(gen))
except:
print("Ошибка ввода")