Programming Logic & Design Comprehensive
9th Edition
ISBN: 9781337669405
Author: FARRELL
Publisher: Cengage
expand_more
expand_more
format_list_bulleted
Question
Look at my previous code, can you help me with this question please.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 1 images
Knowledge Booster
Similar questions
- In [ ]: We obtained an array with N = 10 values, scattered about mean of 25 (mm). Let's calculate the mean, standard deviation, standard deviation of the mean and 20-uncertainty SL of these numbers. In the following code, do these steps: • In the first cell, add a brief comment that explains what each statement does. Start each comment with a # sign. • In the second cell, delete the raise Not ImplementedError() code line and print the standard deviation and 20-uncertainty on the screen (follow the example for mean_L) mean_L = np.mean (L) print("Mean length: ", mean_L) stddev_L = np. std (L, ddof=1) stddev_mean_L = stddev_L/np.sqrt(N) uncertainty_L = 2*stddev_mean_L In [ ] V #YOUR CODE HERE raise NotImplementedError() #calculates the mean of L In the above code, the green expressions on the right hand side, such as np.mean, np. std and np.sqrt are functions built into the numpy package of Python. The names on the left hand side are variable names invented by me.arrow_forwardPlease explain Consider the following array of twelve numbers: [6,5,6,5,1,7,7,5,1,5,7,3] For each of these twelve numbers, you may highlight them in dark red. You may highlight as many numbers as you wish. The only rule is that you are not allowed to highlight two adjacent numbers. In other words, if you highlight A[i], you cannot highlight A[i−1] or A[i+1]. Add up the numbers you've highlighted to produce your total score. For example, [6,5,6,5,1,7,7,5,1,5,7,3] gives me a total score of 6+6+1+7+1+3=24. Can you do better? Determine the maximum possible score.arrow_forwardCreate a 4x3 array of letters from a through l and call it array1. Copy the array and call it array2, then reshape array2 to a 6x2 array. Create another copy of the array, called array3, and flatten it into a one-dimensional array. Print all three arrays.arrow_forward
- Note: Set a random seed of 100 for this assignment. All arrays should contain random numbers between 0 and 1 (zero is inclusive). Create a one-dimensional array of twenty float random numbers. Assign the sum of these values to Q1. Assign the max of these values to Q2. Create a four by five array of random numbers. Take the minimum values in each array and create an array of those values. Assign it to Q3. Assign the mean of all the array values to Q4. Create an array with the following values: 2, 3, np.nan (this should represent a missing value), and 5. Use a numpy function to find the sum of the values in this array. Assign the sum to Q5 (you should expect a numerical value here). Create two separate arrays each containing four random numbers. Concatenate the two arrays and assign it to Q6. Create a four by four array of random numbers and call it q7. Concatenate this array with itself and assign it to Q7. Create a two by four array of…arrow_forwardBackground: This assignment will help you further learn to use multidimensional arrays. You will need a 10x2 matrix for this problem. Consider 10 points on a map, You need to identify the distance between each point (or vertex). A vertex requires two pieces of information. An x,y coordinate (think longitude and latitude.) This is why you have a matrix of 10x2, each entry is the two values you will need. You can think of these points a cities, or friend's houses. We're only looking for a direct route (as the crow flies) not taking roads to make it simpler. You can find the distance between any two points by use of: sqr_root((x1 - x2)^2 + (y1 - y2)^2) You will need to fill your matrix with some random values. Then you will need to calculate the distance between each possible point, eventually displaying it on a matrix in output. Think something like: 1 2 3 4 5 1 0 8 12 4 6 2 8 0 7 .... 3 12 7 .... 4 4 ... 5 6 ... Hint:…arrow_forwardGiven an 8-element array: A = {x1, X2, X3, X4, X5, X6, 7, x8}, we would like to find its 3rd smallest element. It is known that x₁ and 8 are the two extreme elements: max and min, but we do not know which one is the max and which one is the min. It is also known that x4 and x5 are the two medians: left-median and right-median. What is the minimum number of comparisons you need to find the 3rd smallest element of the original array? Ans:arrow_forward
- "John is very interested in history and all the generations of his family. He does a lot of research and realizes that he is descended from the great Mayan dynasty. After a lot of searching through ancient records and the latest records of the society, he is able to find out all the parent-child relationships in his family all the way from the great emperor Ming of the dynasty to himself These relationships are given in the form of a linear array where the emperor is at the first position and his children are at pos (2i + 1) and (2i + 2) Subject: Java Programming This is the pattern followed throughout. Henry wants to figure out all the siblings of the person X from the data. Return the sorted list of all of john's siblings. If no sibling return {-1} input 1: N, the length of the arrayinput2: An array representing the ancestral treeinput 3: X, the person whose siblings are sought. output - return the array of all siblings in increasingly sorted order. Examples : input…arrow_forward//1. Declare an array arr1 and initialize it to 1, 2, 3, 4, 5, 6, 7, 8, and 9//2. Declare another array arr2, the same length as arr1, without// giving it any initial values.//3. Using a for loop print arr1 displaying all elements on one line,// separated by a comma. (Commas must be placed only between numbers.)//4. Using a while loop print arr2 displaying all elements on one// line, separated by a dash. (Dashes must be placed only between numbers.)//5. Using a for loop, copy all the values of arr1 into arr2 in reverse// order. DO NOT print on this step.//6. Using a do/while loop, print arr1 displaying all elements on// one line, separated by a comma.//7. Using a for loop, print arr2 displaying all elements on one line,// separated by a dash.arrow_forwardUse a one-dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the array only if it is not a duplicate of a number already read. After reading all the values, display only the unique values that the user entered. Provide for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem.arrow_forward
- Create an array of 15 integers. Add all elements located at ODD index positions and sum also all numbers located at EVEN(Assume zero index is even) index positions in the linear array. The user will be the one to input each item in the array of 15 elements. Display also the inputted integers in the array. Given the sample layout w/ test data below:arrow_forwardSelect true or false for the statements below. Explain your answers if you like to receive partial credit Select true or false for the statements below. Explain your answers if you like to receive partial credit Which of the following is true about searching elements in an unordered array? With the data is unsorted, search is O(n) because if the element you are looking for is not there, you have to check every element in the array If you start at the end of the array and traverse to index 0, search improves to O(log n) because you only have to look at half of the array If you get lucky with checking the first element and find it immediately, then the worst case performance of search improves to O(n^2) Which of the following is true about searching elements in an ordered array? You cannot use binary search on an ordered array so the performance is O(n) If there are no holes in the array and the elements are all next to each other, then the performance for search improves to…arrow_forward2. Use a two-dimensional (double-subscripted) array to solve the following problem: A company has four salespeople who sell five different products. Let each salesperson represent a row of your array and each product a column. You now have a 4 x 5 array. Once a day, each salesperson submits a slip for each different type of product he or she sold. Each slip contains: The salesperson’s number (1 to 4) (use this to get row subscript) The product number (1 to 5) (use this to get column subscript) The total dollar value of that product sold that day Thus, each salesperson submits from 0 to 5 sales slips per day (0, if they made no sales that day; and 5, if they sold every product that day). Your program will read a file that contains the information from all of the sales slips for the last month. Read until EOF. The file is named "productSales.txt". You need to create this file with at least 10 entries. Remember that the first number is the salesperson, the second number is the product,…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,