# 3. Random Numbers

## 3.1. `random`

Table 33. `random`

Function

Description

`random.random()`

Random float: 0.0 <= x < 1.0

`random.randint(min, max)`

Return a random integer N such that `min <= N <= max`. Max is included

`random.gauss(mu, sigma)`

Gaussian distribution. mu is the mean, and sigma is the standard deviation

`random.shuffle(list)`

Randomize order of list (in place)

`random.choice(list)`

Single random element from a sequence

`random.sample(list, k)`

k random elements from list without replacement

`random.seed(a=None, version=2)`

Initialize the random number generator. If a is omitted or None, the current system time is used

## 3.2. Pseudo and Pure random numbers

• What are pseudorandom numbers?

• Why it is not possible to generate a pure random number?

• What is `random.seed(0)`?

## 3.3. Assignments

### 3.3.1. Random numbers

English
1. Print 6 random integers without repetition in range from 1 to 49

Polish
1. Wyświetl 6 losowych i nie powtarzających się liczb całkowitych z zakresu od 1 do 49.

### 3.3.2. Sum of inner elements

• Complexity level: medium

• Lines of code to write: 5 lines

• Estimated time of completion: 10 min

English
1. Use only `random` module

2. Set `random.seed(0)`

3. Generate `outer: List[List[int]]` with 16x16 random digits

4. Calculate sum of inner 4x4 elements

5. Inner matrix is exactly in the middle of outer

Polish
1. Używaj tylko modułu `random`

2. Ustaw `random.seed(0)`

3. Wygeneruj `outer: List[List[int]]` z 16x16 losowych cyfr

4. Policz sumę środkowych 4x4 elementów

5. Środkowa macierz jest dokładnie w środku większej

Hint
1. Digits are in range from 0 to 9 inclusive