Help me translate the code from Pascal to Python, please.



  • x := 0; y := 0;
    for i := 1 to N do
      if a[i]>=4 then
      begin
        x := x+a[i]; //сумма
        y := y+1; //количество
      end;
    s := x/y; //среднее
    writeln('Sred.Ball= ',s);
    


  • x = 0
    y = 0
    
    for i in range(1, N + 1):
        if a[i] >= 4:
            x = x + a[i]       # сумма
            y = y + 1          # количество
    
    s = x / y                  # среднее
    print('Sred.Ball= ',s);
    

    In Piton instead of a couple begin / end Used Derogations (usually 4 gaps for one level) means they're important.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2