Write a recursive function called binarysearch that accepts


1. Write a class of objects called matrix_2 that act like a 2x2 matrix. Make sure to include:
a. __init__ method
b. __add__ method (add two 2x2 matrices)
c. __mul__ method (multiply two 2x2 matrices)
d. __str__ method
e. determinant() a method that finds a matrix's determinant
f. invert() a method that finds a matrix's inverse if it has one or returns 'singular matrix' if it does not

2. Write a recursive function called binary_search() that accepts as arguments a number (your function should work for float and integer types) and a list of numbers sorted in ascending order. Your function may need to accept more arguments, but all other arguments should be given a default value so that they do not have to be entered. Then use the binary search algorithm, implemented recursively, to return either an index that contains the number (there may be more than one, but you need only return one) or 'number not in list'.

3. A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:

1/2=0.5,
1/3=0.(3),
1/4=0.25,
1/5=0.2,
1/6=0.1(6),
1/7=0.(142857),
1/8=0.125,
1/9=0.(1),
1/10=0.1
Where 0.1(

1. Write a class of objects called matrix_2 that act like a 2x2 matrix. Make sure to include:
a. __init__ method
b. __add__ method (add two 2x2 matrices)
c. __mul__ method (multiply two 2x2 matrices)
d. __str__ method
e. determinant() a method that finds a matrix's determinant
f. invert() a method that finds a matrix's inverse if it has one or returns 'singular matrix' if it does not

2. Write a recursive function called binary_search() that accepts as arguments a number (your function should work for float and integer types) and a list of numbers sorted in ascending order. Your function may need to accept more arguments, but all other arguments should be given a default value so that they do not have to be entered. Then use the binary search algorithm, implemented recursively, to return either an index that contains the number (there may be more than one, but you need only return one) or 'number not in list'.

3. A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:

1/2=0.5,
1/3=0.(3),
1/4=0.25,
1/5=0.2,
1/6=0.1(6),
1/7=0.(142857),
1/8=0.125,
1/9=0.(1),
1/10=0.1

Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle.

Write a function decimal() that accepts as input an integer denominator and returns a string with the decimal representation of that fraction (with no trailing zeros, a leading 0. and any numbers that repeat infinitely in parenthesis as above). Hint: How would you implement long division in python? When do you know that your division process is looping?

4. An alternade is a word in which its letters, taken alternatively in a strict sequence, and used in the same order as the original word, make up at least two other words. All letters must be used, but the smaller words are not necessarily of the same length. For example, a word with seven letters where every second letter is used will produce a four-letter word and a three-letter word. Here are two examples:
"board": makes "bad" and "or".
"waists": makes "wit" and "ass".
Using the word list attached, write a function, alternade, that accepts as an argument the file name for the dictionary and then goes through each word in the list and tries to make two smaller words using every second letter. The smaller words must also be members of the list. Print the words to the screen in the above fashion.

5. Write a function called checksum() that accepts as input a filename. The function takes the text of the file and sums the letters (upper and lowercase letters have the same value) for 'a' = 1, 'b' = 2, 'c' = 3, ... For example 'word' would give 'w'+ 'o' + 'r' +'d' = 23 + 15 + 18 + 4 = 60. The function should return the integer sum of all the letters in the file.

6. Write a function called word_lengths() that accepts a list of words and using a dictionary comprehension returns a dictionary whose keys are integers and values are the set of words from the input list whose length are that of its key. The values should be lower cased. The function should be as follows:
defword_lengths(input_list):
"""
documentation here
"""
return {dictionary comprehension here}

7. In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:

1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).

It is possible to make £2 in the following way:

1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p

Write a function, make_change() that accepts an integer number of pence and calculates how many different ways one can make change for that amount using any number of coins? What is the answer for 200 pence?

8. A certain childrens game involves starting with a word in a particular category. Each participant in turn says a word, but that word must begin with the final letter of the previous word. Once a word has been given, it cannot be repeated. If an opponent cannot give a word in the category, they fall out of the game. For example, with "animals" as the category,

Child 1: dog
Child 2: goldfish
Child 1: hippopotamus
Child 2: snake

... Write a function word_game() that accepts a list of words and returns the longest list of words that can be played in sequence. Your function may accept other input, but default values should be used so that it works if simply passed a list. Your program, while not graded for speed, should solve the following selection of 70 English Pokemon names (extracted from Wikipedia's list of Pokemon) in less than 3 minutes.

audino bagon baltoy banette bidoof braviary bronzor carracosta charmeleon
cresselia croagunk darmanitan deino emboar emolga exeggcute gabite
girafarig gulpin haxorus heatmor heatran ivysaur jellicent jumpluff kangaskhan
kricketune landorus ledyba loudred lumineon lunatone machamp magnezone mamoswine
nosepass petilil pidgeotto pikachu pinsir poliwrath poochyena porygon
porygonz registeel relicanth remoraid rufflet sableye scolipede scrafty seaking
sealeo silcoon simisear snivy snorlax spoink starly tirtouga trapinch treecko
tyrogue vigoroth vulpix wailord wartortle whismur wingull yamask

When you cut and paste this list, then parse it, make sure to check that it has 70 elements.

Attachment:- unixdict.rar

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Write a recursive function called binarysearch that accepts
Reference No:- TGS02645152

Expected delivery within 24 Hours