Created
November 22, 2023 15:32
-
-
Save prycerz/d1c8fa40b25651574fc92664b5af6b12 to your computer and use it in GitHub Desktop.
kod pythona generujący losowe liczby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def generuj_losowe_liczby(ilosc_liczb): | |
return [random.randint(1, 100) for _ in range(ilosc_liczb)] | |
def oblicz_srednia(liczby): | |
return sum(liczby) / len(liczby) if len(liczby) > 0 else 0 | |
# Generuj 10 losowych liczb | |
losowe_liczby = generuj_losowe_liczby(10) | |
# Oblicz średnią arytmetyczną | |
srednia = oblicz_srednia(losowe_liczby) | |
# Wyświetl wyniki | |
print("Wygenerowane losowe liczby:", losowe_liczby) | |
print("Średnia arytmetyczna:", srednia) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment