java to python converter

Solutions on MaxInterview for java to python converter by the best coders in the world

showing results for - "java to python converter"
Léon
13 Oct 2016
1public class testint
2	{
3	    public static void main(String[] args)
4	    {
5	            boolean contain= false;
6	            int valeurATrouver=5;
7	            int ints[] ={1,4,5};
8	     
9	        for(int i=0;i<ints.length;i++)
10	        {
11	            if(ints[i]==valeurATrouver)
12	            {
13	                contain=true;
14	            }
15	        }
16	        if(contain){System.out.println("La valeur "+valeurATrouver+" est comprise dans le tableau");}
17	        else{System.out.println("La valeur "+valeurATrouver+" n'est pas comprise dans le tableau");}
18	    }
19	}
Louane
19 Jan 2017
1#include<stdio.h>
2int stack[10000000]={0};
3int top=-1;
4 
5void push(int c)
6{
7    stack[++top]=c;
8}
9 
10void pop()
11{
12    stack[top--]=0;
13}
14 
15int main()
16{
17    int N,max=0;
18    int order=1;
19    scanf("%d",&N);
20    int arr[N];
21    for(int i=0;i<N;i++)
22    {
23        scanf("%d",&arr[i]);
24        if(max<arr[i])
25        max=arr[i];
26    }
27    
28    for(int i=0;i<N;i++)
29    {
30        while(top!=-1 && stack[top]==order)
31        {
32            order++;
33            pop();
34        }
35        if(arr[i]==order)
36        {
37            order++;
38          
39        }
40        else
41        push(arr[i]);
42        
43    }
44      while(top!=-1 && stack[top]==order)
45        {
46            order++;
47            pop();
48        }
49    
50    if(order==max+1)
51    printf("Happy");
52    else
53    printf("Sad");
54    
55    
56}
57
Fabiana
14 May 2019
1import java.util.Scanner;
2
3public class Factorial {
4    public static void main(String[] args) {
5        Scanner sc = new Scanner(System.in);
6        System.out.println("Ingresa un numero para calcular su factorial: ");
7        int num = sc.nextInt();
8        System.out.println("Factorial de " + num + " es: " + factorial(num));
9    }
10
11    private static int factorial(int n) {
12        if (n == 0) { 
13            return 1;
14        } else {
15            return n * factorial(n - 1);
16        }
17    }
18}
Felipe
13 Jul 2017
1public static List<Integer> contacts(final List<String> queries) {
2        // Write your code here
3        final List<Integer> results = new ArrayList<>();
4        final List<String> adds = new ArrayList<>();
5
6        queries.forEach(contact -> {
7            if (contact.startsWith("find")) {
8                String find = contact.replaceAll("find ", "");
9                results.add((int) adds.stream().filter(add -> add.startsWith(find)).count());
10            } else {
11                adds.add(contact.replaceAll("add ", ""));
12            }
13        });
14
15        return results;
16    }
Leni
08 Jun 2016
1def SeatingStudents(arr):
2
3  K = arr[0]
4  occupied = arr[1:]
5
6  rows = int(K/2)
7
8  seats = []
9  x = 0
10  
11  for i in range(rows):
12    seats.append([])
13    for j in range(2):
14      if((x+1) in occupied):
15        full_seat = True
16      else:
17        full_seat = False
18      seats[i].append(str(full_seat))
19      x+=1
20
21  seating = 0
22  for i in range(rows-1):
23    if((seats[i][0] == str(False)) and (seats[i][1] == str(False))):
24      seating+=1
25
26    if((seats[i][0] == str(False)) and (seats[i+1][0] == str(False))):
27      seating+=1
28
29    if((seats[i][1] == str(False)) and (seats[i + 1][1] == str(False))):
30      seating+=1
31  
32  if((seats[rows - 1][0] == str(False)) and (seats[rows - 1][1] == str(False))):
33    seating+=1
34  return seating
35
36 
37print(SeatingStudents([12, 2, 6, 7, 11]))
Giovanni
11 May 2017
1hrs = input("Enter Hours:")
2h = float(hrs)
3rph=float(input("Enter rate per hours:"))
4if hrs>40:
5    print (40*rph +(h-40)*rph*1.5)
6else:
7    print(h*rph)