1
00:00:04,670 --> 00:00:08,570
In the previous video I issued you
with a challenge called the if challenge

2
00:00:08,570 --> 00:00:11,200
and in this video we're going to go
through the solution to that.

3
00:00:11,200 --> 00:00:17,820
So I'm going to start by creating a new file in
this project and we'll call it ifchallenge.

4
00:00:22,269 --> 00:00:26,810
Alright so the first step was to get the
name and age from the user and we do

5
00:00:26,810 --> 00:00:36,240
that using input name equals input
parentheses double quotes Please enter your name

6
00:00:36,240 --> 00:00:38,800
and put a colon and a space
there, then our double quote and right

7
00:00:38,809 --> 00:00:47,539
parenthesis. Next line, age equals int left
parentheses input left parenthesis and

8
00:00:47,539 --> 00:00:53,179
double quotes How old are you question
mark and a space there, double quote

9
00:00:53,179 --> 00:00:57,739
and two right parentheses. Alright, so far
so good. So remember to convert the age

10
00:00:57,740 --> 00:01:02,120
to an int using the int function and you can
see that we're using that on line 2.

11
00:01:02,120 --> 00:01:05,540
Now there are fewer ways to write the
conditions. I'm just going to use the

12
00:01:05,540 --> 00:01:10,430
values that we used in the challenge
description. So I'm going to type if 18

13
00:01:10,430 --> 00:01:17,350
is less than or equal to age less then 31:

14
00:01:17,350 --> 00:01:22,250
then I'm going to print a message, print
parenthesis double quotes Welcome to

15
00:01:22,250 --> 00:01:30,049
club 18 to 30 holidays comma then left
and right curly braces with a 0 in the

16
00:01:30,049 --> 00:01:34,250
middle of it. Then outside the double
quote dot format name and the two

17
00:01:34,250 --> 00:01:41,840
closing right parentheses else: on
the next line, print I'm sorry our

18
00:01:41,840 --> 00:01:49,670
holidays are only for cool people. Not sure
how polite that message was. Okay

19
00:01:49,670 --> 00:01:52,820
then we've got a double quote and right
parenthesis to end. Now you might have

20
00:01:52,820 --> 00:01:57,049
checked for the age being greater than
17, or tested for less than or equal to

21
00:01:57,049 --> 00:02:01,759
30. That will also work fine. Importantly
though, test your program thoroughly

22
00:02:01,759 --> 00:02:05,719
and that involves entering ages less than 30,
greater than 30 and also the specific

23
00:02:05,720 --> 00:02:10,940
endpoints 18 and 30. So let's just run
this to make sure that this does

24
00:02:10,940 --> 00:02:14,720
work for us.
Please enter your name, Tim. I'm gonna start with

25
00:02:14,720 --> 00:02:17,780
an age that's less than 18. We'll start with 17.

26
00:02:17,780 --> 00:02:24,280
I'm sorry, our holidays are only for cool people. Same
thing again, Tim again,  just something

27
00:02:24,290 --> 00:02:30,050
greater than 30 so we'll just do a 31
there, I'm sorry. That's working. Next, Tim

28
00:02:30,050 --> 00:02:34,720
again. This time we're going to try the
specific end points, are 18 in this case,

29
00:02:34,720 --> 00:02:44,450
Welcome, should be Welcome to. That's a
typo. Ok, so that's working and the last

30
00:02:44,450 --> 00:02:49,340
one will test is if it equals 30, Welcome
to club

31
00:02:49,340 --> 00:02:53,989
18 to 30 holidays Tim. Alright, so
that's the challenge solution and as I

32
00:02:53,989 --> 00:02:57,680
mentioned again, you might have checked for
the age being greater than 17 or tested

33
00:02:57,680 --> 00:03:01,700
for less than or equal to 30. That will
also work fine. Importantly though, make

34
00:03:01,700 --> 00:03:04,760
sure again, you do test your program
thoroughly. That's always very important,

35
00:03:04,760 --> 00:03:08,900
and you saw me test and what I did there
was I entered an age that was less than

36
00:03:08,900 --> 00:03:13,980
18, that was greater than 30, and then I also
used the specific endpoints 18 and 30

37
00:03:13,980 --> 00:03:17,750
and the program worked as expected.
Alright, so let's end the video here.

38
00:03:17,750 --> 00:03:23,709
In the next one, we're going to start looking at for loops.
See you in the next video.

