Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
roll of the dice
#1
Photo 
Hi everybody

Ive made a program that randomly chose a number of dice from 1 to 6 (as long as we continu the game) then show an image of the dice with the chosen number after playing the dice roll sound using python jupyter but it shows nothing as result

Can anybody help me out ?

here is the program
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

def info():
    print("press q to stop")
    print("press enter to continu")

def show_nbr():
    import random
    valeur= random.randint(1,6)
    return valeur

info()
while True:
    choix = input()
    if choix == 'q':
        break
    from IPython.display import Audio
    from IPython.display import Image
    sound_file = 'dice2.mp3'
    Audio(sound_file,autoplay=True)
    dados='d'+str(show_nbr())+'.jpg'
    print(dados)
    img=mpimg.imread(dados)
    imgplot=plt.imshow(img)
    plt.show()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dice Roll (Find out how many rolls until specified streak) DustinKlent 4 3,992 Jun-13-2021, 09:44 AM
Last Post: Gribouillis
  Help with dice roll program kraco 4 2,094 Sep-22-2020, 02:06 PM
Last Post: kraco
  simple dice roll Byzas 1 2,340 Mar-21-2019, 02:29 AM
Last Post: ichabod801
  unit test roll die saladgg 5 4,163 Nov-06-2018, 11:39 PM
Last Post: stullis
  Issue with my 'roll the dice simulation'-exercise (cannot break out of the loop) Placebo 2 3,502 Sep-30-2018, 01:19 PM
Last Post: Placebo
  Making a percentile dice roller and dice roller Fixer243 2 3,236 Sep-30-2018, 12:18 PM
Last Post: gruntfutuk
  Random Dice roll program th3h0bb5 1 5,540 Oct-18-2016, 09:25 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020