4
4
n = 4
5
5
a = [] #initializing empty array
6
6
for i in range (n ):
7
- a += [0.0 ] # addingone elem in the end of array
7
+ a += [0.0 ] # adding one elem in the end of array
8
8
9
9
# Some fundamental operations
10
10
# a = [1,2,3,4,5]
22
22
average = total / len (a )
23
23
stdio .writeln (average )
24
24
25
+ # Написать функцию вычисляющую среднее значение массива
26
+ # a = [1,2,3,4,0,-1]
27
+ # total = 0
28
+ # for i in a:
29
+ # total = total + a
30
+ # aver = total / len(a)
31
+
32
+
33
+ # Alias
34
+ # aliasing. Когда две переменные ссылаются на один и тот же объект
35
+ x = [1 ,3 ,4 ,0 ,90 ,905 ]
36
+ y = [6 ,4 ,21 ,4345 ,2 ]
37
+ x = y
38
+ print (y )
39
+
40
+
41
+ #----------------------------------------------------------
42
+ #ИГРА В КАРТЫ
43
+ #----------------------------------------------------------
44
+ SUITS = ['Clubs' , 'Diamonds' , 'Hearts' , 'Spades' ]
45
+ RANKS = ['2' , '3' , '4' , '5' , '6' , '7' ,'8' ,'9' ,'10' , 'Jack' , 'Queen' , 'King' , 'Ace' ]
46
+
47
+ # rank = random.randrange(0, len(RANKS))
48
+ # suit = random.randrange(0, len(SUITS))
49
+ # stdio.writeln(RANKS[rank] + ' of ' + SUITS[suit])
50
+
51
+ # Иницализируем массив массив длиной 52 представляющего колоду карт,
52
+ # используя лва только что определенных массива
53
+
54
+ desk = []
55
+ for rank in RANKS :
56
+ for suit in SUITS :
57
+ card = rank + ' of ' + suit
58
+ desk += [card ] # Равносильно desk = desk + card ?)
59
+ print (desk )
60
+
61
+
25
62
#----------------------------------------------------------
26
63
#Write a Python program to create an array of 5 integers
27
64
# and display the array items.
64
101
# in bytes
65
102
def byte_size (byte ):
66
103
return len (byte .encode ('utf-8' ))
67
- print ( byte_size )
104
+
68
105
69
106
#----------------------------------------------------------
70
107
# Stack overflow solution using sys library
71
108
import sys
72
- array_test = [1 ,2 ,3 ,- 1 ]
73
- sys . getsizeof [1 ,23 ,4 ]
74
- print (array_test )
109
+ # array_test = [1,2,3,-1]
110
+ # getsizeof[1,23,4]
111
+ # print(array_test)
75
112
76
113
#----------------------------------------------------------
77
114
# Write a Python program to append items from inerrable to the end of the array.
@@ -82,3 +119,5 @@ def append_items(test):
82
119
83
120
#----------------------------------------------------------
84
121
# Convert an array to an array of machine values and return the bytes representation
122
+ # Не понял как сделать, гуглил. Есть только варианты с помощью библиотек(
123
+
0 commit comments