-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExamples.py
More file actions
51 lines (40 loc) · 1.15 KB
/
Examples.py
File metadata and controls
51 lines (40 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Генерация списка из случайных чисел
from random import randint
numbers = []
for i in range(3):
numbers.append(randint(-10, 10))
print(numbers)
lst = [randint(-10, 10) for i in range(10)]
print(lst)
#
a = [3, 4, 5]
b = [1, 2, 3]
c = [(x-y)**2 for x, y in zip(a, b)] # сложить эемементы списка
print(c)
import math
def jj(c):
total = 0
for i in c:
total += i
d = math.sqrt(total)
return d
print (round(jj(c),3))
# Дано число из отрезка [10, 99]. Показать наибольшую цифру числа
import random
import os
def ParsIntToList(a): # Разбирает число на список
numbers = []
while a > 0:
numbers.append(a % 10)
a //= 10
numbers.reverse()
return numbers
def MaxInList(list): # Возвращает максимальное число в списке
max = list[0]
for i in list:
if i > max: max = i
return max
n = random.randint(10, 99)
os.system('cls')
print(f'N = {n}')
print(f'{MaxInList(ParsIntToList(n))} является максимальной цифрой числа')