D
D
dared972020-08-10 10:53:27
Python
dared97, 2020-08-10 10:53:27

How can I convert this Pascal ABC code to Visual Python code?

Uses crt, graphABC;
Const r=0.1; k=0.01;  dt=0.001; q=100; N=60;
 Var  teta,F,t,m: real;   i,Gd,Gm: integer;
 eta,ksi: array[0..N+1] of real;
 Procedure Oscillator;
   begin
      F:=q*(ksi[i-1]-ksi[i])+q*(ksi[i+1]-ksi[i]);
      If i>N/2  then m:=1 else m:=0.3;
      teta:=(F-r*eta[i]-k*ksi[i])/m;
      eta[i]:=eta[i]+teta*dt;
      ksi[i]:=ksi[i]+eta[i]*dt;
   end;
BEGIN
     Repeat t:=t+dt;
         For i:=1  to N do
            begin
               Oscillator;
              If 5*t<3.142  then
                   ksi[1]:=10*sin(5*t)
                 else ksi[1]:=0; ksi[N]:=0;   {ksi[N]:=ksi[N-l];   }
            end;
     clrScr;
     For i:=1  to N do circle(8*i,240-round(ksi[i]*10),2);
  until KeyPressed;
END.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
milssky, 2020-08-10
@milssky

Can be done by hand. Do you seriously expect that someone will want you to do your task just like that?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question