You are viewing our Forum Archives. To view or take place in current topics click here.
PYTHON mini game working code below.
Posted:

PYTHON mini game working code below.Posted:

minecrafto
  • Powerhouse
Status: Offline
Joined: Nov 01, 201211Year Member
Posts: 484
Reputation Power: 18
Status: Offline
Joined: Nov 01, 201211Year Member
Posts: 484
Reputation Power: 18
[code]
import random
import sys

print("pick a number between 1 and 10")

computernum = random.randrange(1, 10)
guess1 = input('My guess is:')

if guess1 == computernum:
print("YOU WIN WELL DONE")
else:
print("sorry try again")
print("YOU HAVE 2 GUESSES REMAINING")
guess2 = input("My second guess is:")

if guess2 == computernum:
print("WOW YOUR AMAZING YOU WIN")
else:
print("Sorry, one more try")
print("YOU HAVE ONE FINAL GUESS REMAINING")
guess3 = input("My final guess is:")

if guess3 == computernum:
print("WINNER,WINNER,WINNER,WINNER")
else:
print("GAME OVER ")

print("wanna try again?")

print("if so here we gooo")
print("pick a number")

computernum = random.randrange(1, 100)
guess1 = input('My guess is:')

if guess1 == computernum:
print("YOU WIN WELL DONE")
else:
print("sorry try again")
print("YOU HAVE 2 GUESSES REMAINING")
guess2 = input("my second guess is:")

if guess2 == computernum:
print("WOW YOUR AMAZING YOU WIN")
else:
print("sorry, one more try")
print("YOU HAVE ONE FINAL GUESS REMAINING")
guess3 = input("My final guess is:")

if guess3 == computernum:
print("WINNER,WINNER,WINNER,WINNER")
else:
print("GAME OVER YOU LOOSE")
print("Youre not so good at this then you thought lets step it up a bit ")
print("Pick a number between 1 and 20")


import random
import sys



computernum = random.randrange(1, 20)
guess1 = input('My guess is:')

if guess1 == computernum:
print("YOU WIN WELL DONE")
else:
print("Sorry try again")
#2. Posted:
Huayra
  • TTG Contender
Status: Offline
Joined: Apr 08, 201311Year Member
Posts: 3,101
Reputation Power: 144
Status: Offline
Joined: Apr 08, 201311Year Member
Posts: 3,101
Reputation Power: 144
I'm guessing you use this in school?
#3. Posted:
minecrafto
  • Powerhouse
Status: Offline
Joined: Nov 01, 201211Year Member
Posts: 484
Reputation Power: 18
Status: Offline
Joined: Nov 01, 201211Year Member
Posts: 484
Reputation Power: 18
yes gcse programming why?
#4. Posted:
Tolerated
  • TTG Addict
Status: Offline
Joined: Oct 10, 201112Year Member
Posts: 2,175
Reputation Power: 94
Status: Offline
Joined: Oct 10, 201112Year Member
Posts: 2,175
Reputation Power: 94
I wish they did programming gcses when I was in school, would have learned a lot more, still self teaching is by far the best option. Not bad I would have tried to use cases, they make it cleaner.
#5. Posted:
Odin
  • Christmas!
Status: Offline
Joined: Dec 23, 201013Year Member
Posts: 2,446
Reputation Power: 80
Status: Offline
Joined: Dec 23, 201013Year Member
Posts: 2,446
Reputation Power: 80
Tolerated wrote I wish they did programming gcses when I was in school, would have learned a lot more, still self teaching is by far the best option. Not bad I would have tried to use cases, they make it cleaner.


It depends on your learning style, unfortunately I need to be in a classroom environment to learn optimally..
#6. Posted:
JoeTheSloth
  • New Member
Status: Offline
Joined: Oct 13, 201310Year Member
Posts: 2
Reputation Power: 0
Status: Offline
Joined: Oct 13, 201310Year Member
Posts: 2
Reputation Power: 0
import random
import sys

goAgain = True

print("pick a number between 1 and 10")

while goAgain == True:
    computernum = random.randrange(1, 10)
    guess1 = int(input('My guess is: '))

    if guess1 == computernum:
        print("YOU WIN WELL DONE")
        goAgain = False
    else:
        print("sorry try again")
        print("YOU HAVE 2 GUESSES REMAINING")
    guess2 = int(input("My second guess is: "))

    if guess2 == computernum:
        print("WOW YOUR AMAZING YOU WIN")
        goAgain = False
    else:
        print("Sorry, one more try")
        print("YOU HAVE ONE FINAL GUESS REMAINING")
    guess3 = int(input("My final guess is: "))

    if guess3 == computernum:
        print("WINNER,WINNER,WINNER,WINNER")
        goAgain = False
    else:
        print("GAME OVER ")

    yn = input("wanna try again? ")
   
    if yn == "no":
        goAgain = False


I got bored and actually made your game stop at the end. But it doesnt seem to stop when someone gets it right. Does anybody have any idea on how to stop the loop after they get it right?
#7. Posted:
TheOmgignh2
  • Challenger
Status: Offline
Joined: May 29, 201311Year Member
Posts: 120
Reputation Power: 4
Status: Offline
Joined: May 29, 201311Year Member
Posts: 120
Reputation Power: 4
I made a game like this but with 4 games in one. the second one is like yours.


import random

userName = input("Enter your full name:")
print("Hi,",userName)
usergameNumber = int(input("There are 4 games that you can play. Enter 1 for the first game, 2 for the second game, 3 for the third game or 4 for the fourth game:"))

if usergameNumber == 1:
   
    print("So, " + userName + ", you picked game 1, in this game, you must enter 3 numbers then choose to either display the average of the numbers or the sum of the numbers.")
    input("Press enter to continue...")


    usernumberOne = int(input("Enter a number:"))

    usernumberTwo = int(input("Enter another number:"))

    usernumberThree = int(input("Enter a third number:"))


    average = (usernumberOne + usernumberTwo + usernumberThree) / 3
    add = usernumberOne + usernumberTwo + usernumberThree

    userAnswer = int(input("Press 1 to display the average of the numbers or press 2 do display the sum of the numbers:"))

    if userAnswer == 1:
        print("Well, " + userName + ",the average of all three numbers is",average)

    if userAnswer == 2:
        print("Well, " + userName + ", the sum of all three numbers is",add)
    input("")
                             
   
if usergameNumber == 2:

    print("So, " + userName + ", you picked game 2, in this game you must guess a random number between 1 and 10 in under 3 guesses.")
    input("Press enter to continue...")

    guessesTaken = 0
    myNumber = random.randint(1, 10)

    print("Well, " + userName + ", I am thinking of a number between 1 and 10.")
    print("You have 3 attempts at guessing my number.")
    input("Press enter to start...")

    while guessesTaken < 3:
        print("Take a guess")
        guess = input()
        guess = int(guess)

        guessesTaken = guessesTaken + 1


        if guess < myNumber:
            print("Your guess is too low.")

        if guess > myNumber:
            print("Your guess is too high.")

        if guess == myNumber:
            break

    if guess == myNumber:
        guessesTaken = str(guessesTaken)
        print("Good job, " + userName + "! You guessed my number in " + guessesTaken + " guesses!")

    if guess != myNumber:
        myNumber = str(myNumber)
        print("Unlucky. The number I was thinking of was " + myNumber)
    input("")
       
                             
if usergameNumber == 3:

    print("So, " + userName + ", you picked game 3, this game is a prediction game, you must answer 7 questions about yourself and I will predict your future.")
    input("Press enter to continue...")

    eyeColour = input("Q1: What colour are your eyes?")
    hairColour = input("Q2: What colour is your hair?")
    height = float(input("Q3: What is your height in metres?"))
    skinColour = input("Q4: What colour is your skin?")
    weight = int(input("Q5: What is your weight in kg?"))
    shoeSize = int(input("Q6: What is your shoe size?"))
    age = int(input("Q7: What is your age?"))

    input("Press enter for your prediction...")
    print("You will live to the age of",height + weight,".")
    print("You will have ",age * shoeSize,"in your pocket next week.")
    print("You will marry someone with",hairColour,"eyes and",eyeColour,"hair.")
    print("You might not always have",skinColour,"skin.")
    input("")
   
   
if usergameNumber == 4:

    print("So, " + userName + ", you picked game 4, this game is a true or false game. You will be given 20 statements. After each statement, enter 1 for true or 2 for false.")
    input("Press enter to continue...")

    userScore = 0
   
    statementOne = int(input("1:Japanese snooker tables have shorter legs than normal ones:"))
    statementTwo = int(input("2:Doughnuts originated in Holland:"))
    statementThree = int(input("3:Hollywood film idol Rudolf Valentino choked to death on a golden dildo:"))
    statementFour = int(input("4:Cleopatra was Egyptian:"))
    statementFive = int(input("5:The Egyptian goalkeeper in the 1934 World Cup Finals was called Mustapha Kamel:"))
    statementSix = int(input("6:The Mexican Hat Dance is the official dance of Mexico:"))
    statementSeven = int(input("7:Plastic surgeons in the USA have developed fake testicles for neutered dogs so the appear normal:"))
    statementEight = int(input("8:A Zeedonk is the offspring from a Zebra and a Donkey:"))
    statementNine = int(input("9:King Francis I of Portugal was known as Francis the flatulent:"))
    statementTen = int(input("10:Before forming a band, Dave Dee, Dozy, Beaky, Mick and Titch were all policemen"))
    statementEleven = int(input("11:The outlaw Butch Cassidys father was born in Blackburn Lancashire:"))
    statementTwelve = int(input("12:There is only one river in Saudi Arabia:"))
    statementThirteen = int(input("13:Between 1937 & 1945 in Germany, Heinz did a version of tinned spaghetti shaped like swastikas:"))
    statementFourteen = int(input("14:Dogs are colour blind:"))
    statementFifteen = int(input("15:Women blink twice as much as men:"))
    statementSixteen = int(input("16:The larger a chili pepper, the hotter it is:"))
    statementSeventeen = int(input("Film star John Wayne was in the 1936 US Olympic basket ball team:"))
    statementEighteen = int(input("You can get warts from touching toads:"))
    statementNineteen = int(input("Hair yanked out by the roots will not grow back:"))
    statementTwenty = int(input("Blue is the colour that is liked the most worldwide:"))
   
                         
    if statementOne == 1:
        userScore = userScore + 1
    if statementTwo ==1:
        userScore = userScore + 1
    if statementThree == 2:
        userScore = userScore + 1
    if statementFour == 2:
        userScore = userScore + 1
    if statementFive == 1:
        userScore = userScore + 1
    if statementSix == 1:
        userScore = userScore + 1
    if statementSeven == 1:
        userScore = userScore + 1
    if statementEight == 1:
        userScore = userScore + 1
    if statementNine == 2:
        userScore = userScore + 1
    if statementTen == 2:
        userScore = userScore + 1
    if statementEleven == 2:
        userScore = userScore + 1
    if statementTwelve == 2:
        userScore = userScore + 1
    if statementThirteen == 1:
        userScore = userScore + 1
    if statementFourteen == 2:
        userScore = userScore + 1
    if statementFifteen == 1:
        userScore = userScore + 1
    if statementSixteen == 2:
        userScore = userScore + 1
    if statementSeventeen == 2:
        userScore = userScore + 1
    if statementEighteen == 2:
        userScore = userScore + 1
    if statementNineteen == 2:
        userScore = userScore + 1
    if statementTwenty == 1:
        userScore = userScore + 1

    input("Press enter to find out your final score...")
    print("Well," + userName + ",you scored",userScore,"out of 20.")

    if userScore == 20:
        print("Wow! 100%")

    if userScore < 20:
        if userScore > 15:
            print("So close!")

        if userScore < 15:
            if userScore > 10:
                print("Not bad.")

            if userScore < 10:
                if userScore > 0:
                    print("Unlucky!")

                if userScore == 0:
                    print("That's embarrasing")

   
    input("")   
   


   
       
   
                       
   
   
   
#8. Posted:
ASavile
  • Challenger
Status: Offline
Joined: Oct 18, 201310Year Member
Posts: 178
Reputation Power: 7
Status: Offline
Joined: Oct 18, 201310Year Member
Posts: 178
Reputation Power: 7
minecrafto wrote yes gcse programming why?

hey bro do u live in the UK?
cos im in yr 9, gunnu choose GCSEs soon, and never know you could do programming
#9. Posted:
TheOmgignh2
  • Challenger
Status: Offline
Joined: May 29, 201311Year Member
Posts: 120
Reputation Power: 4
Status: Offline
Joined: May 29, 201311Year Member
Posts: 120
Reputation Power: 4
ASavile wrote
minecrafto wrote yes gcse programming why?

hey bro do u live in the UK?
cos im in yr 9, gunnu choose GCSEs soon, and never know you could do programming


It's not programming it's called computer science, you learn python and how to make apps. I'm in year 10 and started this at the begging of the year. I recommend taking this option.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.