logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Create a class called Rectangular, with two data attributes: length and width. They should be assigned in constructor

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Submission Requirement:

For all the problems in this assignment you need to design and use Python 3, output and present the results in nicely format. Please submit a written report (pdf), where your results and copy your code should be readable, and 4 python files (main.py, gen- erator.py, point.py and MCTest.py). Your grade will be evaluated by combination of report and code. You are strongly encouraged to write comment for your code, because it is a convention to have your code documented all the time. In your python file, you need contain both function and test part of function. Python script must be a ‘.py’ script, Jupyter notebook ‘.ipynb is not allowed. Do NOT copy and paste from others, all homework will be firstly checked by plagiarism detection tool.

 

1          Class practice 30 pts

1.1         Define class (20pts)

Create a class called Rectangular, with two data attributes: length and width. They should be assigned in constructor ( init ()) It should also have two function attributes called area() and perimeter() which return area and perimeter of this rectangular re- spectively. Here is an example of the class structure:

>>> class Rectangular:

...        

...        

...        

>>> myRec = Rectangular(10,20)

>>> print(myRec.area()) 200

>>> print(myRec.perimeter()) 60

(5pt Bonus) Write an inherited class called Square from Rectangular, you may only override the constructor, let it only accept one parameter:  length.  You  need to call  its superclass’s constructor in its constructor, instead of assigning parameters to data attributes.

1.2         Numpy applying on class (10 pts)

  1. define two numpy array with size 10, named with length and

  2. test your your class ¡Rectangular¿ with input as np (Here you should have 10 output for area and perimeter).

 

2          Display Time (20pts)

Create a Time class and initialize it with hours, minutes and seconds.

  1. Make a method addTime which should take two time object and add them. E.g. if your original initial parameter is (2 hour and 50 min and 10 seconds), then you could call this method with another input parameters (1 hr and 20 min and 5 seconds) , then output is (4 hr and 10 min and 15 seconds)

  2. Make a method displayTime which should print the time (the initial parameter).

  3. Make a method DisplayMinute which should display the total seconds in the Time. E.g.- (1 hr 2 min) should display 3720

 

3          Uniform Distributed Random Number Generator (50pt)

You can not use any random number generators in packages like Numpy, because you are required to build your own generator in this question.

 

Almost all the random numbers generated by computer are pseudo random num- bers, because they are generated by a formula. A good random number generator is very important for financial simulations, such as Monte-Carlo method.

 

The goal of this assignment is to let you understand how computer generate ran- dom numbers and create pseudo random number generators which can generate 0-1 uniform-distributed random numbers by yourselves.

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

902 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

539 Answers

Hire Me
expert
Husnain SaeedComputer science

833 Answers

Hire Me
expert
Atharva PatilComputer science

823 Answers

Hire Me

Get Free Quote!

299 Experts Online