Question Bank IAT -2
[Link] a function named DivExp which takes TWO parameters a, b and returns a value c (c=a/b). Write
suitable assertion for a>0 in function DivExp and raise an exception for when b=0. Develop a suitable
program which reads two values from the console and calls a function DivExp.
2. Develop a program to generate Fibonacci sequence of length (N). Read N from the console.
3. Write a function to calculate factorial of a number with and without recursion
4. Read N numbers from the console and create a list. Develop a program to print mean, variance and
standard deviation with suitable messages using functions.
5. Develop a python program to convert binary to decimal, octal to hexadecimal using functions.
6. Read a multi-digit number (as chars) from the console. Develop a program to print the frequency of
each digit with suitable messages.
7. Develop a program to print 10 most frequently appearing words in a text file. [Hint: Use dictionary
with distinct words and their frequency of occurrences. Sort the dictionary in the reverse order of
frequency and display dictionary slice of first 10 items]
8. Develop a program to sort the contents of a text file and write the sorted contents into a separate
text file. [Hint: Use string methods strip(), len(), list methods sort(), append(), and file methods open(),
read lines(), and write()].
9. Develop a program to backing Up a given Folder (Folder in a current working directory) into a ZIP
File by using relevant modules and suitable methods.
10 Write the python program for magic 8 Ball with a list
18. Say you have a list value like this:
spam = ['apples', 'bananas', 'tofu', 'cats']
Write a function that takes a list value as an argument and returns
a string with all the items separated by a comma and a space, with and
inserted before the last item. For example, passing the previous spam list
to
the function would return 'apples, bananas, tofu, and cats'. But your function
should be able to work with any list value passed to it.
[Link] the Python program to play Tic tac Toe board using Dictionary
and list