CE151: Assignment resit — Introduction to Programming CSEE, University of Essex July 2020 Exercise 1 [15%] To calculates sin(x) using Taylor series, use the following definition: The function sin(x)...

Python exercises


CE151: Assignment resit — Introduction to Programming CSEE, University of Essex July 2020 Exercise 1 [15%] To calculates sin(x) using Taylor series, use the following definition: The function sin(x) can be calculated using the Taylor series: For more information see https://en.wikipedia.org/wiki/Taylor_series Where is factorial and calculated as: Write Python program to calculate sin(x) using Taylor series, of course n cannot go to infinity we could only calculate about 16 terms (use a for- loop n = 0 to 16) , at the end compare it with the Math.sin method for: Create a list: val [] = {0, math.pi/3,...,math.pi} and traverse this list to compute and compare the values calculated by your method and math.sin – you need to import math Exercise 2 [25%] Part A 5 marks Create a file that has the following sentences in each line: Hello my name is John Weather is hot today My cat is cute Thank you Part B 20 marks Read the file that you have created in Part A, and write a new file where each sentence [in each line] has similar words but in a reverse order as: nhoJ si eman ym olleH yadot toh si rehtaeW etuc si tac yM uoy knahT Exercise 3 [25%] Write a recursive function that receives a string and outputs a new string in the following format where there is one ‘*’ before the first character and one ‘*’ after the last character. Between other characters there is ‘*+’: For example where the input string is hello, the output should look like: *o*+l*+l*+e*+h* Exercise 4 [15%] Write a function that receives a tuple of tuples as below where the tuples include a string and a number of occurrence as: (('My',3),('Name',14),('John',3), ('David',20), ('My',5), ('Name',6), ('David',6), ('Richard',6)) The function needs to print each string and the total number of occurrence in the following format: My, 8, Name, 20, David, 26 In a separate output line it need to list unique words and their occurrence as: e.g. John, 3, Richard, 6 Exercise 5 [20%] For this exercise, you have to print prime numbers less than 1000 (see the table below). You have to do a bit more to achieve the above table – but it would be all to do with formatting rather than the algorithm of calculating prime numbers. the quality of code and internal documentation are also considered (and not just for this exercise but also throughout the assignment).
Aug 24, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here