generated from justuser-31/code_projects_template
Решения на первый блок
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
1 2
|
||||
2 3
|
||||
@@ -0,0 +1,38 @@
|
||||
a = int(input('Enter a: '))
|
||||
b = int(input('Enter b: '))
|
||||
|
||||
matrix = [
|
||||
[a, a+1],
|
||||
[b, b+1]
|
||||
]
|
||||
|
||||
first = True
|
||||
for line in matrix:
|
||||
#for el in line:
|
||||
if first == True:
|
||||
f_str = f'{line[0]} {line[1]}\n'
|
||||
first = False
|
||||
else:
|
||||
s_str = f'{line[0]} {line[1]}\n'
|
||||
# Write lines
|
||||
with open('file', 'w') as f:
|
||||
f.write(f_str)
|
||||
f.write(s_str)
|
||||
f.close()
|
||||
|
||||
readed_matrix = []
|
||||
with open('file', 'r') as f:
|
||||
for x in f:
|
||||
if x == '' or x == '\n':
|
||||
continue
|
||||
x = x.replace('\n', '')
|
||||
vals = x.split(' ')
|
||||
readed_matrix.append(vals)
|
||||
f.close()
|
||||
|
||||
print(f'''
|
||||
Original matrix:
|
||||
{matrix}
|
||||
Readed matrix:
|
||||
{matrix}
|
||||
''')
|
||||
Reference in New Issue
Block a user