Answer the question
In order to leave comments, you need to log in
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
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')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question