Covert the following Java program to a Python program:
import java.util.Scanner;
/** * Displays the average of a set of numbers */
public class AverageValue {
public static void main(String[] args) {
final int SENTINEL = 0;
int newValue; int numValues = 0;
int sumOfValues = 0; double avg;
Scanner input = new Scanner(System.in);
/* Get a set of numbers from user */
System.out.println("Calculate Average Program");
System.out.print("Enter a value (" + SENTINEL + " to quit): ");
newValue = input.nextInt();
while (newValue != SENTINEL) {
numValues += 1;
sumOfValues += newValue;
System.out.print("Enter a value(" + SENTINEL + " to quit): ");
newValue = input.nextInt();
}
input.close();
/*Calculate average of numbers entered by user */
avg = (double)sumOfValues / (double)numValues;
System.out.println("Average is " + avg);
}
}
// If any doubt please comment
Get Answers For Free
Most questions answered within 1 hours.