main
Ksenia 3 недель назад
Родитель 5e08ec6d4e
Сommit 172a6784df

@ -6,8 +6,9 @@
_Код:_ _Код:_
```py ```py
import cmath import cmath
a = tuple([((round(cmath.phase(0.2+0.8j),2)) * 20)// 3] + [((round(cmath.phase(0.2+0.8j),2)) * 20) % 3]) n = ((round(cmath.phase(0.2+0.8j),2)) * 20)
print(a) a, b = divmod(n, 3)
print(a,b)
``` ```
_Вывод:_ _Вывод:_
@ -28,7 +29,7 @@ start_time = time.time()
_Вывод:_ _Вывод:_
```py ```py
16:26 12:5
``` ```
## 3. ## 3.
@ -38,19 +39,13 @@ _Код:_
```py ```py
import random import random
spis = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота', 'Воскресенье'] spis = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота', 'Воскресенье']
i = 0 l = random.sample(spis, 3)
l = []
while i != 3:
a = random.choice(spis)
if a not in l:
l.append(a)
i += 1
print(l) print(l)
``` ```
_Вывод:_ _Вывод:_
```py ```py
['Четверг', 'Воскресенье', 'Суббота'] ['Понедельник', 'Суббота', 'Вторник']
``` ```
## 4. ## 4.
@ -59,7 +54,9 @@ _Вывод:_
_Код:_ _Код:_
```py ```py
import random import random
print(random.randrange(14,32,3)) num = list(range(14, 32, 3))
res = random.choice(num)
print(res)
``` ```
_Вывод:_ _Вывод:_
@ -73,17 +70,10 @@ _Вывод:_
_Код:_ _Код:_
```py ```py
import random import random
N = round((random.gauss(15, 4))) import string
l = [] N = round(random.gauss(15, 4))
c = [] l = string.ascii_uppercase
k = 0 c = random.sample(l, N)
for i in range(65, 91): # ASCII коды от A (65) до Z (90)
l.append(chr(i))
while k != N:
r = random.choice(l)
if r not in c:
c.append(r)
k += 1
print(c) print(c)
print(N) print(N)
print(f'Длина массива: {len(c)}') print(f'Длина массива: {len(c)}')
@ -91,9 +81,9 @@ print(f'Длина массива: {len(c)}')
_Вывод:_ _Вывод:_
```py ```py
['I', 'Q', 'N', 'O', 'H', 'C', 'K', 'R', 'B', 'G', 'J', 'Y', 'V', 'S'] ['M', 'Z', 'V', 'Q', 'G', 'O', 'N', 'J', 'X', 'R', 'C', 'S', 'H', 'B', 'T', 'F', 'U', 'E', 'K', 'W']
14 20
Длина массива: 14 Длина массива: 20
``` ```
## 6. ## 6.

@ -3,8 +3,9 @@
## 1. ## 1.
import cmath import cmath
a = tuple([((round(cmath.phase(0.2+0.8j),2)) * 20)// 3] + [((round(cmath.phase(0.2+0.8j),2)) * 20) % 3]) n = ((round(cmath.phase(0.2+0.8j),2)) * 20)
print(a) a, b = divmod(n, 3)
print(a,b)
## 2. ## 2.
import time import time
@ -15,32 +16,21 @@ start_time = time.time()
## 3. ## 3.
import random import random
spis = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота', 'Воскресенье'] spis = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота', 'Воскресенье']
i = 0 l = random.sample(spis, 3)
l = []
while i != 3:
a = random.choice(spis)
if a not in l:
l.append(a)
i += 1
print(l) print(l)
## 4. ## 4.
import random import random
print(random.randrange(14,32,3)) num = list(range(14, 32, 3))
res = random.choice(num)
print(res)
## 5. ## 5.
import random import random
N = round((random.gauss(15, 4))) import string
l = [] N = round(random.gauss(15, 4))
c = [] l = string.ascii_uppercase
k = 0 c = random.sample(l, N)
for i in range(65, 91): # ASCII коды от A (65) до Z (90)
l.append(chr(i))
while k != N:
r = random.choice(l)
if r not in c:
c.append(r)
k += 1
print(c) print(c)
print(N) print(N)
print(f'Длина массива: {len(c)}') print(f'Длина массива: {len(c)}')

Загрузка…
Отмена
Сохранить