We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
Serial
Assignment Name Page No. Signature
No.
The Interpreter as a calculator. Basic arithmetic operations.
Introduction to the simple numeric data types –
integers, floating point numbers, Boolean, complex
numbers. Inter conversion of data types.
a. Use the Python prompt as a basic calculator. Explore the
order of operations using parentheses.
b. Explore the various functions in the math module. Eg:
1 find GCD of two numbers, area and perimeter of circle using 1-3 math.pi, etc.
c. Exploring the complex data type and their operations,
eg: finding the modulus and phase angle of a complex number.
d. The print function – Printing value. Repeat the previous
experiments now using the print function solve using python.
Basic user interactions using the print() and input()
functions. a. Write a simple python script using the print function in a text editor, save it with the extension “.py”. Run it in the terminal / command prompt. b. Take input two strings from the user, and print the first 2 one twice, and the other one thrice. 4-5 c. Ask the user to enter two numbers, and output the sum, product, difference, and the GCD. d. More programs that test concepts learned in week 1 which involves the usage of the print and input functions.
Strings, List, Tuples, the re (regular expression) module
a. Ask the user for two strings, print a new string where the first string is reversed, and the second string is converted to upper case. Sample strings: “Pets“, “party”, output: “steP PARTY”. Only use string slicing and + operators. b. From a list of words, join all the words in the odd and 3 even indices to form two strings. Use list slicing and join 6-10 methods. c. Simulate a stack and a queue using lists. Note that the queue deletion operation won’t run in O(1) time. d. Explore the ‘re’ module, especially re.split, re.join, re.search and re.match methods.
4 Conditionals, looping constructs, and generators
a. Use list comprehension to find all the odd numbers and 11-13 numbers divisible by 3 from a list of numbers. b. Using while loops to do Gaussian addition on a list having an even number of numbers. Print each partial sum. Eg: if the list is [1, 2, 3, 4, 5, 6], the program should output “1 + 6”, “2 + 5”, and “3+4” in separate lines, and the result of the addition “21”. Extend it to handle lists of odd length. c. Primarily testing using for and while loops. d. Use (c) to generate a list of primes within a user-given range. e. Explore the ‘key’ function of sum( ), min( ), max( ), and sort( ) functions using lambdas. User defined functions a. Implement popular sorting algorithms like quick sort and merge sort to sort lists of numbers. b. Implement the Pascal’s triangle. c. Three positive integers a, b, and c are Pythagorean triples if a2 + b2 =c 2 . Write a function to generate all 5 Pythagorean triples in a certain range. 14-18 d. Write two functions that simulate the toss of a fair coin, and the roll of an unbiased ‘n’ sided die using the random module. e. Like (d), but now the coin and the die are not fair, with each outcome having a given probability.
File handling, sys, pickle and csv modules
a. Basic file operations. Explore the different file modes. b. Emulate the unix ‘cp’, ‘grep’, ‘cat’ programs in Python. In 6 each case, the user should pass the arguments to the 19-22 program as command line arguments. c. Use pickle for persistent storage of variables.
Sets and dictionaries
a. Use sets to de-duplicate a list of numbers, and a string
such that they contain only the unique elements
b. Use the set union and intersection operations to
implement the Jaccard and Cosine similarity of two sets.
c. Use dictionaries to count the word and letter occurrences
in a long string of text.
d. Invert a dictionary such the previous keys become values
7 and values keys. Eg: if the initial and inverted dictionaries 23-27 are d1 and d2, where d1 = {1: ‘a’, 2: ‘b’, 3: 120}, then d2 = {‘a’: 1, 2: ‘b’, 120: 3}.
e. What if the values in (d) are not immutable? Use
frozensets. For repeated values, use lists. Eg: if d1 = {1: ‘a’, 2: ‘a’, 4: [1, 2]}, then d2 = {‘a’: [1, 2], frozenset([1, 2]): 4}.
f. Write a function to generate the Fibonacci numbers in (a)
exponential time using the naïve algorithm, and (b) in linear time using dynamic programming (memorization) with a dictionary. Signature of Signature of Signature of HOD Teacher Teacher
Full download (Ebook) The Trauma Golden Hour: A Practical Guide by Adonis Nasr, Flavio Saavedra Tomasich, Iwan Collaço, Phillipe Abreu, Nicholas Namias, Antonio Marttos ISBN 9783030264420, 9783030264437, 3030264424, 3030264432 pdf docx