ArmanPython
6 subscribers
2 photos
28 files
10 links
Transfer python files
Download Telegram
#from IPython.display import clear_output

## Step 1. Creat the Bord
def display_bord(bord):

print("\n"*10)

print(bord[7] + "|" + bord[8] + "|" + bord[9])
print("-|-|-")
print(bord[4] + "|" + bord[5] + "|" + bord[6])
print("-|-|-")
print(bord[1] + "|" + bord[2] + "|" + bord[3])

test_bord=["#", " ", " ", " ", " ", " ", " ", " ", " ", " "]
display_bord(test_bord)

## Step 2. player input

def player_input():

marker=""
## keep asking x or o

#while marker not in ("x","o"):
while marker != 'x' and marker != 'o':
marker = input("player 1 input x or o: ")
## assign player 1 to x

Player1 = marker

if Player1 == 'x':
Player2 = 'o'
else:
Player2 = 'x'


return(Player1,Player2)

#Pleyer1_marker,Player2_marker = player_input()
x = player_input()

print(x)

#print("\n"*100)

print ("Player 1 please start!")

## Step 3. Place their input on the board.

#def place_marker(board, marker, possition):



def display_marker(bord, marker, position):

bord[position]=marker

display_marker(test_bord, "x" , 8)


#print(display_marker(test_bord, "p" , 8)
print(display_bord(test_bord))
def centuryFromYear(year):
b=str(year)
if year in range(1,101):
print(1)
elif len(b)==3 and b[-2:] != "00":

c = int(b[0])+1
print(c)

elif len(b)==3 and b[-2:] == "00":

c = int(b[0])
print(c)

elif len(b)==4 and b[-2:] != "00":

c = b[0] + b[1]
print(int(c)+1)

elif len(b)==4 and b[-2:] == "00":

c = b[0]+b[1]
print(int(c))





centuryFromYear(1901)
def centuryFromYear(year):
b=str(year)
if year in range(1,101):
return 1
elif len(b)==3 and b[-2:] != "00":

c = int(b[0])+1
return c

elif len(b)==3 and b[-2:] == "00":

c = int(b[0])
return c

elif len(b)==4 and b[-2:] != "00":

c = b[0] + b[1]
return int(c)+1

elif len(b)==4 and b[-2:] == "00":

c = b[0]+b[1]
return int(c)




#centuryFromYear(1178)

print("It was in {} century".format(centuryFromYear(2501)))
Ars_Forwards = {"Lacazet": 10 , "Aubameyang" : 14 }
Ars_Midfielders = {"Mkhitaryan": 7, "Ramsay": 8}
Ars_Defenders = {"Belerin": 2, "Monreal": 18}
Ars_Goalkeepers = {"Cekh": 1, "Leno": 19}
ManUn_Forwards = {"Reshford": 10 , "Lukaku" : 9 }
ManUn_Midfielders = {"Pogba" : 6, "Lingard": 14}
ManUn_Defenders = {"Ashley Young": 18, "Shaw": 23}
ManUn_Goalkeepers = {"De Gea": 1, "Romero": 22}

class ArsenalTeam():
def __init__(self,ttt,kkk,bbb,ggg):
self.Forwards = ttt
self.Midfielders = kkk
self.Defenders = bbb
self.Goalkeepers = ggg


Arsenal = ArsenalTeam(ttt = Ars_Forwards,kkk = Ars_Midfielders,bbb=Ars_Defenders,ggg=Ars_Goalkeepers)


print("{} {}".format("Defanders",Arsenal.Defenders))

class ManUnTeam():
def __init__(self,ttt,kkk,bbb,ggg):
self.Forwards = ttt
self.Midfielders = kkk
self.Defenders = bbb
self.Goalkeepers = ggg

ManchesterUnited = ManUnTeam(ttt = ManUn_Forwards,kkk = ManUn_Midfielders,bbb=ManUn_Defenders,ggg=ManUn_Goalkeepers)


print("{} {}".format("Defanders",ManchesterUnited.Defenders))
## Ex. 6
def makeArrayConsecutive2(statues):
tt = sorted(statues)

out1 = [(tt[i] + 1) for i in range(0, len(statues) - 1) if tt[i] != (tt[i + 1] - 1)]

tt.extend(out1)
bb = sorted(tt)

out2 = [(bb[i] + 1) for i in range(0, len(bb) - 1) if bb[i] != (bb[i + 1] - 1)]

out2.extend(out1)

print (len(out2))



makeArrayConsecutive2([6, 2, 3, 8])
list=[33,22,20]

max=0

min=list[2]
max_list=[]
min_list=[]

for i in range(0,len(list)):
if list[i] > max:
max = list[i]
k=max
max_list.append(k)

# elif list[i] < min:
#
# min = list[i]
# d=min
# min_list.append(d)


print(max_list)

print(min_list)
import os
import time
import random
os.system('cls')

t0 = time.clock()
my_list=[]

for x in range(80000):
my_list.append(random.randint(1,152000))

m_max = my_list[0]


for i in range(len(my_list)):
if my_list[i] > m_max:
m_max = my_list[i]


print(max(my_list))
print(m_max)




print (time.clock() - t0, "seconds process time")
import os
import re

myfile = open("7lpp.compare.rs", "r")


texttofind = re.findall(r'[merge][l]*', myfile)
#texttofind = re.findall("Environment Switches")
texttoreplace = "Worked: ha ha ha"



filedata = myfile.read()
filedata = filedata.replace(texttofind,texttoreplace)

## Creating and writing changes

outfile= open("7lpp.compare.rs_int_re", "w")
outfile.write(filedata)
import os
texttofind = """{

merge_parallel(
state,
device_type,
device_names = {res_schname},

exclude_tolerances = res_merge_p_exclude_tol,

property_functions = res_merge_p_property_func
);"""

change_list = ("merge_series(", "merge_parallel(")
#text_to_replace0 = texttofind.replace("\t", "\\")
#text_to_replace1 = texttoreplace0.replace(" ", "")
#text_to_replace = texttoreplace1.replace("\n", ",")



myfile = open("7lpp.compare.rs", "r")


tmp_str = ""
out = ""
found = False
count = 0

for line in myfile.readlines():
if any(token in line for token in change_list):
found = True
tmp_str = ""
count = 0

while line[count] == "\t":
count += 1

if found:
tmp_str += line
out += "//" + line

if found and ");" in line:
found = False
tmp_str = tmp_str.replace("\n","")
tmp_str = tmp_str.replace(" ","")
tmp_str = tmp_str.replace("\t","")
tmp_str = "\n" + "\t" * count + tmp_str + "\n"
out += tmp_str
continue

if not found:
out += line


## Creating and writing changes

#outfile= open("7lpp.compare.rs_int", "w")
outfile= open("sample", "w")
outfile.write(out)
Նոր
regex tests