Question

Write a python code that calculates the mean and median of a sample of 100 uniform...

Write a python code that calculates the mean and median of a sample of 100 uniform random numbers between 0 and 2 and the percentage of points in the sample that are greater than 1.

Homework Answers

Answer #1

Required Python Code:

import random 
import numpy
def Rand(start, end, num): 
    res = [] 
    for j in range(num): 
        res.append(random.uniform(start, end)) 
    return res 
res = Rand(0, 2, 100)
print("Mean of 100 random uniform numbers between 0 and 2 is ", numpy.mean(res))
print("Median of 100 random uniform numbers between 0 and 2 numbers is ", numpy.median(res))
percentage = 0
for i in res : 
    if i > 1 : 
        percentage = percentage + 1
print("Percentage of numbers greater than 1 is ", percentage, "%")

SAMPLE OUTPUT:

Know the answer?
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
Similar Questions
Python code Write a complete program with for loop which calculates the sum of the numbers...
Python code Write a complete program with for loop which calculates the sum of the numbers from 1 to 100
# Python Given the list values = [], write code that fills the list with each...
# Python Given the list values = [], write code that fills the list with each set of numbers below. Note: use loops if it is necessary 1 2 3 4 5 6 7 8 9 10 0 2 4 6 8 10 12 14 16 18 20 1 4 9 16 25 36 49 64 81 100 0 0 0 0 0 0 0 0 0 0 1 4 9 16 9 7 4 9 11 0 1 0...
- Write a python program which prints all the numbers between 1 and 100 that are...
- Write a python program which prints all the numbers between 1 and 100 that are divisible by 3.
****CODE IN PYTHON***** (Please replicate it EXACTLY as it is shown in the sample run) Write...
****CODE IN PYTHON***** (Please replicate it EXACTLY as it is shown in the sample run) Write a program where the user and the program/computer play a number guessing game. The program should prompt the user for a number (between 1 and 100, inclusive) then the program/computer has to guess what the user entered. Keep track of the number of iterations it takes for the computer to guess the number. Sample runs are shown below: Enter number to be guessed: 88...
Write a python code that will ask the user to enter an integer number n. Construct...
Write a python code that will ask the user to enter an integer number n. Construct a recursive function that prints numbers 1 to n in the form “11223344..nn”.
in Python Write a code fragment that prints true if the double variables x and y...
in Python Write a code fragment that prints true if the double variables x and y are both strictly between 0 and 1and false otherwise.
WRITE it in Python! how to Write a method named smallest largest that asks the user...
WRITE it in Python! how to Write a method named smallest largest that asks the user to enter numbers, then prints the smallest and largest of all the numbers typed in by the user. You may assume the user enters a valid number greater than 0 for the number of numbers to read. Here is an example dialogue: How many numbers do you want to enter? 4 Number 1: 5 Number 2: 11 Number 3: -2 Number 4: 3 Smallest...
[10 marks] (SumDigits.java) Write code that asks the user to enter an integer between 100 and...
[10 marks] (SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The program finds and displays the three digits in the number. The program also calculates and displays the sum of the three digits. A sample run is shown below: Enter a number between 100 and 999: 528 The three digits in the number are: 5 2 8 The sum of the three digits is: 15
Write a Python program which calculates the average of the numbers entered by the user through...
Write a Python program which calculates the average of the numbers entered by the user through the keyboard. Use an interactive loop and ask the user at each iteration if he/she wants to enter more numbers. At the end dispay the average on the screen. Using built-in library functions for finding average is not allowed. Sample output of the program: Enter a number > 23 More numbers (yes or no)? y Enter a number > 4 Do you have more...
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED....
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED. ALSO THE 2 POINTS MENTIONED BELOW SHOULD BE PRESENT IN THE CODE Write a script that calculates the 3 longest words of a text stored in a file and print them from the longest to the smaller of the 3. Please note: 1. The name of the file is word_list.csv and it doesn’t need to be asked to the user (meaning the name will...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT