Python Forum
"Card Dealing" Python code 2.7
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Card Dealing" Python code 2.7
#1
import random
#Simulate the process of dealing of 1000 cards
print "Card dealing simulator"
print "By:"
Club = 0
Dia = 0
Heart = 0
Spade = 0
ClubC = 0
DiaC = 0
HeartC = 0
SpadeC = 0
Count = 0
while True:
    Cards = (random.random() * 52) + 1
    Count = Count + 1
    if 0 < Cards < 14:
        ClubC = ClubC + 1
    elif 14 < Cards < 27:
        DiaC = DiaC + 1
    elif 26 < Cards < 40:
        HeartC = HeartC + 1
    elif 39 < Cards < 53:
        SpadeC = SpadeC + 1
    elif Count == 1000:
        print "1000 cards have been dealt"
        break
print "There were " + str(ClubC) + " clubs cards dealt"
print "There were " + str(DiaC) + " diamonds cards dealt"
print "There were " + str(HeartC) + " heart cards dealt"
print "There were " + str(SpadeC) + " spade cards dealt"
raw_input()
I'm having trouble with this code and i wanted to see if anyone can see a problem with the code. It runs occasionally but most of the time it only inputs the print type and doesn't do anything else.
Part of my belief is that my computer may just not be able to handle the proccessing of 1000 runs through.
Reply


Messages In This Thread
"Card Dealing" Python code 2.7 - by Paradoxalis - Nov-17-2016, 09:48 PM
RE: "Card Dealing" Python code 2.7 - by micseydel - Nov-17-2016, 11:18 PM
RE: "Card Dealing" Python code 2.7 - by metulburr - Nov-17-2016, 11:28 PM
RE: "Card Dealing" Python code 2.7 - by Larz60+ - Nov-17-2016, 11:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel from SAP - dealing with formats and VBA MasterOfDestr 7 654 Feb-25-2024, 12:23 PM
Last Post: Pedroski55
  UnicodeEncodeError - Dealing with Japanese Characters fioranosnake 2 2,522 Jul-07-2022, 08:43 PM
Last Post: fioranosnake
  Having strange results from an RFID HID card reader - I'm stuck orbisnz 1 1,512 Mar-28-2022, 08:20 AM
Last Post: Larz60+
  SQL wild card use hammer 3 1,294 Jan-07-2022, 02:17 PM
Last Post: hammer
  Dealing with duplicated data in a CSV file bts001 10 11,672 Sep-06-2021, 12:11 AM
Last Post: SamHobbs
  Dealing with a .json nightmare... ideas? t4keheart 10 4,450 Jan-28-2020, 10:12 PM
Last Post: t4keheart
  Dealing with Exponential data parthi1705 11 9,898 May-30-2019, 10:16 AM
Last Post: buran
  Credit card number redacting script Drone4four 6 5,292 Jan-18-2019, 02:07 PM
Last Post: Drone4four
  Dealing with multiple context managers heras 5 4,762 Nov-16-2018, 09:01 AM
Last Post: DeaD_EyE
  Validating credit card frequency 8 4,235 Nov-05-2018, 07:36 PM
Last Post: frequency

Forum Jump:

User Panel Messages

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