convert python to java

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

showing results for - "convert python to java"
Amelie
13 Mar 2019
1import check50
2import check50_java
3
4@check50.check()
5def book_exists():
6    """Book.java exists."""
7    check50.exists("Book.java")
8
9@check50.check(book_exists)
10def book_compiles():
11    """Book.java compiles."""
12    check50_java.compile("Book.java")
13
14@check50.check()
15def press_exists():
16    """Press.java exists."""
17    check50.exists("Press.java")
18
19@check50.check(press_exists)
20def press_compiles():
21    """Press.java compiles."""
22    check50_java.compile("Press.java")
23
24@check50.check()
25def vm_exists():
26    """VendingMachine.java exists."""
27    check50.exists("VendingMachine.java")
28
29@check50.check(vm_exists)
30def vm_compiles():
31    """VendingMachine.java compiles."""
32    check50_java.compile("VendingMachine.java")
Erik
28 Aug 2018
1s=input()
2l=[]
3s1='aeiou'
4sum1=0
5def snm(sum1):
6    t=0
7    while(sum1>0 or t>9):
8        if(sum1==0):
9            sum1=t
10            t=0
11        t=t+sum1%10
12        sum1=sum1//10
13    return t
Griffin
24 Apr 2017
1s=input()
2l=[]
3s1='aeiou'
4sum1=0
5def snm(sum1):
6    t=0
7    while(sum1>0 or t>9):
8        if(sum1==0):
9            sum1=t
10            t=0
11        t=t+sum1%10
12        sum1=sum1//10
13    return t
14    
15for i in range(len(s)):
16    if s[i] in s1:
17        l.append(i)
18for j in range(len(l)):
19    k=l[j]*5
20    sum1=0
21    for h in range(1,k+1,2):
22        sum1=sum1+h
23    print(snm(sum1))
Larissa
06 Jan 2017
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]))
Davide
18 Jan 2021
1for i in range(2,len(array)):