## Topic 5: My niggas be trippin' #4_P4.1 # Programmer: Your mom is hot # Date: with Cam? Yes please. #This program be lettin real gansta niggas play with marbies yo nim for punk as BITCHES from random import randint from sys import exit #print("I just pooed myself. ", randint(3, 13.5) marbles = randint(10, 100) userGoesFirst = randint(0, 1) isUserFirst = userGoesFirst == 1 mode = randint(0, 1) isEasyMode = mode == 1 howMany = "Yo betch how many marbies u wanna choose yo dawg?" youLost = "FUCK-ing bollocks!" youWon = "oh FUCK YOU WON DAWG lets do SHOTS SHOTS SHOTS FUCK MARBIES !!!!" victoryExit = "Yo I'ma let you finish, but YOU PLAYED THE BEST MARBIES -- OF ALL TIME!" failureExit = "Poop on your head!" illegalChoice = "Nah dawg, it ain't even leik dat. Try it again my nigga." greetingMessage = "ROLL DAT' SHIT MY NIG" whoStarts = "" howHard = "" print(greetingMessage) print("Yo we got ", marbles, " marbies all up in mah shiiiiii") whoStarts = "you'sa go first okie-day?" if isUserFirst else "compy first sit yo' punk ass DAWHN RIGHT NURR" howHard = "piece of penis-cake" if isEasyMode else "di-ock suck all. DAY. dawg." print (whoStarts, " and it gon' be a ", howHard) if not isUserFirst and not isEasyMode : while marbles > 0 : half = marbles // 2 ## Note that // is not the same as / when it comes to division ## 5 // 2 = 2 BUT 5 / 2 = 2.5 ## Food for thought, just be sure of which operation you want to do.. computerChoice = randint(1, half) // 2 - 1 ## I simplified what you had here: ## "marbles = marbles - choice" to "-=" but left in the original logical error.. ## This following line, even simplified can yield negative values... ## which if you run it enough times you see it does indeed do sometimes. ## Which then actually, when subtracting a negative, actually ADD to the total marbies.. ## you probably want to add validation to stop this / force it to re-pick a legal value. marbles -= computerChoice print ("kompy done took [", computerChoice, "] marbies, now there are [", marbles, "] marbies left yo dawg.") if marbles == 1: print (youLost) exit(failureExit) userChoice = int(input(howMany)) ## At this point, your code had an IF instead of a WHILE statement ## This means it will only check once for a bad entry, ## then accept a bad one the very next time while userChoice <= 0 or userChoice > marbles / 2: print(illegalChoice, userChoice, " is too low/high") userChoice = int(input(howMany)) marbles -= userChoice print ("My dawg you don' tooken ", userChoice, " marbies, now there are ", marbles, " marbies still on the table my n-word.") if marbles == 1: print(youWon) exit(victoryExit) if not isUserFirst and isEasyMode : while marbles > 0 : half = marbles // 2 computerChoice = randint(1, half) marbles -= computerChoice print ("kompy done took [", computerChoice, "] marbies, now there are [", marbles, "] marbies left yo dawg.") if marbles == 1: print (youLost) exit(failureExit) userChoice = int(input(howMany)) while userChoice <= 0 or userChoice > marbles / 2: print(illegalChoice, userChoice, " is too low/high") userChoice = int(input(howMany)) marbles -= userChoice print ("My dawg you don' tooken ", userChoice, " marbies, now there are ", marbles, " marbies still on the table my n-word.") if marbles == 1: print(youWon) exit(victoryExit) exit("Aight. Coo. Coo. Get These Snakes off this motha-fuckin Plane.") ## Presumably you noticed this, but in the code sample you sent me, unless it is the computers turn to go first, basically nothing happens. ## There is no if block capturing what to do if the users turn is first.
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question