This is my homework and python3: Write a GUI-based program that displays random
ID: 3673492 • Letter: T
Question
This is my homework and python3:
Write a GUI-based program that displays random images of playing cards. At start-up, the GUI displays the image of the back of a card as shown in this diagram.
When the user clicks the "Show Random Card" button, the program displays the image of the face of a random card. The program must use the following procedure for selecting a random card. It generates a random integer between 1 and 13 representing a random rank and a random character from the list ["s", "h", "d", "c"] representing a random suit. The card's file name is the concatination of the random integer, random character, and the string .gif. Assume that all image cards are stored in the sub-folder DECK as explained in the CardDemo example that was discussed in class. You need to copy the DECK folder to the folder containing your program. Sample screen shots are as follows:
Explanation / Answer
import random num1 = random.randint(1,13) num2 = random.randint(1,4) cardnum1 = "" cardnum2 = "" input ("Press the enter key to continue ") if True: if num1 == 11: cardnum1 = "Queen" elif num1 == 12: cardnum1 = "Jack" elif num1 == 13: cardnum1 = "King" elif num1 < 10: cardnum1 = num1 elif num2 == 1: cardnum2 = "Spades" elif num2 == 2: cardnum2 = "Hearts" elif num2 == 3: cardnum2 = "Diamonds" elif num2 == 4: cardnum2 = "Clubs" print (cardnum1, cardnum2)Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.