Answers for "java to puthon converter"

C++
0

java to puthon converter

import java.util.*;
import java.lang.*;
import java.io.*;

// Please name your class Main
class Main {
	public static void main(String[] args) {
        int answer=0,mod=1;
        double value;
        Scanner in = new Scanner(System.in);
        int p = in.nextInt();
        int q = in.nextInt();
        int n = in.nextInt();
        int m = in.nextInt();

        if(1<=p && p<=1000){
            if(0<=q && q<=1000){
                if(1<=n || m<=(10^9)){

                    for(int i=1;i<=n;i++) {

                        value = Math.pow(p, i) * Math.pow(i, q) ;
                        answer+=value;
                        
                        mod= answer % m;
                        

                        
                        }
                    
                        System.out.println(mod);
                            }
                        }
                    }
                }
}
Posted by: Guest on October-23-2021
0

python to java converter

def SeatingStudents(arr):

  K = arr[0]
  occupied = arr[1:]

  rows = int(K/2)

  seats = []
  x = 0
  
  for i in range(rows):
    seats.append([])
    for j in range(2):
      if((x+1) in occupied):
        full_seat = True
      else:
        full_seat = False
      seats[i].append(str(full_seat))
      x+=1

  seating = 0
  for i in range(rows-1):
    if((seats[i][0] == str(False)) and (seats[i][1] == str(False))):
      seating+=1

    if((seats[i][0] == str(False)) and (seats[i+1][0] == str(False))):
      seating+=1

    if((seats[i][1] == str(False)) and (seats[i + 1][1] == str(False))):
      seating+=1
  
  if((seats[rows - 1][0] == str(False)) and (seats[rows - 1][1] == str(False))):
    seating+=1
  return seating

 
print(SeatingStudents([12, 2, 6, 7, 11]))
Posted by: Guest on May-28-2021

Browse Popular Code Answers by Language