How can I modify my program to accept a list of integers (up to 20 entries) from the user into a list and prints the numbers entered by the user in ascending order, their sum and their average. The program then stops when the user inputs -100 as a number to search.
#function that returns largest number
def max(numOne,numTwo,numThree):
if(numOne > numTwo and numOne > numThree):
return numOne
elif(numTwo > numOne and numTwo > numThree):
return numTwo
elif(numThree > numOne and numThree > numTwo):
return numThree
#function that returns middle number
def mid(numOne,numTwo,numThree):
if(numOne < numTwo and numThree > numTwo):
return numTwo
elif(numOne < numThree and numTwo > numThree):
return numThree
elif(numTwo < numOne and numThree > numOne):
return numOne
elif(numTwo < numThree and numOne > numThree):
return numThree
elif(numThree < numOne and numTwo > numOne):
return numOne
elif(numThree < numTwo and numOne > numTwo):
return numTwo
#function that returns smallest number
def min(numOne,numTwo,numThree):
if(numOne < numTwo and numOne < numThree):
return numOne
elif(numTwo < numOne and numTwo < numThree):
return numTwo
elif(numThree < numOne and numThree < numTwo):
return numThree
#function that calculates the sum
def sum(numOne,numTwo,numThree):
sumOfThree = int(numOne + numTwo + numThree)
return sumOfThree
#function that calculates average
def avg(numOne,numTwo,numThree):
average = ((numOne + numTwo + numThree)/3)
return average
#start of main
#prompts user for 3 numbers
numOne = int(input("Enter 1st number: "))
numTwo = int(input("Enter 2nd number: "))
numThree = int(input("Enter 3rd number: "))
print("You just entered 3 integers:", numOne, numTwo,
numThree)
#loop that will exit and quit the program once the user enters -7
as their first number
while (numOne != -7):
#condition to print if all three numbers are equal
if(numOne == numTwo == numThree):
print ("These 3 integers in order
are",numOne,numTwo,numThree)
else:
print ("These 3 integers in order are",
min(numOne,numTwo,numThree),
mid(numOne,numTwo,numThree), max(numOne,numTwo,numThree))
print("Their sum is", sum(numOne,numTwo,numThree), "and their
average is",
avg(numOne,numTwo,numThree))
numOne = int(input("\nEnter your 1st number: "))
numTwo = int(input("Enter your 2nd number: "))
numThree = int(input("Enter your 3rd number: "))
print("You just entered 3 integers:", numOne, numTwo,
numThree)
#end of main
Here is code:
def printArray(array):
for i in array:
print(i," ",end=' ')
print()
#function that calculates the sum
def sum(array):
total = 0
for i in array:
total += i
return total
#function that calculates average
def avg(array):
return (sum(array)/len(array))
#start of main
data = []
while(True):
#prompts user for 3 numbers
num = int(input("Enter number (-100 to quit): "))
if(num == -100):
break
data.append(num)
if(len(data) == 20):
break
print("you have entered : ")
printArray(data)
data.sort()
print("ascending order : " )
printArray(data)
print("Their sum is", sum(data), "and their average is",
avg(data))
#end of main

Output:

How can I modify my program to accept a list of integers (up to 20 entries)...
Please provide pseudocode for the following python program: class Student: def t(self,m1, m2, m3): tot= m1+m2+m3; average = tot/3; return average class Grade(Student): def gr(self,av): if av>90: print('A grade') elif (av<90) and (av>70): print('B grade') elif (av<70) and (av>50): print('C grade') else: print('No grade') print ("Grade System!\n") s=Student(); repeat='y' while repeat=='y': a=int(input('Enter 1st subject Grade:')) b=int(input('Enter 2nd subject Grade:')) c=int(input('Enter 3rd subject Grade:')) aver=s.t(a,b,c); g=Grade(); g.gr(aver); repeat=input("Do you want to repeat y/n=")
Please write a C++ program that will accept 3 integer numbers from the user, and output these 3 numbers in order, the sum, and the average of these 3 numbers. You must stop your program when the first number from the user is -7. Design Specifications: (1) You must use your full name on your output statements. (2) You must specify 3 prototypes in your program as follows: int max(int, int, int); // prototype to return maximum of 3 integers...
**how can I make my program break if 0 is entered by user as last number not always 10 numbers output should be enter 10 numbers:1 2 0 numbers entered by user are: 1 2 Largest number: 2 **arrays can ONLY be used in the main function, other than the main function pointers should be used #include #define N 10 void max(int a[], int n, int *max); int main (void) { int a [N], i , big; printf("enter %d numbers:",N);...
Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...
In Java*
Write a program that reads an arbitrary number of 20 integers that are in the range 0 to 100 inclusive. The program will ask a user to re-enter an integer if the user inputs a number outside of that range. The inputted integers must then be stored in a single dimensional array of size 20. Please create 3 methods: 1. Write a method public static int countEven(int[] inputArray) The method counts how many even numbers are in...
In
c++ programming, can you please edit this program to meet these
requirements:
The program that needs editing:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int cal_avg(char* filenumbers, int n){
int a = 0;
int number[100];
ifstream filein(filenumbers);
if (!filein) {
cout << "Please enter a a correct file to read in the
numbers from";
}
while (!filein.eof()) {
filein >> number[a];
a++;
}
int total = number[0];
for (a = 0; a < n; a++) {...
Python: Create a function count_target_in_list that takes a list of integers and the target value then counts and returns the number of times the target value appears in the list. Write program in that uses get_int_list_from_user method to get a list of 10 numbers, then calls the count_target_list method to get the count then prints the number of times the target was found in the list. def get_int_list_from_user(): lst=[] y = int(input("Enter number of numbers")) for x in range(y): lst.append(int(input("Enter...
C++
Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...
I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...
Can you please Test and debug the program below using the following specifications? Many thanks! Create a list of valid entries and the correct results for each set of entries. Then, make sure that the results are correct when you test with these entries. Create a list of invalid entries. These should include entries that test the limits of the allowable values. Then, handle the invalid integers (such as negative integers and unreasonably large integers). In addition, make sure the...