Untitled

mail@pastecode.io avatar
unknown
plain_text
16 days ago
1.3 kB
1
Indexable
Never
import random

def generate_random_multiples_of_three_array(size):
    array = [random.randint(1, 100) * 3 for _ in range(size)]
    return array

def find_multiples_of_three_five_six(array):
    result_array = [x for x in array if x % 3 == 0 or x % 5 == 0 or x % 6 == 0]
    return result_array

def combine_and_calculate(array_a, array_b):
    combined_array = array_a + array_b
    total_sum = sum(combined_array)
    min_value = min(combined_array)
    max_value = max(combined_array)
    return total_sum, min_value, max_value

# Przykładowe użycie funkcji:

# a)
size = 10
random_multiples_of_three_array = generate_random_multiples_of_three_array(size)
print("Tablica liczb losowych będących wielokrotnościami liczby 3:", random_multiples_of_three_array)

# b)
multiples_of_three_five_six_array = find_multiples_of_three_five_six(random_multiples_of_three_array)
print("Tablica liczb będących wielokrotnościami liczby 3, 5 lub 6:", multiples_of_three_five_six_array)

# c)
total_sum, min_value, max_value = combine_and_calculate(random_multiples_of_three_array, multiples_of_three_five_six_array)
print("Suma wszystkich elementów:", total_sum)
print("Najmniejsza wartość:", min_value)
print("Największa wartość:", max_value)
Leave a Comment