python to java converter online

def average():
  sum=0
  n=int(input())
  p=int(input())
  for i in range(n,(n*p+1),n):
    sum=sum+i
  return int(sum/p)
print(average())

3.63
8
Frpzzd 95 points

                                    class Solution(object):
   def distributeCandies(self, candies, num_people):
      res = [0 for i in range(num_people)]
      index = 0
      while candies>0:
         res[index%num_people] += min(candies,index+1)
         candies-=(index+1)
         index+=1
      return res
ob1 = Solution()

3.63 (8 Votes)
0
4.33
9

                                    print("hola Mundo")

4.33 (6 Votes)
0
3.89
9

                                    n = int(input())
while n > 0:
    n -= 1
    m = int(input())
    a = input().split()
    for ind, i in enumerate(a):
        a[ind] = int(a[ind])
    b = sorted(a)
    b.reverse()
    total = 0
    for ind, i in enumerate(a):
        if (a[ind] == b[ind]):
            total +=1
    print(total)

3.89 (9 Votes)
0
4.67
3

                                    from selenium import webdriver
def main(Text):

   options = webdriver.FirefoxOptions()

   options.add_argument("-headless")

   driver = webdriver.Firefox(options=options)

   driver.maximize_window()

   search_string = Text

   frmtd_search_s = search_string.replace(" ","_")
   driver.get(f"https://en.wikipedia.org/wiki/{frmtd_search_s}")


   if "Wikipedia Does not have an article with this exact name." in driver.page_source:
       return("Sorry we couldn't find a wikipedia page for your search :(")

   else:
       body = driver.find_element_by_id("bodyContent")
       p_tags = body.find_elements_by_tag_name("p")

       for p_tag in p_tags:
           return{p_tag.text}

4.67 (3 Votes)
0
3.7
10
Jrrk 115 points

                                    k, m, a, b = int(input()), int(input()), int(input()), int(input())
res = 0
for i in range(a, b+1):
    if i % k == 0:
        res += 1
    if i % m == 0:
        res -= 1
print(res)

3.7 (10 Votes)
0
4.4
5
Taitrnator 95 points

                                    switch(escalaParaConverter){
            case 'C':
                if(this.getTemp().getEscala()=='K') this.kelvinParaCelsius();
                else if(this.getTemp().getEscala()=='F') this.fahrenheitParaCelsius();
                break;
            case 'K':
                if(this.getTemp().getEscala()=='C') this.celsiusParaKelvin();
                else if(this.getTemp().getEscala()=='F') this.fahrenheitParaKelvin();
                break;
            case 'F':
                if(this.getTemp().getEscala()=='C') this.celsiusParaFahrenheit();
                else if(this.getTemp().getEscala()=='K') this.kelvinParaFahrenheit();
                break;
        }

4.4 (5 Votes)
0
0
3
Mamta D 100 points

                                    def neighbour(map, node, m, n):
    calc_neighbour= [-8, -7, 1, 9, 8, 7, -1, -9]
    neighbour=[]
    for i in range(0,len(map[node])):
        a = map[node][i]
        if(a==1):
            x= node+calc_neighbour[i]+1
            if(x>0 and x<=m*n):
                neighbour.append(x)
    return neighbour

0
0
4
3

                                    def average():
  sum=0
  n=int(input())
  p=int(input())
  for i in range(n,(n*p+1),n):
    sum=sum+i
  return int(sum/p)
print(average())

4 (3 Votes)
0
3.8
5

                                    import math

def isPerfectSquare(x):
    s = int(math.sqrt(x))
    return s*s == x

def isPrime(n):
    if n <= 1:
        return 0
    for i in range(2, n):
        if n % i == 0:
            return 0;
    return 1
    
def solve(n):
    flag = 0
    if isPrime(n):
        if isPerfectSquare(5*n*n + 4) or isPerfectSquare(5*n*n - 4):
            flag = 0
        else:
            flag = 1
    return flag

3.8 (5 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source