Please write code and give answers below mentioned guidelines

(4) Assignment: Fraction

Create a class named Fraction whose constructor sets numerator and denominator instance variables.

Your Fraction class should support an instance method called display that takes no parameters and displays to the screen a text based representation of a Fraction, as well as an instance method called add that takes another Fraction object as a parameter and returns a new Fraction that is the sum of the calling Fraction and the Fraction that was passed in.

You do NOT have to reduce the resulting Fraction.

F1 = Fraction(1,2) F1.display() -> display “1/2” to the screen
F2 = Fraction(1,4) F2.display() -> display “1/4” to the screen
F3 = F1.add(F2) F3.display() -> display “6/8” to the screen


(4) Assignment: Dice

Create an object that represents a Dice object that we might want to roll like those used in casinos or in games like dungeons and dragons.

Typical dice at 6 sided and when you roll a value between 1 and 6 comes up.

There are, however, many different size dice, like 20 sides (D20) which give values between 1 and 20, 10 sided (D10) which give values between 1 and 10 etc…

Create a class called Dice whose constructor takes a single parameter for the number of sides this particular Dice object will have.
Provide a single instance method called roll that takes no parameters and returns a single random roll of that particular instance of Dice.
For documentation on random numbers in python, see:


D6 = Dice(6)

  • D6.roll() -> returns 3
  • D6.roll() -> returns 1
  • D6.roll() -> returns 5
  • D10 = Dice(10)

  • D10.roll() -> returns 9
  • D10.roll() -> returns 2
  • =========================———–==============================================

    (4) Assignment: Map of Rooms

    Read: for an introduction to a type of text based game from the early days of the internet.

    This kind of game had a collection of rooms that were connected to each other by exits.

    A player could then walk around the interconnected rooms.

    Create a “map” of rooms that are connected to each other in the shape of a cross.
    Link the rooms together with Exit objects (depicted in the yellow E’s)
    Initially add the Player to R1 and ask them over and over again which direction they want to go.
    Each time a player enters a room it should display the room’s title and the obvious exits leading out of the room for the player to select from. See the example for what your running program might look like.