Question

About Python 3 I want to make calculation data saved as array form So I want...

About Python 3

I want to make calculation data saved as array form

So I want code like this

i=0

while i<10

x=(mean of 20 random sampled numbers)

save x to array A

i=i+1

print(A)

so I expect A=[x1,x2,x3,x4,x5,...,x10]

How can I do this?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

import random

def meanRandomNumbers(): # function which generates 20 random numbers between 1 to 100 and then findng that average(mean)

sum_=0
  
for i in range (0,20): #iterate loop to generate 20 random numbers
  
sum_=sum_+random.randint(1,100) #add number to sum_

return sum_/20 #return the average
  
i=0 #declare variable i

A=[] #declare a list A

while i<10: #iterate loop till i value < 10
  
x=meanRandomNumbers() #finding mean of random numbers
  
A.append(x) #append x value to array or list A
  
i+=1 #increment i value

print(A) #print A values

Code and Output Screenshots:

1 import random 3 # function which generates 20 random numbers between 1 to 100 and then findng that average (mean) def meanR

Explanation:

Here we have created a function meanRandomNumbers() it will generate 20 random numbers and will return mean value and that will be appending to List A.

Note: if you have any queries please post a comment thanks a lot..always avialble to help you...

Add a comment
Know the answer?
Add Answer to:
About Python 3 I want to make calculation data saved as array form So I want...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • LANGUAGE IS JAVA CALCULATOR USING SCIENTIFIC/STANDARD MODE ERRORS: ADDITION AND DIVISION NOT WORKING FOR EITHER CALCULATOR...

    LANGUAGE IS JAVA CALCULATOR USING SCIENTIFIC/STANDARD MODE ERRORS: ADDITION AND DIVISION NOT WORKING FOR EITHER CALCULATOR CODE: import java.util.Scanner; public class CalculatorProject { public static void main (String[] args) { Scanner yurr = new Scanner(System.in);    String mode; double i; String choice; String answer = "Y"; while (answer.equals("Y")) { System.out.println("Enter the calculator mode: Standard/Scientific?"); mode = yurr.next(); if(mode.equals("Scientific")) { System.out.print("Enter '+' for addition, '-' for subtractions, '*' for multiplication, '/' for division, 'sin' for sin x, 'cos' for cos x,...

  • Python, I need help with glob. I have a lot of data text files and want...

    Python, I need help with glob. I have a lot of data text files and want to order them. However glob makes it in the wrong order. Have: data00120.txt data00022.txt data00045.txt etc Want: data00000.txt data00001.txt data00002.txt etc Code piece: def last_9chars(x):     return(x[-9:]) files = sorted(glob.glob('data*.txt'),key = last_9chars) whole code: import numpy as np import matplotlib.pyplot as plt import glob import sys import re from prettytable import PrettyTable def last_9chars(x):     return(x[-9:]) files = sorted(glob.glob('data*.txt'),key = last_9chars) x = PrettyTable() x.field_names =...

  • LAB 4: JavaScript Loops Part I) 1) Make an array of colors, instead of responses, call...

    LAB 4: JavaScript Loops Part I) 1) Make an array of colors, instead of responses, call it colors. Color names go inside quotes, i.e. "red". 2) Copy the line of the var randomNum, but instead of looking at the length of responses, look at the length of your colors array. 3) Declare a variable myColor below the randomNum variable declaration. 4) Save a randomly chosen color into the variable myColor.     colors[randomNum] picks a random color from the array. Save...

  • Using Python 3, is there a way I could find the second_highest value of a user's...

    Using Python 3, is there a way I could find the second_highest value of a user's random input using a while-loop? For example, if I use random input numbers such as: 100,95,92,87,83,80,75,50,40 etc. I want it to compute the 2nd highest along with my highest and lowest score. Is there any if, else, elif, etc statement that I could add to my while statement or in my while-loop to make this happen? The output would be something like highest =...

  • I have a python project that requires me to make a password saver. The major part...

    I have a python project that requires me to make a password saver. The major part of the code is already giving. I am having trouble executing option 2 and 3. Some guidance will be appreciated. Below is the code giving to me. import csv import sys #The password list - We start with it populated for testing purposes passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] #The password file name to store the passwords to passwordFileName = "samplePasswordFile" #The encryption key for the caesar...

  • Python Problem Hello i am trying to finish this code it does not save guesses or...

    Python Problem Hello i am trying to finish this code it does not save guesses or count wrong guesses. When printing hman it needs to only show _ and letters together. For example if the word is amazing and guess=a it must print a_a_ _ _ _ not a_ _ _ _ and _a_ _ _ separately or with spaces. The guess has a maximum of 8 wrong guesses so for every wrong guess the game must count it if...

  • Assignment:Super Lotto This exercise is JavaScript only. No jQuery, please. Your page should work as follows: Ask the user the highest number that they want to generate. (Some lotteries are 1 ‐ 47, so...

    Assignment:Super Lotto This exercise is JavaScript only. No jQuery, please. Your page should work as follows: Ask the user the highest number that they want to generate. (Some lotteries are 1 ‐ 47, some 1 ‐ 49, etc.) Ask the user how many numbers they want to generate. Create a function that returns a random number between 1 and the highest number (see "Additional Info" below). Create an array of numbers. Run the function the correct number of times, putting...

  • C++ i want Lab#3 done can u make clear code so I could understand it. Lab#2The...

    C++ i want Lab#3 done can u make clear code so I could understand it. Lab#2The objective of this lab is compare the populations of various cities that lie in between Toledo and Dayton on I-75. Write a program that produces a bar illustrating the populations. The program should read the name of the city and its population from a file. Have the program continue this process until the end of file is reached. For each city, your program should...

  • how to make my code of python work probely my q is how to write a...

    how to make my code of python work probely my q is how to write a code to find the average actual water level, average error by using python and my program should be flexible where user can select the column no. If you can see in the main program, it asked which column to know the maximum or average, the column number is passed to the function. The function should look which column to do. #THIS PROGRAMMING IS ABLE...

  • Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such...

    Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such as declaration, initialization, storing, retrieving, and processing elements. • Effectively manipulating and using ArrayList objects. • Becoming familiar with the use of arrays as method arguments and how array elements are passed to and returned from the called method. • Mastering the use of various debugging tools available on the Eclipse IDU. Important: EVERY one of the following Activities MUST be in a separate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT