You are on page 1of 15

Task 1 Mastermind

ALL MY PYTHON TASKS

Mastermind Success Criteria

Generate a random four digit number (Complete)

The player has to keep inputting 4 digit numbers until they guess
the random one. (Complete)

After each unsuccessful try it should say how many numbers they
got correct but not which ones. (Complete)

At the end of the game it should congratulate the user and say
how many tries it took. (Complete)

Pseudo Code
GUESSED = False
While GUESSED= False:
NUMBER = INPUT(Welcome to guess the number, Please enter your guess)
IF (NOT LEN(NUMBER) == 4):
Print(please enter a four digit number)
ELSE:
1 is added to the GUESSES
IF(NUMBER = STR(MYNUMBER)):
PRINT(Well done! You have guessed the number in + STR(guesses) + Guesses)
ELSE:
FOR INT IN digits:
IF STR(INT) IN STR(NUMBER) AND STR(MYNUMBER):

Variable Table
Identifier

Data Type

Description

Validation

Guesses

String

Stores the number of guesses the


player has before they get it
correct

The variable can store the data


until the code ends. You can
look back at this and use the
variable anytime

myNumber

String

Stores the random number that the


user is guessing

The variable can store the data


until the code ends. You can
look back at this and use the
variable anytime

Digits

Integer

These are all the digits used in the


random number. This is used when
figuring out how many number are
correct.

Guessed

String

Is used to check if the loop is False


or True

Build of my code
I imported a random
number so that can be
guessed by the user.

This displays the number


of guesses it takes to find
the number this is adding
a sense of competition to
the game

These digits are used so the


code knows who to report back
when digits are inputted.

This shows the numbers in


the guess that are correct this
is so the user knows how
many numbers are correct
but not which ones

This generates a
random number
between 1000,9999 so
it is a 4 digit number
to guess.

Build of my code 2

I have commented on the


code inside python and It
tells you what it does.

Build of my code 2

I have commented on the


code inside python and It
tells you what it does.

Problems

I over came some tricky tasks especially how to create a system to tell
the user how many numbers they have got correct. I overcame this by
testing my code many time and using trial and error to work it out.

This is the
part of the
code that I
didnt
understand.
I overcame
this by trying
many times

Test Table
Test
Number

Test
Description

Test Data

Expected
Result

Errors?

Evidence

See how many


digits you have
correct

Displays how
many digits are
correct

yes

Next slide

Generate 4 digit From random


number
import randint

Generates a
random 4
digit number

No

2nd Next slide

Display an input
so that the user
can input a 4
digit number

number =
The user will
input(Welcom input a 4 digit
e to guess the number
number,
Please enter
your guess:)

No

3rd Next slide

Congratulate
the user when
they get the
number correct

4th next slide

Yes

4th next slide

Congratulates
user and tells
them the
number of
guesses

Test 1 Evidence

I didnt specify what the digits were. I


overcame this using knowledge. The digits
had to be added in.

Test 2
Evidence
These show the digits that are
correct. This shows us that a
random number has been imported.

It shows when the number has


been guessed meaning a
random 4 digit number has
been imported.

Test 3
Evidence

This allows the user to


input something after the
text has appeared.

This is where you enter the


4 digit number

Test 4
Evidence

This prints how many


guesses it took and prints
well done to the user this is
the code for it.

Congratulated user and


told them how many
goes it took for the
number to be guessed

Testing
myNumber has been set
to 9324 for testing
reasons.

This is where you enter your guess


and it is stored as a variable.

Shows you how many guesses


it
took you to guess the word.

Shows how many digits are


correct but not which ones.

Evaluation

Last year we created guess the number but a more simplified


version where is just tells you whether the number should be
higher or lower.

Overall I believe I have been very successful in creating the


number guessing game. The thing I enjoyed most was doing the
code as it was the most fun.

You might also like