N
N
Nazarko032020-05-23 09:48:51
Python
Nazarko03, 2020-05-23 09:48:51

What would this Python code look like?

var
 D:TextFile;
 str,imya:string;
 i,n,k:integer;
begin
writeln('vedite imya faila');
readln(Imya);
writeln('vvedite N');
readln(N);
writeln('vvedite K');
readln(K);
for I := 1 to k do begin
 str:=str+'*';
end;
{связываем дискриптор с конкретным файлом}
   AssignFile(D,Imya);
  {создаем файл для записи данных}
  rewrite(D);
  for I := 1 to n do
  writeln(D,str);
  CloseFile(D);
  readln;
end.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2020-05-23
@Nazarko03

About something like this. Didn't check at work.

imya = input('vedite imya faila')
n = input('vvedite N')
k = input('vvedite K')
str1 = '*' * int(k)
with open(imya, 'w+') as out_file:
    for i in range(int(n)):
        out_file.write(str1 + '\n')

H
HemulGM, 2020-05-23
@HemulGM

Rewrite and find out

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question