Ask Python Expert

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

Python, Programming

  • Category:- Python
  • Reference No.:- M92678008
  • Price:- $90

Guranteed 48 Hours Delivery, In Price:- $90

Have any Question?


Related Questions in Python

Part i the assignment filesone of the most important

Part I: The Assignment Files One of the most important outcomes of this assignment is that you understand the importance of testing. This assignment will follow an iterative development cycle. That means you will write a ...

Homework -this homework will have both a short written and

Homework - This homework will have, both a short written and coding assignment. The problems that are supposed to be written are clearly marked. 1) (Written) Make heuristics Describe two heuristics for the slide problem ...

Tasksdemonstrate data scraping of a social network of

Tasks Demonstrate data scraping of a social network of choice. Develop technical documentation, including the development of the code & detailing the results. Provide a report on the findings, that includes research into ...

Assignment1 utilising python 3 build the following

Assignment 1. Utilising Python 3 Build the following regression models: - Decision Tree - Gradient Boosted Tree - Linear regression 2. Select a dataset (other than the example dataset given in section 3) and apply the De ...

Python programming assignment -you first need an abstract

Python Programming Assignment - You first need an abstract base class, called, Account which has the following attributes and methods: accountID: This attribute holds the ID assigned the account , if not provided set to ...

Learning outcomes lo3 - research develop and document a

Learning Outcomes LO3 - Research, develop, and document a basic security policy, and analyse, record, and resolve all security incidents LO4 - Identify and assess the threats to, and vulnerabilities of networks Assessmen ...

Question research pythons dictionary data type dictdiscuss

Question : Research Python's dictionary data type (dict). Discuss its interface and usage. Include examples. Discuss practical applications of dictionaries.

Questionwhat is a python development frameworkgive 3

Question What is a python development framework? Give 3 examples python development framework used today. and explain which development framework is used in which industry.

Below zero - ice cream storethe local ice-cream store needs

Below Zero - ice cream store The local ice-cream store needs a new ordering system to improve customer service by streamlining the ordering process. The manager of the store has found that many orders are incorrect and s ...

The second task in this assignment is to create a python

The second task in this assignment is to create a Python program called pancakes.py that will determine the final order of a stack of pancakes after a series of flips.(PYTHON 3) Problem Task In this problem, your input w ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As