Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python: Deal or No Deal Game. I'm trying to code the game Deal or No Deal (like the TV show) but got stuck, and also
Python: Deal or No Deal Game.
I'm trying to code the game Deal or No Deal (like the TV show) but got stuck, and also having problem with Pygame as I never you it before. Please help!
mport random import pygame class dealOrNoDeal(): briefcases = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26] listPrice = [1.00, 2.00, 5.00, 10.00, 25.00, 50.00, 75.00, 100.00, 200.00, 300.00, 400.00, 500.00, 750.00, 1000.00, 5000.00, 10000.00, 25000.00, 50000.00, 75000.00, 100000.00, 200000.00, 300000.00, 400000.00, 500000.00, 750000.00, 1000000.00] briefcaseWithValue = [] priceLeft = [] selected = 0 selectedPrice = 0 def __init__(self): print('*' * 30, end=' ') print(('Welcome to Deal or No Deal!').upper(), end=' ') print('*' * 30, end=' ') #The function will randomly assign the amount of price for each briefcase and zip them into a dictionary def assignValue(self): dealOrNoDeal.priceLeft = sorted(dealOrNoDeal.listPrice) random.shuffle(dealOrNoDeal.listPrice) dealOrNoDeal.briefcaseWithValue = dict(zip(dealOrNoDeal.briefcases, dealOrNoDeal.listPrice)) return dealOrNoDeal.briefcaseWithValue def choseCase(self, casesWithValue): self.casesWithValue = casesWithValue playGame = True while playGame: #Prompt the user to enter the briefcase number selected = int(input('Select your briefcase from number 1 to 26: ')) - 1 if selected >= 0 and selected <= 25: print('Your briefcase number is: ', selected + 1) #Record the user's briefcase dealOrNoDeal.selected = selected + 1 #Record the price in the user's briefcase dealOrNoDeal.selectedPrice = dealOrNoDeal.briefcaseWithValue[dealOrNoDeal.selected] print(dealOrNoDeal.selectedPrice) #delete the briefcase that the user have chosen del dealOrNoDeal.briefcaseWithValue[dealOrNoDeal.selected] print(dealOrNoDeal.briefcaseWithValue) return dealOrNoDeal.selected else: print('Input is out of range!')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started