Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Python 1. In this part of the assignment, you will work with file 1/0 operations, dictionaries, Numpy arrays and visualization with Matplotlib. You will

Use Python image text in transcribed
image text in transcribed
image text in transcribed
1. In this part of the assignment, you will work with file 1/0 operations, dictionaries, Numpy arrays and visualization with Matplotlib. You will write a simple Python script that will read a file named test.txt. You can hard code this into your program for convenience. A sample file is given on Canvas for your reference. Your program should read a text file and print a histogram of the letters present in the document. The code must have the histogram as both a dictionary, where the keys are letters and the values are the corresponding frequencies, as well as a N inpy array, where each index corresponds to a letter in alphabetical order. For examrle, the letter 'a' corresponds to index 0 , ' b ' to index 1 , etc. An example of a histogram for a line is given below: Input: The quick brown fox jumps over the lazy dog Output: {a:1,b:1,c:1,d:1,e:3, ' i:1,j0:1,k:1,1:1,m:1,n:1, 0:4,p:1,q:1,r: 2, 's': 1, 't': :2,u:2,vv:1,w:m:1,x:1, Y:1,:1} 2. Write a python program to solve Collatz conjuncture sequence as given below. The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: n={n/2,2vn+1ifnisevenifnisodd 2. Write a python program to solve Collatz conjuncture sequence as given below. The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: n={n/2,3xn+1,ifnisevenifnisodd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1 . For example, if n=35, the sequence is 35,106,53, 160,80,40,20,10,5,16,8,4,2,1. 3. Create array x and y, where x=(1,4,3) and y=(324719). Perform all the basics mathematical operations like addition, subtraction, multiplication, transpose, xy and division. 4. Write a function mymax(x) to return the maximum (largest) value in x without using any built-in functions. 5. Let Q(x) be the quadratic equation Q(x)=ax2+b+c=0 for some scalar values a, b, and c. A root of Q(x) is an r such that Q(r)=0. The two roots of a quadratic equation can be describsd by the quadratic formula, which is r=2abb24ac A quadratic equation has either two real roots (i.e., b2>4ac ), two imaginary roots (i.e., b2

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

Advances In Databases And Information Systems Second East European Symposium Adbis 98 Poznan Poland September 1998 Proceedings Lncs 1475

Authors: Witold Litwin ,Tadeusz Morzy ,Gottfried Vossen

1st Edition

3540649247, 978-3540649243

More Books

Students also viewed these Databases questions

Question

socialist egalitarianism which resulted in wage levelling;

Answered: 1 week ago

Question

soyuznye (all-Union, controlling enterprises directly from Moscow);

Answered: 1 week ago