How do I change this java code into a python code? And output the desired output shown in the image below. import java.util.*; public class Demo { public static void main(String[] args) { Scanner sc=new Scanner(System.in); long min=Integer.MAX_VALUE; long max=Integer.MIN_VALUE; long sum=0; int ignoreCount=0, numberCount=0; while(true){ System.out.print("Please enter an integer value: "); String s=sc.next(); try { long n=Long.parseLong(s); if(n<0) break; else if(n<0 || n>2000000000) ignoreCount++; else{ if(nmax) max=n; sum += n; numberCount++; } } catch(Exception e){ ignoreCount++; } } System.out.println("The highest value is "+max); System.out.println("The lowest value is "+min); System.out.println("The avergae value is "+sum/numberCount); System.out.println(ignoreCount+" entry was ignored"); } }
How do I change this java code into a python code? And output the desired output shown in the image below.
import java.util.*;
public class Demo {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
long min=Integer.MAX_VALUE;
long max=Integer.MIN_VALUE;
long sum=0;
int ignoreCount=0, numberCount=0;
while(true){
System.out.print("Please enter an integer value: ");
String s=sc.next();
try {
long n=Long.parseLong(s);
if(n<0)
break;
else if(n<0 || n>2000000000)
ignoreCount++;
else{
if(n<min)
min=n;
if(n>max)
max=n;
sum += n;
numberCount++;
}
}
catch(Exception e){
ignoreCount++;
}
}
System.out.println("The highest value is "+max);
System.out.println("The lowest value is "+min);
System.out.println("The avergae value is "+sum/numberCount);
System.out.println(ignoreCount+" entry was ignored");
}
}
![Please enter an integer value: 5
value: 15
Please enter an integer
Please enter an integer value: 3
Please enter an integer value: a
Please enter an integer value: 20
Please enter an integer value: 5
Please enter an integer value: -1
The highest value is 20
The lowest value is 3
The avergae value is 9
1 entry was ignored](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fea56b2d3-976b-48ba-b1de-ef5a4d536379%2F472c1fc4-1caa-4a50-bbed-300f26f54f5f%2Faqg8nfn_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)