Programming Doccumentation

download Programming Doccumentation

of 8

Transcript of Programming Doccumentation

  • 7/30/2019 Programming Doccumentation

    1/8

    IslingtonCollegeKamal Marg, Kamalpokhari, Kathmandu

    Computer Programming

    Guess Number

    Submitted By: Submitted To:Rupak Bista [12063423] Mr. Sailesh Neupane

  • 7/30/2019 Programming Doccumentation

    2/8

    Table of content

    Introduction.......................................................................................1Screenshots

    Instruction for playing the game................................................2Random number display.............................................................2Prompt to input user numbers.....................................................2Check for number........................................................................3Output if correct...........................................................................3Coding..........................................................................................4 - 6

  • 7/30/2019 Programming Doccumentation

    3/8

    Introduction

    This is a Guessing Numbers Game. In this game computer generates five random

    numbers between 1 - 100. These random numbers are displayed for five second onlyand then those numbers are hidden after five second. After that, player has to inputthose numbers in series as displayed earlier. The numbers entered by the playershould be correct and in correct order, in order to win the game. After the playerwins the game then the player is awarded with $ 10. If the player wins many gamesthen the prize won will be added in his account continuously. The player shouldenter the numbers correctly; simple mistake can led to loss of the game. Player can

    play the game as many times s/he wants to play else can exit the game.

    -1-

  • 7/30/2019 Programming Doccumentation

    4/8

    Screenshots

    Instruction for playing the game

    Random number display

    Prompt to input user numbers

    -2-

  • 7/30/2019 Programming Doccumentation

    5/8

    Check for number

    Output if correct

    -3-

  • 7/30/2019 Programming Doccumentation

    6/8

    Coding

    #rupak bista#may 2013# it i a memory gamefrom random import randrangeimport timefrom string import lowerimport os

    print"Welcome To Game"print "please read the insruction carefully before playing the memory game"time.sleep(3)

    print "At first, the computer displayes five random numbers from 1 to 100."time.sleep(1)

    print "The numbers are displayed only for five seconds and the numbers are hidden"time.sleep(1)

    print "you have to input the five numbers in series as printed earlier!"time.sleep(1)

    print "Each game costs $1, the winner will be awarded a total prize of $10."time.sleep(1)

    gameplayed=0gamelose=0

    gamewon=0point=0#prints the five random numbersa=randrange(1,101)

    b=randrange(1,101)c=randrange(1,101)d=randrange(1,101)e=randrange(1,101)numr=[a,b,c,d,e]

    print"Five random numbers are:"print numrtime.sleep(5)os.system('cls' if os.name=='nt' else 'clear')

    print"Enter the numbers in series"num1=input("Enter the first number:")num2=input("Enter the second number:")num3=input("Enter the third number:")num4=input("Enter the fourth number:")

    num5=input("Enter the fifth number:")

    -4-

  • 7/30/2019 Programming Doccumentation

    7/8

    numu=[num1,num2,num3,num4,num5]print"The number you enter =",numuif numr==numu:

    print"\nCongratulation you won the game"

    gamewon=gamewon+1point=point+10else:

    print"\n Sorry, You lose the game"gamelose=gamelose+1

    gameplayed=gameplayed+1

    print"\nTotal no of game you played =",gameplayedprint"\nTotal no of game you lose =",gameloseprint"\nTotal no of game you won =",gamewonprint"\nTotal point you gain $=","$",pointprint"\nEnter 'y' to play game again and 'n' to quit:"choice=raw_input("Enter the choice (y/n):")while lower(choice)=="y":

    print"Five random numbers are:"a=randrange(1,101)b=randrange(1,101)c=randrange(1,101)d=randrange(1,101)

    e=randrange(1,101)numr=[a,b,c,d,e]print numrtime.sleep(5)os.system('cls' if os.name=='nt' else 'clear')print"Enter the numbers in series"num1=input("Enter the first number:")num2=input("Enter the second number:")num3=input("Enter the third number:")

    num4=input("Enter the fourth number:")num5=input("Enter the fifth number:")numu=[num1,num2,num3,num4,num5]print"The number you enter =",numuif numr==numu:

    print"\nCongratulation you won the game"gamewon=gamewon+1point=point+10

    else:

    print"\nSorry You lose the game"

    -5-

  • 7/30/2019 Programming Doccumentation

    8/8

    print "better luck next time"gamelose=gamelose+1

    gameplayed=gameplayed+1print"\nTotal no of game you played =",gameplayedprint"\nTotal no of game you won =",gamewon

    print"\nTotal no of game you lose =",gameloseprint"\nTotal point you gain $ =","$",pointprint"\nEnter 'y' to play game again and 'n' to quit:"choice=raw_input("Enter the choice(y/n):")

    -6-