def random_data(): ''' This function return dictionary of random data for human: name, surname, age, gender ''' data = {} list_upper_case = list(string.uppercase) list_lower_case = list(string.lowercase) apper_leter = random_sample.choice(list_upper_case) apper_leter_2 = random_sample.choice(list_upper_case) lower_letters = reduce(lambda x, y: x + y, random_sample.sample(list_lower_case, 3)) lower_letters_2 = reduce(lambda x, y: x + y, random_sample.sample(list_lower_case, 5)) data['name'] = apper_leter + lower_letters data['surname'] = apper_leter_2 + lower_letters_2 data['age'] = random_sample.randint(16, 60) data['gender'] = random_sample.choice(['man', 'women']) return data
def ini_size(file_type): return random_sample.randint(800, 1000)
def ttf_size(file_type): return random_sample.randint(600, 800)
def jpg_size(file_type): return random_sample.randint(400, 600)
def zip_size(file_type): return random_sample.randint(200, 400)
def txt_size(file_type): return random_sample.randint(100, 200)
def ini_handler(): return randint(0, 100)
def ttf_handler(): return randint(1200, 2000)
def jpg_handler(): return randint(800, 1000)
def zip_handler(): return randint(500, 700)
def txt_handler(): return randint(100, 500)
data['age'] = random_sample.randint(16, 60) data['gender'] = random_sample.choice(['man', 'women']) return data # create file with random data for 100 student with open('students.json', 'w') as my_file: # quantity of student == 100 data_base_students = [random_data() for i in range(100)] my_file.write(json.dumps(data_base_students)) with open('students.json', 'r') as my_file: data_base_students = json.loads(my_file.read()) # random marks marks = [random_sample.randint(0, 10) for mark in range(10)] def stud_info(data_student): ''' This function recives random data for 'Student' and returns information about it. data_stud == data_base_students[x] ''' student = Students(marks, data_student['name'], data_student['surname'], data_student['age'], data_student['gender']) return student number_stud = random_sample.randint(0, 99) print(data_base_students[number_stud]) print('student #%d name is ' + str(stud_info(data_base_students[number_stud]).get_name()))\