0% found this document useful (0 votes)
5 views1 page

Python Programming Tasks and Solutions

The document outlines a series of programming tasks including the creation of a 'calc.py' module with various mathematical functions, exception handling, file processing with regex, and class implementations for 'Person' and 'Product'. It also includes requirements for a custom list class, an iterator, a Fibonacci generator, a function execution time decorator, and translations of English statements into regular expressions. These tasks are intended for internal use at Wipro.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Python Programming Tasks and Solutions

The document outlines a series of programming tasks including the creation of a 'calc.py' module with various mathematical functions, exception handling, file processing with regex, and class implementations for 'Person' and 'Product'. It also includes requirements for a custom list class, an iterator, a Fibonacci generator, a function execution time decorator, and translations of English statements into regular expressions. These tasks are intended for internal use at Wipro.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1)Create a module “calc.

py" with the following functions

a. A function to find the factorial of a number


b. A function that returns the log10 of a given number
c. A function to convert value in degrees to radians
Internal to Wipro
d. A function that returns the sin, cos and tan values of a given angle

Utilize the above functions by importing them in another module “[Link]”. Use
from <module> import <function> statement to import only functions a & d from
the “[Link]” module

2) Write a program to handle the following exceptions


a. Keyboard interrupt
b. NameError
c. ArithmeticError
Note : make use of Try, except, else and finally blocks

3)Write a program using re module that loops through the lines of a file or standard input (where
each line contains a single word) and prints all words containing two adjacent vowels

4)Implement a class Person with the following attributes and methods


a. Class attribute to hold the instances of Person
b. An initialization method to set the attributes first name and last name
c. A class method to return the number of Person instances
Create few instances of the class and use the class method to print the number of instance(s)

5)Define the Product class. Each product instance should have an id, name, and price. Use a
generator object to allocate id for products. Implement a depot class. Each instance of depot has an
inventory of products with instance methods to add, remove, display, find product by name and sort
by price Note: The product names should not be duplicated.

6)Create a class named ListofStrings. Extend the append() method in the list class to ensure only
objects of string type are added to list. Raise TypeError with appropriate error messages if objects of
other types are added to the list. Ensure all the strings added to the list are in title case. [Hint: Use
super()]

7)Write an iterator class that iterators over a sequence of values in the reverse direction 19.

8)Implement a simple generator for Fibonacci series

9)Implement a decorator that quantifies and returns the execution time of any function

10) Translate each of the following English statements into a regular expression: a. Digit at the
beginning of the string and a digit at the end of the string b. A string that contains only whitespace
characters or word characters c. A string containing no whitespace characters

Internal - General Use

You might also like