add KR
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
def filter_numbers(data):
|
||||
new_data = []
|
||||
for dat in data:
|
||||
if type(dat) is int or float and not bool:
|
||||
new_data.append(float(dat))
|
||||
return new_data
|
||||
|
||||
|
||||
def calculate_average(numbers):
|
||||
result = 0
|
||||
if len(numbers) == 0:
|
||||
result = 0
|
||||
else:
|
||||
for number in numbers:
|
||||
result += float(number)
|
||||
return result
|
||||
|
||||
|
||||
def find_extremes(numbers):
|
||||
if not numbers:
|
||||
return (None, None)
|
||||
else:
|
||||
return min(numbers), max(numbers)
|
||||
|
||||
|
||||
def analyze_data(data):
|
||||
new_data = filter_numbers(data)
|
||||
print(f"Среднее: {calculate_average(new_data)}")
|
||||
print(f"Минимум: {find_extremes(new_data)[0]}")
|
||||
print(f"Максимум: {find_extremes(new_data)[1]}")
|
||||
|
||||
|
||||
my_list = []
|
||||
analyze_data(my_list)
|
||||
@@ -0,0 +1,38 @@
|
||||
import random
|
||||
import string
|
||||
|
||||
|
||||
def validate_length(length):
|
||||
if length < 8:
|
||||
print("Пароль должен быть не менее 8 символов")
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def generate_password(length, use_digits, use_special):
|
||||
password_book = string.ascii_letters
|
||||
if use_digits:
|
||||
password_book += string.digits
|
||||
if use_special:
|
||||
password_book += string.punctuation
|
||||
result = "".join(random.choices(password_book, k=length))
|
||||
return result
|
||||
|
||||
|
||||
def create_passwords(count, length):
|
||||
pasword_list = []
|
||||
i = 0
|
||||
for i in range(count):
|
||||
if validate_length(length):
|
||||
pasword = generate_password(
|
||||
length,
|
||||
use_digits=False,
|
||||
use_special=False
|
||||
)
|
||||
pasword_list.append(pasword)
|
||||
i += 1
|
||||
return pasword_list
|
||||
|
||||
|
||||
print(create_passwords(5, 12))
|
||||
Reference in New Issue
Block a user