best business builder

Rolling A Die

Here is a script that can be used to roll a die. The number of sides of the die can be adjusted. The amount of rolls and roll results can be changed at the bottom. Currently, the script will roll three times on a six sided die.

#!/bin/python3.6

from random import randint

"""A class to represent a XX sided die"""

class Die():
    """A XX sided dice"""

    def __init__(self, sides):
        """A XX sided dice"""
        self.sides = 6
        print("You are handed a " + str(self.sides) + " sided die.")

    def roll_die(self):
        """Rolling the die"""
        self.roll = randint(1, (self.sides))
        print("Die rolled...")

    def roll_result(self):
        """Results of the die"""
        print("The die landed on a " + str(self.roll))

# Define dice from class
dice = Die('side')

# Roll then see the results
dice.roll_die()
dice.roll_result()
dice.roll_die()
dice.roll_result()
dice.roll_die()
dice.roll_result()

customer relationships

Leave a Reply

Your email address will not be published. Required fields are marked *