python roll dice 100 times graph results code example

Example: python roll dice 100 times graph results

import numpy as np 
import random 
import matplotlib.pyplot as plt 

def die_roll(rollnum, maxdots=6, ausgabe=""):
    all_rolls = np.random.randint(1, maxdots+1, size=rollnum)
    
    if "T" in ausgabe.upper():
        i = 1
        for roll in all_rolls:
            print("{0:d}. Roll : {1:d}" .format(i,roll))
            i+=1
    if "G" in ausgabe.upper():
        plt.figure()
        plt.plot(all_rolls, marker="o", color = "purple" , linewidth=1, linestyle="solid")
        plt.ylabel("Number Rolled")
        plt.xlabel("Times rolled")
    return all_rolls 

MaxScore = 6
rolls = 100
Grafical_results = die_roll(rolls, MaxScore, ausgabe="Text")
print(Grafical_results)