Professional Documents
Culture Documents
Звіт лабораторна №5 Ковальчук О. КН-20-1
Звіт лабораторна №5 Ковальчук О. КН-20-1
Хід роботи:
gipot1 = float()
gipot2 = float()
else:
d2 = gipot2 - gipot1
print('Гіпотенуза 2-го трикутника більше ')
Завдання 3: Задано коло (x-a)2 + (y-b)2 = R2 і точки Р (р1, р2), F (f1, f1), L
(l1, l2). З'ясувати і вивести на екран, скільки точок лежить всередині кола.
Перевірку, чи лежить точка всередині кола, оформити у вигляді функції.
Лістинг програми:
def task(a, b, r, c):
return len(list(filter(lambda x: (x[0] - a) ** 2 + (x[1] - b) ** 2 < r ** 2,
c)))
Лістинг програми:
import math
n = int(input('Введіть n: '))
numbers = [2, 3, 7]
def get_time6(func):
def function(m,n):
start = time.perf_counter()
value = func(m, n)
end = time.perf_counter()
print("Пройшло часу:", end - start)
return value
return function
@get_time6
def chysla(m, n):
maxx = []
dict = {}
for i in range(m, n + 1):
count = 0
for j in range(1, i // 2 + 1):
if i % j ==0:
count += 1
dict[i] = count
maximum = max(dict.values())
for key, value in dict.items():
maxx.append(key)
return maxx
def get_time7(func):
def function(m,type="1"):
start = time.perf_counter()
value = func(m, type)
end = time.perf_counter()
print("Пройшло часу:", end - start)
return value
return function
@get_time7
def prosti(n, type='lst'):
count = 0
list = [2]
for i in range(3, n + 1, 2):
if (i > 10) and (i % 10 == 5):
continue
for j in list:
if j * j - 1 > i:
list.append(i)
count += 1
break
if i % j == 0:
break
else:
list.append(i)
count +=1
if type == 'lst':
return list
elif type == 'spisok':
return '\n'.join(map(str, list))
elif type == 'count':
return count + 1
while True:
try:
ch = int(input('Введіть тип виводу: \n 1-Список \n 2-Рядки \n
3-Кількість \n'))
if not 0 < ch < 4:
raise ValueError
except ValueError:
Лістинг програми:
import math
import random
import time
def get_time8(func):
def function(list, m, n):
start = time.perf_counter()
value = func(list, m, n)
end = time.perf_counter()
print("Пройшло часу: ",end - start)
return value
return function
@get_time8
def list(mylist, bottom, upper):
list = []
minimum = min(mylist)
maximum = max(mylist)
if type(bottom) is not int or type(upper) is not int:
raise Exception('Введіть число типу int: ')
if minimum + bottom >= maximum - upper or bottom >= upper:
raise Exception('Неправильно вказаний інтервал!' )
for i in range(len(mylist)):
if minimum + bottom <= mylist[i] <= maximum - upper and bottom <=
mylist[i] <= upper:
list.append(mylist[i])
if not list:
return 'Такі числа відсутні'
return list