Skip to content

Commit fa88e9b

Browse files
committed
Game named 'Karti'
1 parent 267f164 commit fa88e9b

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

array.py

+44-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
n = 4
55
a = [] #initializing empty array
66
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
88

99
# Some fundamental operations
1010
# a = [1,2,3,4,5]
@@ -22,6 +22,43 @@
2222
average = total / len(a)
2323
stdio.writeln(average)
2424

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+
2562
#----------------------------------------------------------
2663
#Write a Python program to create an array of 5 integers
2764
# and display the array items.
@@ -64,14 +101,14 @@
64101
# in bytes
65102
def byte_size(byte):
66103
return len(byte.encode('utf-8'))
67-
print(byte_size)
104+
68105

69106
#----------------------------------------------------------
70107
# Stack overflow solution using sys library
71108
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)
75112

76113
#----------------------------------------------------------
77114
# Write a Python program to append items from inerrable to the end of the array.
@@ -82,3 +119,5 @@ def append_items(test):
82119

83120
#----------------------------------------------------------
84121
# Convert an array to an array of machine values and return the bytes representation
122+
# Не понял как сделать, гуглил. Есть только варианты с помощью библиотек(
123+

0 commit comments

Comments
 (0)