Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.1 1.2 1.3 Generate a list of 300 random values in the range 1-99. Determine, print, and remove duplicate values of numbers from the list

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed1.1
image text in transcribed1.2
image text in transcribed1.3
image text in transcribed
Generate a list of 300 random values in the range 1-99. Determine, print, and remove duplicate values of numbers from the list that appears more than 2 times. Your program should print sorted original list generated randomly. (Ex: (1,1,4,4,4,5,6,6,10,10,10,10)) duplicate values that appear more than 2 times, and (Ex : [4,4,4,10,10,10,10)) the list without duplicates that appear more than 2 times. (Ex: (1,1,5,6,6]) (Hint: you many want to sort the list first.) Write the missing functions myAverage, ny StandardDev, win, and myCorrelation in the following code. The formulas for average (mean), standard deviation and correlation are given below. no deviation PI import math import randon def my Avearage (ist): def syStandard Dev(1st): def myMin(st): def wyCorrelation(x, y): def main(): alist - [11, 20, 30, 50, 80, 90, 181, 15, 125, 128, 15e, 185, 280, 248, 260, 290) blist - (14, 25, 28, 45, 79, 85, 121, 115, 125, 256, 160, 195, 230, 270, 280, 330] Chist. blist.copy clist.reverse() dList. [randon.rand int(1,99) for x in range(len(alist))] print("Lists:") print("List Astralist)) print("list " + str(blist)) print("List Costr(clist)) print("List D."str(dList)) print() print("List A Average " + str(ayAvearagealist))) print("standart Deviation of List Astrmystandardev (alist) print("Minimum of List Astr(myminalist))) print() print("List 8 Average = " + str(ayAvearage(alist))) print("Standart Deviation of List 8 str(myStandardDev(alist)>> print("Minimum of List .". str(myMinalist) >> print() print("Correlation of List A and B = str(myCorrelationalist, blist>>> print("Correlation of List A and Estr(nyCorrelationalist, clist))) print("Correlation of List A and D=" + str(myCorrelationalist, dlist>>> main() Write the missing functions myAverage, ny StandardDev, win, and myCorrelation in the following code. The formulas for average (mean), standard deviation and correlation are given below. no deviation PI import math import randon def my Avearage (ist): def syStandard Dev(1st): def myMin(st): def wyCorrelation(x, y): def main(): alist - [11, 20, 30, 50, 80, 90, 181, 15, 125, 128, 15e, 185, 280, 248, 260, 290) blist - (14, 25, 28, 45, 79, 85, 121, 115, 125, 256, 160, 195, 230, 270, 280, 330] Chist. blist.copy clist.reverse() dList. [randon.rand int(1,99) for x in range(len(alist))] print("Lists:") print("List Astralist)) print("list " + str(blist)) print("List Costr(clist)) print("List D."str(dList)) print() print("List A Average " + str(ayAvearagealist))) print("standart Deviation of List Astrmystandardev (alist) print("Minimum of List Astr(myminalist))) print() print("List 8 Average = " + str(ayAvearage(alist))) print("Standart Deviation of List 8 str(myStandardDev(alist)>> print("Minimum of List .". str(myMinalist) >> print() print("Correlation of List A and B = str(myCorrelationalist, blist>>> print("Correlation of List A and Estr(nyCorrelationalist, clist))) print("Correlation of List A and D=" + str(myCorrelationalist, dlist>>> main() In this question, you are going to write methods that operate on matrices. The program reads values of matrices A, B, and stored in a file called inputs.txt. This file should be placed under current directory where you have the program. The first line before each matrix contains the number of rows and the number of columns as shown below. Import randon Import sys Get readtrix ruberofrons underofColumns, tile): natrix.i.Cate antys for rox in range(berofus): matrix.open(t)) Anempty w now rowdata. (int(*) for in line.split("")) for column in rangenter of Columns) natrix[row).append(rondata[column)) return matrix del printmatrix(catrix): for ror in rangelen (matrix) for column in rangellenmatrix[ro])): print(format (natrix[row]column),"5"), end print() Printer time def Fellatrixdonly[underoftous, tuberofColumns ) natrix create onesty to for row in range(beroflow): matrix.end(11) Antyw for colum in rerumber of Columns): natrixtrow.opend randon.randintco. >>>> return atrix def generateZeroRate interfrows, rusterOfColumns): ") natraffer : tn range(number ofrot) or in range(number of Columns) ] return def ,6) c. generateromatrix (4), tento for row in rangellen(A)): for column in rangeltrow]>> ctronicelun] . Atrow][column][row column return #Redtrect standard output device (console) to output txt file #print statements will write to output.txt file sys.stdout .open('output.txt*, ') print("Wreating data from Inputs, txt file in current directory!) line fredline) unberotonerofColumns (int (for in the 911 , print("trix A printmatrix(A) ) uberoflors, berotolumns - fant) for 2 to 11.1918 Breadtrixbertos, nuber of Columns, print. Ratrix pritaria) teau line.f.readline riunberoflot, cumberOfColumns - [310(x) for in line.split("")) (readtrunberorrows, ber of Columns, print printf(C) o filtrandoleterotrows, uberofColumns) print(atrix print(0) print(" *** Computing (1) Transpose())) - A) Tada (A) print(" **** Matrix (A) ***** printers) write the rest of code sin( You are going to write the code for the following methods and the missing code in mainl). det multiply, def transpose() def worElements (A) def subtractatris. >> The program will calculate 5 = {A+B) * Transpose(C) - A) +D and find the maximum element in S. Complete the code given above so that it will produce an output as follows:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxiv Special Issue On Database And Expert Systems Applications Lncs 9510

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Hendrik Decker ,Lenka Lhotska ,Sebastian Link

1st Edition

366249213X, 978-3662492130

More Books

Students also viewed these Databases questions

Question

9. Describe the characteristics of power.

Answered: 1 week ago