1
00:00:05,120 --> 00:00:07,680
For this challenge, you'll use the
function that you wrote in the last

2
00:00:07,680 --> 00:00:11,040
exercise. You'll do this
in your ide because the

3
00:00:11,040 --> 00:00:15,360
online python interpreter can't
accept input from the keyboard. The

4
00:00:15,360 --> 00:00:18,800
python interpreter for Udemy's
code exercises is running

5
00:00:18,800 --> 00:00:22,400
on a remote server, so that means that
you're not sitting at its keyboard

6
00:00:22,400 --> 00:00:25,519
and hence have no way
to type in your input.

7
00:00:25,520 --> 00:00:28,800
Alright, so I've got my solution to the
previous exercise showing on screen.

8
00:00:28,800 --> 00:00:33,040
It's in fizzbuzz_challenge.py.
You can download this code

9
00:00:33,040 --> 00:00:36,640
from the resources for this video,
but it would be better to use your

10
00:00:36,640 --> 00:00:41,200
function from the previous exercise,
rather than copying mine. Only use my

11
00:00:41,200 --> 00:00:44,880
function, if you didn't 
complete the previous exercise.

12
00:00:44,880 --> 00:00:49,039
Alright, so looking at the code,
down here on lines 21 and 22, I've got a

13
00:00:49,039 --> 00:00:51,920
loop that tests the fizz buzz function.
The code

14
00:00:51,920 --> 00:00:55,840
that you produced should
have something similar.

15
00:00:56,160 --> 00:01:00,239
Alright, so for this challenge, replace
that loop with a loop that will play the

16
00:01:00,239 --> 00:01:02,800
game. The computer will
start with the value

17
00:01:02,800 --> 00:01:05,680
1 the player and the
computer will then take

18
00:01:05,680 --> 00:01:09,200
turns. The player will type in their
response and the computer

19
00:01:09,200 --> 00:01:12,880
will print out its next value, and so on.
The game ends

20
00:01:12,880 --> 00:01:16,159
when the player makes a
mistake or gets to 100.

21
00:01:16,159 --> 00:01:19,840
If the player gets it wrong, they lose.

22
00:01:20,320 --> 00:01:23,520
So this challenge doesn't involve
writing another function,

23
00:01:23,520 --> 00:01:26,720
rather you're using a function
that you've already written,

24
00:01:26,720 --> 00:01:30,799
in the previous exercise. My solution
to this will be in the next video,

25
00:01:30,799 --> 00:01:34,159
but in the remainder of this video,
I'm going to plan the program

26
00:01:34,159 --> 00:01:37,360
so that we know what we're trying to do.
Now you may want to have a go at that

27
00:01:37,360 --> 00:01:40,000
yourself. Write the steps
in whichever language

28
00:01:40,000 --> 00:01:43,840
you think in. In my case
that's English - or Australian.

29
00:01:43,840 --> 00:01:47,200
When planning a program,
write in your native language.

30
00:01:47,200 --> 00:01:50,320
That way you produce
clear steps describing

31
00:01:50,320 --> 00:01:53,600
what the program's going to do.

32
00:01:53,680 --> 00:01:57,200
If you dive straight in and start
writing code, you will find it very

33
00:01:57,200 --> 00:01:59,280
difficult. So write the
steps in the language that

34
00:01:59,280 --> 00:02:02,880
you're thinking. A good rule is reach
for the pen and paper

35
00:02:02,880 --> 00:02:06,159
before you reach for the keyboard.
Alright so pause the video now and have

36
00:02:06,159 --> 00:02:08,318
a go, or continue watching
if you want to see

37
00:02:08,318 --> 00:02:12,160
my English solution first.

38
00:02:15,680 --> 00:02:19,200
pseudocode is code that you
write in a simplified language,

39
00:02:19,200 --> 00:02:22,319
usually a simple version
of your native language.

40
00:02:22,319 --> 00:02:26,480
It's a simplified version because
computer languages are much simpler

41
00:02:26,480 --> 00:02:29,599
than human languages. You may
find that hard to believe,

42
00:02:29,599 --> 00:02:32,800
Python probably seems quite difficult to
write at the moment,

43
00:02:32,800 --> 00:02:39,040
but programming languages have very few words,
and very few grammatical structures.

44
00:02:39,200 --> 00:02:43,120
It's very easy to say, in English, that
the computer and the player takes turns

45
00:02:43,120 --> 00:02:46,239
but phrasing that with
the limited vocabulary

46
00:02:46,239 --> 00:02:49,440
and grammar of a programming
language needs a bit of thought.

47
00:02:49,440 --> 00:02:53,599
So here's our pseudocode
for this challenge.

48
00:02:53,760 --> 00:02:58,400
The basic steps can be described as:
Calculate the computer's number

49
00:02:58,400 --> 00:03:02,400
which may be a number or maybe fizz buzz
or fizz buzz.

50
00:03:02,400 --> 00:03:06,959
Print the computer's response. Calculate
the player's correct answer.

51
00:03:06,959 --> 00:03:12,480
Get input from the player. Compare the
correct answer to the player's input.

52
00:03:12,480 --> 00:03:16,239
Repeat until the player makes
a mistake or we reach 100.

53
00:03:16,239 --> 00:03:20,959
Print suitable message:
congratulations, or wrong.

54
00:03:20,959 --> 00:03:24,400
You might then refine that slightly,
 to produce something like

55
00:03:24,400 --> 00:03:29,280
call fizzbuzz and print the result (we'll
need a variable to pass to fizzbuzz).

56
00:03:29,280 --> 00:03:33,040
Calculate the player's correct answer.
Increment the variable

57
00:03:33,040 --> 00:03:38,159
that was previously passed to fizzbuzz
and use it again here.

58
00:03:38,319 --> 00:03:41,920
Get input from the player. Check the
player's input against the correct

59
00:03:41,920 --> 00:03:44,480
answer.
If it's not correct break out of the

60
00:03:44,480 --> 00:03:48,720
loop. Print a wrong message.
Repeat until we reach 100 and then print

61
00:03:48,720 --> 00:03:53,200
a suitable congratulations message.
Alright so we've now got the basic

62
00:03:53,200 --> 00:03:55,920
steps that we need to perform.
And we're ready to convert it

63
00:03:55,920 --> 00:04:01,840
to valid python code. I'll go over my
solution in the next video.

