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
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()
Thank you!
8
0
4.33
9
print("hola Mundo")
Thank you!
9
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)
Thank you!
9
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}
Thank you!
3
0
3.7
10
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)
Thank you!
10
0
4.4
5
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;
}
Thank you!
5
0
0
3
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
Thank you!
3
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())
Thank you!
3
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
Thank you!
5
0
Are there any code examples left?
New code examples in category Python
-
Python 2023-04-11 03:04:20
-
Python 2022-03-27 22:40:04 pycharm no module named
-
Python 2022-03-27 22:25:05 assign multiple variablesin one line
-
Python 2022-03-27 22:20:02 levenshtein distance
-
Python 2022-03-27 21:35:09 get text from url python last slash
-
Python 2022-03-27 21:30:30 df concatenate df
-
Python 2022-03-27 21:25:09 python odd or even
-
Python 2022-03-27 21:15:32 python include function from another file
-
Python 2022-03-27 21:10:01 color module python
-
Python 2022-03-27 21:00:27 python tkinter cursor types