Write Python code for this problem The Python random module has functions that can be used to
Fantastic news! We've Found the answer you've been seeking!
Question:
Write Python code for this problem
Transcribed Image Text:
The Python random module has functions that can be used to generate random numbers For example the randint function can be used to generate random integers within a specified range, e.g. 1 import random 2 a_randint random.randint (1, 10) 3 print (a_randint) = will generate a random integer, a_randint, within the range [1,10]. If you run the code repeat- edly, using a for loop, you can generate as many numbers as you want. Your task is to, a) Use randint to generate a list of 100 random integers between 1 and 10. b) Write the integers to a text file. c) Open the file, read the integers into an array (i.e. a list). d) Print the average of the integers. Note: use intrinsic functions to compute the average. Hint: what is the definition of average? The Python random module has functions that can be used to generate random numbers For example the randint function can be used to generate random integers within a specified range, e.g. 1 import random 2 a_randint random.randint (1, 10) 3 print (a_randint) = will generate a random integer, a_randint, within the range [1,10]. If you run the code repeat- edly, using a for loop, you can generate as many numbers as you want. Your task is to, a) Use randint to generate a list of 100 random integers between 1 and 10. b) Write the integers to a text file. c) Open the file, read the integers into an array (i.e. a list). d) Print the average of the integers. Note: use intrinsic functions to compute the average. Hint: what is the definition of average?
Expert Answer:
Answer rating: 100% (QA)
import random file opennumberstxtw for x in range100 n randomrandint110 filewritestrn fileclose f... View the full answer
Related Book For
Essentials Of Statistics For Business And Economics
ISBN: 9781111533847
6th Edition
Authors: David R. Anderson, Dennis J. Sweeney, Thomas A. Williams
Posted Date:
Students also viewed these electrical engineering questions
-
Write a Python Code for this Problem: A grounded sphere of 2 mm radius is placed in the centre of a 10mm x 10mm x 10mm box. 5 point charges, -2C, -1C, 1C, 2C, 3C are placed at random positions on the...
-
Write a Python code for this question: In the given set-up, plot the E fields inside both dielectrics if a. No charge is present in the interface. b. Charge is present in the interface (p, is nonzero...
-
Write a new code for this problem that satisfies this problem First, the user will input the numbers(integers) eg. 2,3,4,5,6 which the user want to arrange in the lexicographical order And the number...
-
TRUE OR FALSE. 6 POINTS EACH. (Always assume "Other things equal.") 1. In economics in the short run, a firm will have both fixed and variable resources. 2. In economics, the short run is defined as...
-
If the population of the United States suddenly grew because of a large immigration, what would happen to wages? What would happen to the rents earned by the owners of land and capital?
-
The circle graph below shows the percent of bachelors degrees awarded in 2012 in Business, Social Sciences and History, Health Professions, Psychology, Education, and other fields. In 2012, the...
-
Look over the Judicial Council form for an Abstract of Judgment in California, provided in Exhibit 18.2. Once you fill out the form, find out how you file and record it.
-
On January 1, 2010, Point Corporation acquired an 80% interest in Sharp Company for $2,000,000. At that time Sharp Company had capital stock of $1,500,000 and retained earnings of $700,000. The book...
-
Solve the logarithmic equation for x. (Enter your answers as a comma-separated list.) log3(x+3)-log3(x-3)= 3
-
The mileage (in 1,000s of miles) that car owners get with a certain kind of radial tire is a random variable Y having a lognormal distribution such that Y = eX, where X is normally distributed. Let...
-
Compute the payback period for an investment with the following net cash flows. (Round your answer to one decimal place.) Year Initial investment 12345 1. 2. 3. 4. 5. 6. Net Cash Flows per Year $...
-
HCl has a rotational constant of 10.59 cm1 and a vibrational constant of 2991 cm1. Part A Find the temperature, if there is one, at which the J = 0 and J = 1 rotational states have the same...
-
An ordinary flashlight is a very complicated instrument if we include the electrochemistry of the battery, the resistance of connections, and the thermodynamics of the bulb. What principles of...
-
Assume that Tamarisk Company received the balance due from Carla Vista Co. on January 2 of the following year instead of December 13. Prepare the journal entry to record the receipt of payment on...
-
A golfer on a fairway is 74 m from the green. The golfer hits a ball at an angle of 38.2 degrees above horizontal, with an initial speed of 17 m/s. The course is on a slope such that the ball lands...
-
The value of identifying purpose as it pertains to teamwork is a way to what ? Povide meaning and significance to the work delineate personal goals from organizational goals require team members to...
-
2. The graph below represents our choices between the production of food and biofuels as discussed in the news article "Fuel v. Food" (Files-News Articles-Basic Econ Concepts). Q Food (tons) 22 20 18...
-
Explain why each of the following is either a private good or a public good: traffic lights, in line skates, a city park, a chicken salad sandwich, a tennis racket, national defense, a coastal...
-
Some of the best-known food franchises and the number of retail locations for each are shown in the following table (The New York Times Almanac, 2010). a. What is the largest franchise? How many...
-
Fortune magazine publishes an annual list of the 500 largest companies in the United States. The following data show the five states with the largest number of Fortune 500 companies (The New York...
-
Roper ASW conducted a survey to learn about American adults' attitudes toward money and happiness (Money, October 2003). Fifty-six percent of the respondents said they balance their checkbook at...
-
The diameter, \(d\), of bubbles produced by a bubble-making toy depends on the soapy water viscosity, \(\mu\), density, \(ho\), and surface tension, \(\sigma\), the ring diameter, \(D\), and the...
-
Choked-flow nozzles are often used to meter the flow of gases through piping systems. The mass flow rate of gas is thought to depend on nozzle area \(A\), pressure \(p\), and temperature \(T\)...
-
Spin plays an important role in the flight trajectory of golf, ping-pong, and tennis balls. Therefore, it is important to know the rate at which spin decreases for a ball in flight. The aerodynamic...
Study smarter with the SolutionInn App