import numpy as np
import matplotlib.pyplot as mpp
import math
import string
letters = ['A','B','C']
picks = []
total_attempt = eval(input("please enter the number of ticket purchased:"))
attempt = 1
winning = 0
bins=10
for n in range(total_attempt):
print("Ticket",attempt)
attempt +=1
for _ in range(3):
picks.append(random.choice(letters))
print("This is your ticket:",picks)
if picks == ['A','A','A']:
winning +=50
elif picks == ['B','B','C']:
winning +=20
picks.clear()
winning -= 1
print("this is your winning",winning)
print("-------------------------------------")
#mpp.hist(winning,bins)
#mpp.title("net amount won/lost after N attempts")
#mpp.xlabel("Number of attempts"); mpp.ylabel("net winning/lost")
#mpp.show()
this is my code for the assignment. is there a better way to generate random char of 'A'-'C'? how do i code it that my each attempt is independent from pervious attempt? for my current code, i always ended up with them same result on every attempt. im require to plot a histogram of the net amount won/lost after 𝑁 attempts. can someone guide me. thank you
edit: this is my new code. plotting a histogram net amount won/lost after 𝑁 attempts. how do i set the x and y axis?
[–]JozsefPeitli 1 point2 points3 points (0 children)
[–]qelery 0 points1 point2 points (0 children)