customer relationships

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()


Got a project that needs expert IT support?

From Linux and Microsoft Server to VMware, networking, and more, our team at CR Tech is here to help.

Get personalized support today and ensure your systems are running at peak performance or make sure that your project turns out to be a successful one!

CONTACT US NOW
one click social media designs