“Convertir le code Java en Python en ligne” Réponses codées

Convertir le code Java en Python en ligne

class HelloWorld
{
    // Your program begins with a call to main().
    // Prints "Hello, World" to the terminal window.
    public static void main(String args[])
    {
        System.out.println("Hello, World");
    }
}
Real Raven

Convertir le code Java en Python en ligne

import java.util.Scanner;  // needed for Scanner
Spotless Sloth

Convertir le code Java en Python en ligne

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String args[] ) throws Exception {
int a;
double b,c;
Scanner sc = new Scanner(System.in);
a = sc.nextInt();
b = sc.nextDouble();
c = sc.nextDouble();
Account account = new Account(a, b, c);
int noOfYear;
noOfYear = sc.nextInt();
double answer = calculateInterest(account, noOfYear);
System.out.format("%.3f",answer);
}
public static double calculateInterest(Account account, int noOfYear)
{
double temp = noOfYear * account.getInterestRate() / 100;
return (account.getBalance() * (account.getInterestRate()+temp) / 100);
}
}
class Account {
private int id;
private double balance;
private double interestRate; 
Account(int id, double balance, double interestRate) {
this.id = id;
this.balance = balance;
this.interestRate = interestRate;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return this.balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getInterestRate() {
return this.interestRate;
}
public void setInterestRate(double interestRate) {
this.interestRate = interestRate;
}
}
Careful Cat

Convertir le code Java en Python en ligne

package stringWala;
import java.util.Scanner;
public class String3 {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String next="";
        System.out.println("Enter the string");       
        String abc= sc.nextLine();
        int lenght =abc.length();
        if(lenght<=1){
            next=abc;
        }
        else{
            for (int i=0;i<lenght;i++){
                next=next+abc.charAt(0)+abc.charAt(1);
            }
        }
        System.out.print(next);
    sc.close();
    }
    }
puja Samai

Convertir le code Java en Python en ligne

package stringWala;
public class String12 {
    public static void main(String[] args) {
        String a,c="";
        int b,len;
        b=Integer.parseInt(args[1]);
        len=args[0].length();
        a=args[0];
        len=len-b;
        for(int i= 0;i<b;i++)
        {
            c=c+a.substring(len);
        }
        System.out.println(c);
    }
}

puja Samai

Convertir le code Java en Python en ligne

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

public class TestMultipleThreads {

	@Test(invocationCount = 5)
	public void loadTestThisWebsite() {

		WebDriver driver = new FirefoxDriver();		
		driver.get("http://www.google.com");
		System.out.println("Page Title is " + driver.getTitle());
		Assert.assertEquals("Google", driver.getTitle());
		driver.quit();

	}
}
Vardhaman Kothari

Convertir le code Java en Python en ligne

public static long countMax(List<String> upRight) {
    // Write your code here
    int xl = 1;
    int yl = 1;

    xl = Integer.parseInt(upRight.get(1).split(" ")[0]);
    yl = Integer.parseInt(upRight.get(1).split(" ")[1]);

    for (int i=0; i<upRight.size(); i++){
        if (xl > Integer.parseInt(upRight.get((int) i).split(" ")[0]) ) xl = Integer.parseInt(upRight.get((int) i).split(" ")[0]);
        if (yl > Integer.parseInt(upRight.get((int) i).split(" ")[1])) yl = Integer.parseInt(upRight.get((int) i).split(" ")[1]);
    }

    return (yl * xl);
}
Innocent Iguana

Convertir le code Java en Python en ligne

package com;
public class ToyDemo {
public static void main(String[] args) {
Toy one=new Toy("Banana","fruit",100,10.5);
Toy two=new Toy("Orange","fruit",300,30);
Toy three=new Toy("Lion","animal",50,5);
Toy four=new Toy("Tiger","animal",70,7);
System.out.println(getLeastPriceToy(one, two, three, four,"fruit"));
System.out.println(getLeastPriceToy(one, two, three, four,"animal"));
}
public static String getLeastPriceToy(Toy one, Toy two, Toy three, Toy four,
String category) {
Toy ansToy = one;
if(two.getCategory().equals(category) &&
(two.getPrice()*two.getDiscount())<(ansToy.getPrice()*ansToy.getDiscount())){
ansToy =two;
}
if(three.getCategory().equals(category) &&
(three.getPrice()*three.getDiscount())<(ansToy.getPrice()*ansToy.getDiscount())){
ansToy =three;
}
if(four.getCategory().equals(category) &&
(four.getPrice()*four.getDiscount())<(ansToy.getPrice()*ansToy.getDiscount())){
ansToy =four;
}
return ansToy.getName();
}
}
Careful Cat

Convertir le code Java en Python en ligne

import java.util.Scanner;

public class KboatClothDiscount
{
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter total cost: ");
        double cost = in.nextDouble();
        double amt;
        
        if (cost < 2000) {
            amt = cost - (cost * 5 / 100.0);
        }
        else if (cost < 5000) {
            amt = cost - (cost * 25 / 100.0);
        }
        else if (cost < 10000) {
            amt = cost - (cost * 35 / 100.0);
        }
        else {
            amt = cost - (cost * 50 / 100.0);
        }
        
        System.out.println("Amount to be paid: " + amt);
        
    }
}
Inexpensive Impala

Convertir le code Java en Python en ligne

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!"); 
    }
}
Cruel Cow

Réponses similaires à “Convertir le code Java en Python en ligne”

Questions similaires à “Convertir le code Java en Python en ligne”

Plus de réponses similaires à “Convertir le code Java en Python en ligne” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code