Answers for "python to java converter"

0

python to java converter

import javax.swing.*;

public class Exe4{
	//metodo para calculo de Potencia
public static int exp(int n1,int n2)   
{
	int i=0, total=0;
	
	while(i<=n2)
	{
			total = n1*n2;	
			i++;
	}
	return total; 
    
}
  
       
	//metodo principal
	public static void main(String args[]){
		//Declaração de Variáveis
		int num1, num2;
		
		//Entrada de Dados do Usuário
		num1 = Integer.parseInt(JOptionPane.showInputDialog("Digite um número"));  
		num2 = Integer.parseInt(JOptionPane.showInputDialog("Digite outro número"));  
		
		//Exibição dos dados
		
		JOptionPane.showMessageDialog(null, exp(num1,num2));
		
	}
	
}
Posted by: Guest on July-13-2021
0

python to java converter

import math



print('Penentuan akar bilangan')

bilangan = int(input('Bilangan='))



a=1

b=bilangan

EPSILON = 1e-10

while b-a > EPSILON:

    x = (a+b)/2

    if x*x > bilangan:

        b=x

    else:

        a=x

        

akar = a



print('Akar', bilangan,'=', akar)

print('Hasil math.sqrt()=', math.sqrt(bilangan))
Posted by: Guest on October-18-2021
0

python to java converter

public static List<Integer> contacts(final List<String> queries) {
        // Write your code here
        final List<Integer> results = new ArrayList<>();
        final List<String> adds = new ArrayList<>();

        queries.forEach(contact -> {
            if (contact.startsWith("find")) {
                String find = contact.replaceAll("find ", "");
                results.add((int) adds.stream().filter(add -> add.startsWith(find)).count());
            } else {
                adds.add(contact.replaceAll("add ", ""));
            }
        });

        return results;
    }
Posted by: Guest on June-27-2021
0

python to java converter

array=list(map(int,input().split(",")))
array=sorted(array)
j=[]
j.append(array[0])
j.append(array[1])
for i in range(2,len(array)):
    if j[i-1]+j[i-2] in array:
        j.append(j[i-1]+j[i-2])
    else:
        break
print(j)
Posted by: Guest on March-13-2021
0

python to java converter

def shiftLeft(source,k):
    i=0
    while(i<=(len(source)-k-1)):
        source[i]=source[i+k]
        i=i+1
    i=len(source)-1
    while(i>=len(source)-k):
        source[i]=0
        i=i-1
    print(source)
source=[10,20,30,40,50,60]
shiftLeft(source,3)
Posted by: Guest on July-17-2021
0

python to java converter

a-int(input())

1=list (map(int,input().split()))

1. sort()

b-max(1)

c=min (1)

print (b-c)
Posted by: Guest on August-31-2021
0

python to java converter

import math as mt
def authentication(arr, n, m):
    t=0
    while (1):
        items = 0
        for i in range(n):
            items += (t//arr[i])
        if(items>=m):
            return t+10
        t+=1
arr=list(map(int,input().split()))
n=len(arr)
m=30

print(authentication(arr, n, m))
Posted by: Guest on June-07-2021
0

python to java converter

print("1. Addition \n")
print("2. Subtraction \n")
print("3. Multiplication \n")
print("4. Division \n")
menu = input("Please Insert Menu \n")
Posted by: Guest on July-06-2021
0

python to java converter

print('jjj');
Posted by: Guest on August-23-2021
0

python to java converter

import sys
import math


width = int(input())
height = int(input())
players = int(input())

class Player:
    def __init__(self, x, y):
        self.x = x
        self.y = y

DIR = {'UP' : 'C', 'RIGHT' : 'A', 'DOWN' : 'D', 'LEFT' : 'E', 'STAY' : 'B'}

grid = [['?' for x in range(width)] for y in range(height)]
enemies = [Player(-1,-1) for e in range(players-1)]
player = Player(-1,-1)

def enemyAtPos(x, y):
    for e in enemies:
        if x == e.x and y == e.y:
            return True
    return False
def getPossibleMoves(x, y):
    possibleMoves = []
    if grid[(y-1)%height][x] != '#':
        if not enemyAtPos(x, y-1) and not enemyAtPos(x, y-2) and not enemyAtPos(x-1, y-1) and not enemyAtPos(x+1, y-1):
            possibleMoves.append([x, (y-1)%height])
    if grid[y][(x+1)%width] != '#':
        if not enemyAtPos(x+1, y) and not enemyAtPos(x+2, y) and not enemyAtPos(x+1, y-1) and not enemyAtPos(x+1, y+1):
            possibleMoves.append([(x+1)%width, y])
    if grid[(y+1)%height][x] != '#':
        if not enemyAtPos(x, y+1) and not enemyAtPos(x, y+2) and not enemyAtPos(x-1, y+1) and not enemyAtPos(x+1, y+1):
            possibleMoves.append([x, (y+1)%height])
    if grid[y][(x-1)%width] != '#':
        if not enemyAtPos(x-1, y) and not enemyAtPos(x-2, y) and not enemyAtPos(x-1, y-1) and not enemyAtPos(x-1, y+1):
            possibleMoves.append([(x-1)%width, y])

    return possibleMoves
Posted by: Guest on March-13-2021

Python Answers by Framework

Browse Popular Code Answers by Language