Professional Documents
Culture Documents
Ex-6 7
Ex-6 7
Ex-6 7
1. Define a recursive function to find the sum of numbers between the two given
numbers x and y as input.
2. Write a recursive function to find out how many digits, a positive integer has.
3. The Hamming distance between two bit strings of length n is equal to the number
of bits in which the two strings differ. Compose a program that takes an integer k and
a bitstring s and writes all bitstrings that have Hamming distance at most k from s.
4. The program accepts a file containing a poem, as input. The poem should follow
the following rules:
a) All odd numbered lines should contain exactly 6 words and even-numbered lines
to contain exactly 5 words.
b) Odd numbered lines should contain a hyphen as the last character (this hyphen is
not counted in the 6 words count)
c) Even numbered lines should not start with uppercase letter
Write a python code to implement the above scenario. Also, print the count of each
type of exception raised, at the end of the execution.