python roll dice 100 times graph results

Solutions on MaxInterview for python roll dice 100 times graph results by the best coders in the world

showing results for - "python roll dice 100 times graph results"
Isabel
25 Oct 2020
1import numpy as np 
2import random 
3import matplotlib.pyplot as plt 
4
5def die_roll(rollnum, maxdots=6, ausgabe=""):
6    all_rolls = np.random.randint(1, maxdots+1, size=rollnum)
7    
8    if "T" in ausgabe.upper():
9        i = 1
10        for roll in all_rolls:
11            print("{0:d}. Roll : {1:d}" .format(i,roll))
12            i+=1
13    if "G" in ausgabe.upper():
14        plt.figure()
15        plt.plot(all_rolls, marker="o", color = "purple" , linewidth=1, linestyle="solid")
16        plt.ylabel("Number Rolled")
17        plt.xlabel("Times rolled")
18    return all_rolls 
19
20MaxScore = 6
21rolls = 100
22Grafical_results = die_roll(rolls, MaxScore, ausgabe="Text")
23print(Grafical_results)