Fundamentals of DataScience Week 5 - Asignment
PadhAI_FDS_Week_5_Assignment-200304-124339

Exercise 1

Attempt any 3 questions

  1. Create a list of 10 ordered pairs $(x,y),\ \ x\ \epsilon\ [-6,6]$ such that they satisfy the equation $x^2+y^2=r^2$ where $r=6$.
  2. We have a list of tuple representing the name and height (in cms) of 5 students respectively. Convert the list into a dictionary so that we can access the student's height from their names.

    data = [('Sumit', 183), ('Rahul', 175), ('Kritika', 170), ('Harshit', 177), ('Deepak', 162)]

  3. Write a function which takes list of random integers as an input and returns the list all the unique values present in that list. For ex:

    Input: [1, 2, 4, 4, 3, 2, 1, 1, 2, 4, 5, 3]
    Output : [1, 2, 3, 4, 5]
  4. Write a program to generate a dictionary that contains the number between $1$ and $n$ in the form of $(key : value) = (x : x^2)$ where $n=100$. For ex:
    If n = 7 then output will be = {0:0, 1:1, 2:4}
  5. Write a function which takes a dictionary as an input as return the list of all unique values of dictionary. For ex:
    Input : {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3, 'g':4, 'h':3, 'i':4}
    output : [1, 2, 3, 4]
  6. Write a Python program to remove newline characters from a file.
  7. Write a Python program that takes a text file as input and returns the number of words of a given text file.

Exercise 2

Attempt any 3 questions

  1. Write a python function which accpets a tuple representing the fields (func, $x_a$) where 'func' is any function $f(x)$ and $x_a$ is a point on which you have to find the slope i,e; $\frac{df(x)}{dx}$ and return a tuple of (slope, $x_a$, $f(x_a)$, $\Delta x$) where $\Delta x \to 0$ but $\Delta x \neq 0$.

    Remember : $\lim_{\Delta x \to 0} \frac{f(x_a + \Delta x) - f(x_a)}{\Delta x}$

  2. Write a python function which accepts two arguments ($n$, $a$) and returns a tuple of $n$ elements where $n^{th}$ element should be : $n^{th}_{element} = 1+\frac{a}{1!}+\frac{a^2}{2!}+\frac{a^3}{3!}+...+\frac{a^n}{n!}$ and $a$ should be any positive number. (Observe the last 10 values of returned tuple if $n > 20$)

  3. Write a python function which generates the list of $n$ dictionaries representing $n$ students. Each dictionary should have two keys Name and Marks, the value of Marks key should be a list of 10 elements representing marks in 10 subjects as $[a_1,a_2,a_3,a_4,...,a_{10}]$. Create another function which accepts such dictionary and performs operation on marks and returns a list as $[\alpha_1,\alpha_2,\alpha_3,\alpha_4,...,\alpha_{10}]$ where $\alpha_i = \beta \alpha_{i-1} + (1-\beta)a_i$ and $\beta = 0.99, \alpha_0 = 1, i=1,2,3,...,10$

  4. Create a dictionary, with keys should be the number from 1 to 100 (1 and 100 both inclusive) and the value should be the list of string representing whether that key is 'Prime', 'Fibonacci' (if that number exist in Fibonacci sequence), 'Square' or all of three. Also write a function which accepts a dictionary (which you will create) and string Prime, Fibonacci or Square and by searching through dictionary it should return a tuple of that numbers. Fo ex:

    sample_dict = {1: ['Fibonacci', 'Square'], 6: [], ..., 13: ['Prime', 'Fibonacci'], ..., 34: ['Fibonacci'], ..., 100: ['Square']}
    For second part of the question:
    seq = func_name('Fibonacci')
    print(seq) --> (1, 2, 3, 5, 8, 13, 21, ..., 89)
  5. Copy the below paragraph and write an ecoded text file then read the same file and reconstruct the original paragraph. You have to use $f(a)$ function for encoding and decoding the text. $f(a) = 2a + 3$,where $a$ is an ASCII value of charater.

    Data science is an inter-disciplinary field that uses scientific methods, processes, algorithms and systems to extract knowledge and insights from structured and unstructured data. Data science is related to data mining and big data. Data science is a "concept to unify statistics, data analysis, machine learning and their related methods" in order to "understand and analyze actual phenomena" with data. It employs techniques and theories drawn from many fields within the context of mathematics, statistics, computer science, and information science. Turing award winner Jim Gray imagined data science as a "fourth paradigm" of science (empirical, theoretical, computational and now data-driven) and asserted that "everything about science is changing because of the impact of information technology" and the data deluge. In 2015, the American Statistical Association identified database management, statistics and machine learning, and distributed and parallel systems as the three emerging foundational professional communities.
  6. Using below text, write a file named File_1.txt and you have to insert new line character after every 10 words.
    Data science is an inter-disciplinary field that uses scientific methods processes algorithms and systems to extract knowledge and insights from structured and unstructured data Data science is related to data mining and big data. Data science is a concept to unify statistics data analysis machine learning and their related methods in order to understand and analyze actual phenomena with data It employs techniques and theories drawn from many fields within the context of mathematics statistics computer science and information science Turing award winner Jim Gray imagined data science as a fourth paradigm of science empirical theoretical computational and now data driven and asserted that everything about science is changing because of the impact of information technology and the data deluge In 2015 the American Statistical Association identified database management statistics and machine learning and distributed and parallel systems as the three emerging foundational professional communities
In [0]: