Python Code
Write a program using functions and mainline logic which prompts the user to enter a number. The number must be at least 5 and at most 20. (In other words, between 5 and 20, inclusive.) The program then generates that number of random integers and stores them in a list. The random integers should range from 0 to 100. (You can use a wider range if you want, but the lower end of the range must be at most 0 and the upper end of the range must be at least 100.) It should then display the following data to back to the user with appropriate labels:
Here is the code with a screenshot:
import random
def findMin(a):
#initialize the minimum
minEl = a[0]
for el in a:
#if current element is smaller
if el < minEl:
#update the minimum
minEl = el
return minEl
def findMax(a):
#initialize the maximum
maxEl = a[0]
for el in a:
#if current element is larger
if el > maxEl:
#update the maximum
maxEl = el
return maxEl
def findSum(a):
#initialize the sum
totalSum = 0
for el in a:
#accumulate the elements
totalSum += el
return totalSum
def findAvg(a):
return findSum(a)/len(a)
#get user input
nEls = int(input("Please input the number of elements: "))
if nEls < 5 or nEls > 20:
print("Please enter a number between 5 and 20")
exit()
#generate the numbers
nums = []
for i in range(nEls):
nums.append(random.randint(0,100))
print("The elements:", nums)
print("Minimum:", findMin(nums))
print("Maximum:", findMax(nums))
print("Sum of elements:", findSum(nums))
print("Average of elements:", findAvg(nums))
![import random def findMin(a): #initialize the minimum minel = a[0] for el in a: #if current element is smaller if el < minEl:](http://img.homeworklib.com/questions/1ac772b0-87a0-11eb-8abb-2d08d5391b1e.png?x-oss-process=image/resize,w_560)

Here are some sample outputs:
![Please input the number of elements: 9 The elements: [82, 36, 72, 79, 25, 42, 93, 7, 22] Minimum: 7 Maximum: 93 Sum of elemen](http://img.homeworklib.com/questions/1ba2e5c0-87a0-11eb-b20d-21687a6991e4.png?x-oss-process=image/resize,w_560)
Comment in case of any doubts.
Python Code Write a program using functions and mainline logic which prompts the user to enter...
Can you help me write a Python 3.7 code for this question? Write a program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a list. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The...
(Python Programming)Write a Python program that prompts the user to enter a list of words and stores in a list only those words whose first letter occurs again within the word (for example, 'Baboon'). The program should display the resulting list.
Design a Python program that prompts the user to enter "yes" or "no" and validates the input. (Use a case-insensitive comparison) and another Python program that prompts the user to enter a number in the range of 1 through 100 and validates the input
Write a program that prompts the user to enter a number within the range of 1 to 10 inclusive. The program then generates a random number using the random class: If the users guess is out of range use a validation loop (DO) to repeat the prompt for a valid number, If the users guess matches the random number tell them they win! If the users guess does not match the random number tell them they are wrong. Use a...
USING PYTHON - Write a program that calls a function that prompts the user to enter a real number. The function should verify that the user entered a valid real number, and should prompt the user to re-enter any invalid input. After a valid real number has been entered, the function should return the number as a number. To test your function, from a main function, call the function two separate times and print the sum of the two numbers...
(Same-number subsequence) Write an O(n) program in python that prompts the user to enter a sequence of integers and finds longest subsequence with the same number. Here is a sample run of the program: <Output> Enter a series of numbers ending with 0: 2 4 4 8 8 8 8 2 4 4 0 The longest same number sequence starts at index 3 with 4 values of 8 <End Output>
Python 3 **11.40 (Guess the capitals) Write a program that repeatedly prompts the user to enter a capital for a state. Upon receiving the user input, the program reports whether the answer is correct. Assume that 50 states and their capitals are stored in a two- dimensional list, as shown in Figure 11.13. The program prompts the user to answer all the states’ capitals and displays the total correct count. The user’s answer is not case sensitive. Implement the program...
Java: Write a program that prompts the user to enter integers in the range 1 to 50 and counts the occurrences of each integer. The program should also prompt the user for the number of integers that will be entered. As an example, if the user enters 10 integers (10, 20, 10, 30, 40, 49, 20, 10, 25, 10), the program output would be: 10 occurs 4 times 20 occurs 2 times 25 occurs 1 time 30 occurs 1 time...
c++
program
Exercise #1: Index of the Minimum Write a function main() that prompts the user to input a positive integer n, then calls the function generate() which generates n random numbers in the range [11, 217] inclusive. The function main() also calls the function indexMin() which finds the smallest random number and its index. The function main() prints the random numbers and the two values produced by the function indexMin(). Sample input/output: How many integers: 9 The 9 random...
question 2 in C programming please
PE-05b-01 (Six-sider) write a counter-controlled program that prompts the user to enter the number of times n to roll a six-sided die. The program should print to the screen the iteration of the loop and result for each roll 1 ) How many times would you like to roll? 3 roll 6 6 5 1 2) PE 05b 02 (Flash Cards) Write a counter-controlled program that creates addition problems for an elementary kid to...