3 videos 📅 2024-04-15 08:00:00 America/Chicago
2:57
2024-03-22 14:25:01
2:10
2024-04-15 08:44:21
4:13:43
2024-04-15 09:37:37

Visit the C# for Automation Test Engineers course recordings page

                WEBVTT

00:00:00.640 --> 00:00:02.780
My apologies, it's taking a little bit of time.

00:00:02.840 --> 00:00:04.020
Here we go, okay.

00:00:04.640 --> 00:00:06.560
So let me see what you're seeing here, Colton.

00:00:07.520 --> 00:00:08.860
So let's take a look at your,

00:00:09.000 --> 00:00:11.500
oh, so you need to go to Visual Studio.

00:00:11.680 --> 00:00:13.160
This is a Visual Studio code.

00:00:15.320 --> 00:00:17.760
Yeah, so if you go to your search menu

00:00:18.440 --> 00:00:20.700
and just type Visual, start sending Visual Studio.

00:00:20.940 --> 00:00:22.220
Yeah, there you go.

00:00:23.360 --> 00:00:24.780
Oh, don't do it that way.

00:00:24.780 --> 00:00:26.260
If you do it that way, you're gonna open

00:00:26.260 --> 00:00:29.540
all the activities for the week in Visual Studio.

00:00:29.540 --> 00:00:31.900
Yeah, let's just do it from here.

00:00:34.960 --> 00:00:35.880
Yeah, no, not a problem.

00:00:38.400 --> 00:00:40.060
I have a quick question.

00:00:40.220 --> 00:00:43.180
I'm seeing a framework .NET 08.

00:00:43.300 --> 00:00:44.320
Is that correct?

00:00:45.840 --> 00:00:48.800
Let's see, you're seeing...

00:00:48.800 --> 00:00:51.400
Oh, what comes up in your window here?

00:00:52.480 --> 00:00:53.920
Yeah, I'm about to create

00:00:53.920 --> 00:00:57.140
and it says .NET 08 instead of 472.

00:00:58.200 --> 00:00:59.840
Give me one second.

00:01:00.760 --> 00:01:03.860
How do I minimize this desktop now?

00:01:04.840 --> 00:01:06.820
Well, Anne, did you make sure you are doing

00:01:08.160 --> 00:01:10.620
console.net framework and not just console.net?

00:01:12.020 --> 00:01:12.840
Oh, no.

00:01:13.660 --> 00:01:15.660
I made that mistake, too.

00:01:16.280 --> 00:01:17.960
That was like, I'll just keep going with it.

00:01:18.060 --> 00:01:19.000
That was not the right thing to do.

00:01:19.300 --> 00:01:22.480
I think, yeah, I think on this one, too,

00:01:23.840 --> 00:01:27.480
the previous client was, of course, was four.

00:01:27.800 --> 00:01:30.900
They had a specific version of the .NET framework.

00:01:31.980 --> 00:01:34.680
And so the instructions in some of this material

00:01:34.680 --> 00:01:36.480
are referring to that specific version.

00:01:37.220 --> 00:01:39.460
So honestly, in this one, you could just use

00:01:39.460 --> 00:01:42.060
the console app and it would still work.

00:01:43.400 --> 00:01:47.260
Let me see what you're seeing there.

00:01:48.800 --> 00:01:51.660
Yeah, you can even, yeah, it's fine when you pick that

00:01:51.660 --> 00:01:53.060
and then you're going to see the option there.

00:01:54.800 --> 00:01:55.280
That's fine.

00:01:56.780 --> 00:01:57.840
Okay, thank you.

00:01:58.900 --> 00:02:00.660
So Shane, when you're saying location

00:02:00.660 --> 00:02:02.000
and you're saying starter.

00:02:02.840 --> 00:02:03.320
Yes.

00:02:04.160 --> 00:02:07.280
I'm seeing C user student source equals.

00:02:08.060 --> 00:02:11.860
Am I, are you, is that farther down the road

00:02:11.860 --> 00:02:13.000
where you're talking about the starter?

00:02:13.340 --> 00:02:15.600
No, I'll show you what I mean there.

00:02:16.680 --> 00:02:19.280
No, it's not from, let's see.

00:02:19.960 --> 00:02:22.340
Oh no, I think I went to the wrong desktop.

00:02:22.560 --> 00:02:26.820
I think I went to, yeah, give me a second here.

00:02:31.140 --> 00:02:33.780
I wish I had like bigger names next to these desktops.

00:02:33.960 --> 00:02:36.820
This is a pretty, okay, give me one.

00:02:41.140 --> 00:02:44.460
Oh my gosh, this is like fun, but between Zoom.

00:02:44.860 --> 00:02:47.100
So that's gonna be the default location

00:02:47.100 --> 00:02:48.100
that you're seeing there.

00:02:48.500 --> 00:02:51.460
If you click on that little blue button with the dot, dot,

00:02:52.020 --> 00:02:56.940
dot, and now just on the left side there, pick desktop

00:02:58.020 --> 00:03:00.840
and then pick the C sharp folder there.

00:03:04.720 --> 00:03:06.080
And then go, yeah, just keep going.

00:03:06.140 --> 00:03:09.740
You go into O1 lesson and the activities.

00:03:10.700 --> 00:03:12.480
Sorry, I try to give you a bunch of directories.

00:03:12.620 --> 00:03:16.640
Go to O2 Hello World and then there's the starter folder.

00:03:16.700 --> 00:03:17.920
So double click that starter folder.

00:03:18.800 --> 00:03:21.800
Yeah, and then you select folder at the bottom, right?

00:03:23.160 --> 00:03:23.900
Yeah, perfect.

00:03:24.160 --> 00:03:26.720
So that'll just create it so that when we're done

00:03:26.720 --> 00:03:30.020
with all the course, you'll still have all your files

00:03:30.020 --> 00:03:32.120
and the solutions and everything kind of

00:03:32.120 --> 00:03:33.360
in the same place.

00:03:41.100 --> 00:03:43.000
So this is where we're supposed to be then?

00:03:43.240 --> 00:03:45.720
Yes, yep, that's exactly where you wanna be.

00:03:48.600 --> 00:03:50.160
I promise it gets easier.

00:03:50.680 --> 00:03:52.420
There is a little bit of overhead though, right?

00:03:52.720 --> 00:03:54.000
In getting these things set up.

00:03:56.800 --> 00:03:59.100
Your screen is kind of small too, Shane.

00:03:59.380 --> 00:04:03.560
And I know it's because we're all got our cameras on,

00:04:03.560 --> 00:04:06.060
I would assume, but is there any way

00:04:06.060 --> 00:04:07.740
to make it just a little bit larger?

00:04:08.340 --> 00:04:09.380
When I'm sharing my screen?

00:04:09.900 --> 00:04:10.860
Yeah. Oh, absolutely.

00:04:11.020 --> 00:04:13.240
Yeah, I can zoom in when I do that.

00:04:14.040 --> 00:04:14.680
Okay, thank you.

00:04:14.940 --> 00:04:16.200
I was gonna mention that as well.

00:04:16.200 --> 00:04:17.820
I got bad-ass.

00:04:18.280 --> 00:04:20.120
Yeah, I'm doing this with my glasses.

00:04:20.520 --> 00:04:21.400
I know, I'm going like.

00:04:21.700 --> 00:04:23.980
No, I could feel the pain.

00:04:24.300 --> 00:04:27.340
My eyes are not the same as they used to be either, so.

00:04:30.620 --> 00:04:32.160
Yeah, that attention that I got

00:04:32.160 --> 00:04:33.840
are saying my eyeglasses are ready today.

00:04:34.000 --> 00:04:34.760
I'm like, yay!

00:04:39.360 --> 00:04:41.140
So like, Fist of Five, how are we doing?

00:04:41.660 --> 00:04:43.400
Five, you're finished already?

00:04:44.780 --> 00:04:46.720
This, we need more assistance?

00:04:48.600 --> 00:04:49.080
All right, cool.

00:04:49.580 --> 00:04:50.580
So let's take a look.

00:04:52.120 --> 00:04:53.160
Share my screen here.

00:04:53.200 --> 00:04:55.280
Let's take a look at some solution code

00:04:55.280 --> 00:04:56.220
and we'll just talk again

00:04:56.220 --> 00:04:58.200
about kind of what's going on there.

00:04:59.120 --> 00:04:59.580
All right.

00:04:59.680 --> 00:05:01.700
After writing Python for a while,

00:05:01.860 --> 00:05:04.320
the semi-colons just kill me.

00:05:04.600 --> 00:05:05.760
I'm just like, let's do it.

00:05:06.420 --> 00:05:07.940
It's a little bit different, right?

00:05:08.580 --> 00:05:11.340
Yeah, I'm like, oh, sometimes semi-colons, oh yeah.

00:05:11.900 --> 00:05:13.260
Okay, let's see.

00:05:13.560 --> 00:05:17.840
I think I'm gonna zoom back out and get to my desktop.

00:05:18.460 --> 00:05:19.560
All right.

00:05:21.880 --> 00:05:22.400
Okay.

00:05:26.220 --> 00:05:29.080
All right, I'm actually gonna step back from this

00:05:29.080 --> 00:05:30.460
and show you again.

00:05:32.480 --> 00:05:33.620
All right, so again,

00:05:34.340 --> 00:05:35.980
this is a little bit of overhead that has to happen

00:05:35.980 --> 00:05:39.240
in order for Visual Studio to have all the files

00:05:39.240 --> 00:05:42.120
that it needs in order to run your code.

00:05:42.920 --> 00:05:45.200
And so there's gonna be some things

00:05:45.200 --> 00:05:47.020
it'll need to create, for example,

00:05:48.160 --> 00:05:50.520
if you're running a desktop application,

00:05:50.540 --> 00:05:52.540
versus a web application.

00:05:53.680 --> 00:05:55.000
Is everyone able to see my screen?

00:05:55.040 --> 00:05:57.100
I can zoom in here, I'm pretty sure.

00:05:57.220 --> 00:05:58.000
Let's see.

00:05:58.900 --> 00:05:59.880
The only thing I don't know

00:05:59.880 --> 00:06:01.900
is if this is gonna zoom in on that tool

00:06:01.900 --> 00:06:03.920
or if it's gonna zoom in only for me.

00:06:03.940 --> 00:06:05.060
Let's see here.

00:06:05.560 --> 00:06:06.700
Let's try this.

00:06:10.160 --> 00:06:12.520
Okay, so at the top of my screen,

00:06:12.540 --> 00:06:14.980
are you able to see kind of a zoomed in version there?

00:06:17.360 --> 00:06:20.280
Okay, so anytime you're gonna start working

00:06:20.280 --> 00:06:21.420
with Visual Studio,

00:06:21.540 --> 00:06:23.900
there's gonna be kind of two options you're gonna go to.

00:06:23.980 --> 00:06:25.320
So if we're doing something new,

00:06:25.680 --> 00:06:27.520
it'll be just create a new project option.

00:06:28.240 --> 00:06:29.960
If you're opening something existing,

00:06:30.580 --> 00:06:33.760
there's an open existing project or solution,

00:06:34.420 --> 00:06:37.160
as well as I'll show you that you can just

00:06:38.280 --> 00:06:40.420
double click on that solution file

00:06:40.420 --> 00:06:42.320
right in your Windows Explorer

00:06:42.320 --> 00:06:43.620
and it'll open it as well.

00:06:44.100 --> 00:06:45.560
So these are kind of your two options

00:06:45.560 --> 00:06:46.940
that you're gonna have.

00:06:47.360 --> 00:06:48.920
This create a new project option.

00:06:49.380 --> 00:06:51.040
This is actually the only activity

00:06:51.040 --> 00:06:52.280
we're gonna do this for.

00:06:52.740 --> 00:06:53.860
Just so that you're familiar,

00:06:53.940 --> 00:06:55.980
that you're aware of kind of how these things

00:06:55.980 --> 00:06:57.080
get built and created.

00:06:57.600 --> 00:06:58.700
Everything from here forward

00:06:58.700 --> 00:07:01.680
will actually have a starter file

00:07:01.680 --> 00:07:03.040
for you to work with already.

00:07:03.680 --> 00:07:05.200
But it's important to understand

00:07:05.200 --> 00:07:06.660
kind of where these things come from.

00:07:07.880 --> 00:07:09.860
You're gonna see that there's lots and lots

00:07:09.860 --> 00:07:12.220
of different templates that are available.

00:07:13.000 --> 00:07:15.040
And the particular one that we're using here

00:07:15.040 --> 00:07:16.580
is gonna be this console app.

00:07:17.340 --> 00:07:19.120
Again, if that doesn't appear,

00:07:19.700 --> 00:07:21.920
you can always type in your search up here.

00:07:21.940 --> 00:07:24.100
You can type for different kinds of applications

00:07:24.100 --> 00:07:25.460
to find those.

00:07:26.480 --> 00:07:28.440
So in this case, I just say console.

00:07:29.800 --> 00:07:32.700
And you're gonna see there's different types of apps

00:07:32.700 --> 00:07:33.580
that are available.

00:07:34.580 --> 00:07:37.620
So in this example, I'm just gonna go and pick

00:07:37.620 --> 00:07:39.540
an option here.

00:07:40.260 --> 00:07:42.300
And where's the scroll bar now?

00:07:42.580 --> 00:07:43.440
Oh my gosh.

00:07:47.560 --> 00:07:49.180
There we go, okay.

00:07:51.500 --> 00:07:53.000
And then on this next screen,

00:07:53.060 --> 00:07:54.680
what you'll see is you're gonna get

00:07:54.680 --> 00:07:56.280
a couple more choices, right?

00:07:56.600 --> 00:07:58.900
So here when I'm configuring my project,

00:07:59.440 --> 00:08:00.540
the first thing I'm gonna get

00:08:00.540 --> 00:08:01.860
is the name of that project.

00:08:02.300 --> 00:08:05.400
So in this case, we called it Hello World.

00:08:09.320 --> 00:08:10.420
Oh, there's a little bit of a lag.

00:08:10.540 --> 00:08:11.620
If you could see what I'm typing.

00:08:12.580 --> 00:08:14.220
So we're gonna call it Hello World.

00:08:14.860 --> 00:08:16.320
And this is gonna just be the name

00:08:16.320 --> 00:08:18.920
that it'll use to name that file, right?

00:08:19.680 --> 00:08:21.940
So typically you wanna make this something friendly.

00:08:22.500 --> 00:08:24.400
If I called it Hello World

00:08:24.400 --> 00:08:28.480
and then it actually did my taxes or something else,

00:08:28.620 --> 00:08:29.800
it would be confusing, right?

00:08:29.800 --> 00:08:31.880
So you wanna pick a descriptive name for this.

00:08:32.160 --> 00:08:33.340
Something that's gonna make sense

00:08:33.340 --> 00:08:35.240
to whatever it is you're actually working on.

00:08:36.380 --> 00:08:40.580
And then this location is gonna be where in your files

00:08:40.580 --> 00:08:44.020
it's gonna actually create these files for you.

00:08:44.200 --> 00:08:46.280
And again, for this one,

00:08:47.720 --> 00:08:49.900
I just browsed with my browser

00:08:49.900 --> 00:08:51.580
into the activity folder.

00:08:51.620 --> 00:08:55.180
So into that C sharp and lessons and activities

00:08:55.180 --> 00:08:56.980
and just created it in here.

00:09:00.700 --> 00:09:02.480
All right, I'm gonna cancel out.

00:09:02.540 --> 00:09:04.920
I'm not gonna actually finish creating that particular one.

00:09:04.960 --> 00:09:07.400
We'll take a look at the one we did create though.

00:09:12.860 --> 00:09:15.800
So I'm gonna cancel out of that.

00:09:17.840 --> 00:09:20.320
And then I'll show you,

00:09:22.060 --> 00:09:23.500
there we go, fantastic.

00:09:23.880 --> 00:09:24.820
I'll show you the other way.

00:09:24.880 --> 00:09:26.740
So since this is already existing,

00:09:30.880 --> 00:09:33.940
here I am in the Hello World folder.

00:09:36.520 --> 00:09:38.480
I'm gonna go back up a folder.

00:09:42.440 --> 00:09:44.140
And so in this solved version,

00:09:44.860 --> 00:09:46.960
you're gonna see that there's already

00:09:47.680 --> 00:09:49.460
the solution file already exists.

00:09:49.660 --> 00:09:51.420
So if I just double click on that,

00:09:51.820 --> 00:09:53.580
that'll actually open that in Visual Studio

00:09:53.580 --> 00:09:54.520
for me as well.

00:09:56.060 --> 00:09:57.520
So Windows is smart enough to know,

00:09:57.520 --> 00:09:59.360
oh, that's the Visual Studio solution.

00:09:59.360 --> 00:10:01.680
Let me open that in Visual Studio for you.

00:10:02.320 --> 00:10:04.640
And you can see that that opens that up for me.

00:10:08.340 --> 00:10:10.580
So what is this project doing for me?

00:10:11.920 --> 00:10:13.640
This is gonna allow me to create

00:10:13.640 --> 00:10:15.680
different kinds of things, right?

00:10:16.480 --> 00:10:17.220
So in this case,

00:10:17.240 --> 00:10:19.280
I'm gonna be able to create this little application

00:10:19.280 --> 00:10:19.920
that we were running.

00:10:20.500 --> 00:10:22.440
And if I go ahead and click start,

00:10:28.700 --> 00:10:31.540
you're gonna see that that will come up and run,

00:10:32.520 --> 00:10:36.000
and it'll print that message out on the screen for me.

00:10:38.860 --> 00:10:40.740
All right, so that's the most important takeaway

00:10:40.740 --> 00:10:43.440
that you're gonna have some files that you'll work with,

00:10:44.440 --> 00:10:46.440
how to open those in Visual Studio,

00:10:46.940 --> 00:10:48.800
and then the fact that you can use

00:10:48.800 --> 00:10:50.600
that little start button or play button

00:10:50.600 --> 00:10:51.920
to actually run your code

00:10:51.920 --> 00:10:52.420
and see what you're doing.

00:10:52.420 --> 00:10:54.220
That's what your code is gonna do for you.

00:10:55.540 --> 00:10:57.800
All right, let's take a look at actually

00:10:58.560 --> 00:10:59.680
writing some code,

00:10:59.860 --> 00:11:00.940
learning how to write some code.

00:11:02.640 --> 00:11:04.380
All right, let me close this.

00:11:20.520 --> 00:11:22.300
All right, so all the activity is going for,

00:11:22.300 --> 00:11:23.760
you're gonna see that, in this case,

00:11:23.780 --> 00:11:25.520
I've got starter files for it.

00:11:25.660 --> 00:11:27.780
So I'll actually be able to just start

00:11:27.780 --> 00:11:28.940
with that existing solution.

00:11:29.020 --> 00:11:30.760
I won't have to create those from scratch.

00:11:34.160 --> 00:11:36.120
And from this activity forward,

00:11:36.180 --> 00:11:38.140
we're gonna focus just on the code itself.

00:11:39.160 --> 00:11:41.060
So once that opens, you're gonna see,

00:11:41.340 --> 00:11:43.580
I'll have my variables project over here.

00:11:43.600 --> 00:11:45.860
Oh, you were asking me about zooming in on this, right?

00:11:47.700 --> 00:11:48.580
Let's see.

00:11:48.820 --> 00:11:50.920
Am I gonna be able to zoom?

00:11:51.600 --> 00:11:52.960
Are you gonna allow me to do that?

00:11:56.140 --> 00:11:56.840
Are you able to see that?

00:11:57.000 --> 00:11:58.780
Is that zoomed in for you on the top there?

00:11:59.160 --> 00:11:59.620
Okay.

00:11:59.980 --> 00:12:03.180
So here are my variables project.

00:12:03.600 --> 00:12:05.340
If I click to expand that,

00:12:05.940 --> 00:12:08.180
I'm gonna see there's some code files under here.

00:12:08.180 --> 00:12:10.340
So this program.cs file.

00:12:11.020 --> 00:12:12.820
And if I double click that,

00:12:13.980 --> 00:12:18.180
that will open it for me here in my editor.

00:12:21.440 --> 00:12:22.400
All right.

00:12:22.700 --> 00:12:25.880
We'll talk as we go through about some of this stuff

00:12:25.880 --> 00:12:27.700
that Visual Studio is creating for me.

00:12:27.900 --> 00:12:31.160
So this using and the namespace, all this.

00:12:31.300 --> 00:12:33.460
We'll talk about that as we get further along.

00:12:33.900 --> 00:12:35.860
For right now, the key thing to keep in mind

00:12:35.860 --> 00:12:37.800
is that all the code we're gonna write

00:12:37.800 --> 00:12:40.720
will be inside this thing called main.

00:12:41.000 --> 00:12:43.220
So this is where we're gonna write all the code

00:12:43.220 --> 00:12:45.020
that we wanna actually write and run.

00:12:45.260 --> 00:12:47.600
And we'll let Visual Studio for right now

00:12:47.600 --> 00:12:50.560
sort of create the rest of that framework for us.

00:12:50.960 --> 00:12:52.860
And we'll just focus on the code we'll write.

00:12:53.260 --> 00:12:55.700
And then once we've understand what the code is doing

00:12:55.700 --> 00:12:56.560
a little bit better,

00:12:56.840 --> 00:12:58.160
then we'll come back and talk about

00:12:58.160 --> 00:13:01.300
what some of these things mean out here.

00:13:01.720 --> 00:13:02.580
But for right now,

00:13:02.760 --> 00:13:04.300
Visual Studio will create that for us,

00:13:04.320 --> 00:13:06.280
that sort of template.

00:13:06.700 --> 00:13:08.240
And we'll just focus on the code

00:13:08.240 --> 00:13:09.620
that we write inside here.

00:13:11.080 --> 00:13:12.840
So let's try writing some code.

00:13:14.560 --> 00:13:16.180
So the first thing you're gonna notice

00:13:16.180 --> 00:13:17.740
as we start writing code.

00:13:19.100 --> 00:13:22.820
Oh, it's lagged a little bit, I think.

00:13:23.700 --> 00:13:24.760
There we go.

00:13:26.260 --> 00:13:27.280
Okay, there we go.

00:13:29.940 --> 00:13:31.360
The first thing you're gonna notice

00:13:31.360 --> 00:13:33.060
as you start writing code is

00:13:33.060 --> 00:13:36.120
any time we wanna write our programs to do things,

00:13:36.140 --> 00:13:38.480
and I'm sure you're seeing this in Python already,

00:13:39.960 --> 00:13:41.700
we have things that we wanna track,

00:13:41.740 --> 00:13:43.160
data that we wanna track.

00:13:43.800 --> 00:13:45.580
And just like in Python,

00:13:46.240 --> 00:13:48.200
we're gonna track that in variables.

00:13:48.800 --> 00:13:50.120
So the variables are gonna be

00:13:50.120 --> 00:13:53.200
how we'll know what we wanna track.

00:13:53.420 --> 00:13:55.700
So what might be some examples of things

00:13:55.700 --> 00:13:58.680
that we would wanna track in a program?

00:13:59.860 --> 00:14:00.480
A counter?

00:14:02.360 --> 00:14:02.920
Yeah, exactly.

00:14:03.000 --> 00:14:04.880
So maybe a counter we wanna keep track of

00:14:04.880 --> 00:14:06.760
how many times something has happened

00:14:06.760 --> 00:14:08.780
or how many times something is run,

00:14:08.780 --> 00:14:09.960
something like that, right?

00:14:10.800 --> 00:14:12.560
What might be some other examples

00:14:12.560 --> 00:14:14.860
of things we would wanna track in a program?

00:14:16.960 --> 00:14:20.620
The idea of an activity in MES web.

00:14:23.680 --> 00:14:25.540
That seems very specific.

00:14:28.220 --> 00:14:30.400
Something like the activity ID, right?

00:14:30.500 --> 00:14:30.900
Yeah.

00:14:31.980 --> 00:14:33.400
Oh, okay, all right.

00:14:35.180 --> 00:14:36.160
Oh, let's try that.

00:14:36.160 --> 00:14:41.160
Would it be like the result of a mathematical expression?

00:14:42.140 --> 00:14:42.680
Yeah, absolutely.

00:14:42.940 --> 00:14:44.580
So something like a result, right?

00:14:44.940 --> 00:14:47.680
So in programming or in code in general,

00:14:48.200 --> 00:14:50.140
there's lots of data we wanna work with

00:14:50.140 --> 00:14:51.120
and things we wanna track.

00:14:51.660 --> 00:14:55.240
And so what we'll do to track that in most languages

00:14:55.240 --> 00:14:56.980
is we'll create something called variables.

00:14:57.760 --> 00:14:59.580
So these things we've created here

00:14:59.580 --> 00:15:02.220
are basically gonna be,

00:15:02.880 --> 00:15:03.820
it's trying to like help me,

00:15:03.820 --> 00:15:04.680
but it's not being helpful.

00:15:05.220 --> 00:15:06.580
These things we've created here

00:15:06.580 --> 00:15:08.280
are all things we wanna keep track of.

00:15:08.460 --> 00:15:10.740
And so we'll keep track of those with variables.

00:15:11.380 --> 00:15:13.660
And a variable is just gonna be a way

00:15:13.660 --> 00:15:15.700
to store information or store data

00:15:15.700 --> 00:15:17.220
that we wanna keep track of.

00:15:18.740 --> 00:15:20.540
In C Sharp specifically though,

00:15:20.540 --> 00:15:22.220
we have to have a couple of things

00:15:22.220 --> 00:15:23.780
in order to create a variable.

00:15:24.420 --> 00:15:26.620
So we already have name for this thing,

00:15:26.620 --> 00:15:29.020
but we also have to say,

00:15:29.600 --> 00:15:32.660
what type of data do we wanna store here?

00:15:33.220 --> 00:15:36.460
So I'll have to do something like this, for example.

00:15:40.000 --> 00:15:42.380
And I'll give you a couple of examples

00:15:42.380 --> 00:15:45.040
and then we'll talk about this.

00:15:45.500 --> 00:15:47.120
So this is probably also,

00:15:49.660 --> 00:15:51.860
it's probably actually a different type of data,

00:15:52.060 --> 00:15:53.620
but just pretend with me.

00:15:54.080 --> 00:15:59.440
And yeah, maybe this is also a data type as well.

00:16:02.980 --> 00:16:04.520
So in C Sharp,

00:16:05.160 --> 00:16:07.540
not only do we have to have a name for a variable,

00:16:07.600 --> 00:16:08.860
so here's gonna be the name of,

00:16:08.940 --> 00:16:10.040
we'll call this thing counter,

00:16:10.540 --> 00:16:12.020
but I have to tell C Sharp,

00:16:12.400 --> 00:16:15.820
what kind of data do I want to store in this variable?

00:16:17.000 --> 00:16:20.320
And C Sharp will take that information that I give it

00:16:20.320 --> 00:16:21.680
and do a couple of things with it.

00:16:21.720 --> 00:16:23.300
One is it's gonna say,

00:16:23.660 --> 00:16:24.840
oh, how much space do I need

00:16:24.840 --> 00:16:26.180
to set aside for this thing?

00:16:27.040 --> 00:16:29.520
And the other thing it's gonna do is that,

00:16:29.520 --> 00:16:33.480
if sometime later you try to put data into there,

00:16:33.520 --> 00:16:35.680
into that variable that doesn't match

00:16:35.680 --> 00:16:38.540
the type that you told it that it was,

00:16:39.020 --> 00:16:40.540
C Sharp will actually tell you that,

00:16:40.820 --> 00:16:43.680
hey, you're trying to store something in there

00:16:43.680 --> 00:16:44.540
that you told me

00:16:44.540 --> 00:16:46.520
that you were gonna store something different in.

00:16:46.760 --> 00:16:48.200
And that's really important

00:16:48.840 --> 00:16:50.980
because you might've done that accidentally

00:16:51.760 --> 00:16:54.020
or you might not realize it's a different data type.

00:16:54.560 --> 00:16:56.260
So in this example here,

00:16:56.260 --> 00:17:00.780
I'm saying I wanna have something of a number type

00:17:00.780 --> 00:17:01.840
or an int type,

00:17:02.320 --> 00:17:04.800
and I wanna store this in a variable called counter,

00:17:05.520 --> 00:17:07.680
and then I'm gonna have different data types

00:17:07.680 --> 00:17:08.560
that are available to me.

00:17:08.680 --> 00:17:10.780
We'll talk more as I go through this

00:17:10.780 --> 00:17:12.520
about the different data types that are available.

00:17:13.080 --> 00:17:14.540
But the key takeaway here

00:17:14.540 --> 00:17:17.700
is that you wanna be able to tell C Sharp,

00:17:18.860 --> 00:17:20.040
the type something is,

00:17:20.120 --> 00:17:22.300
what kind of data do I wanna store in this?

00:17:22.760 --> 00:17:24.100
And then you're gonna give it a name

00:17:24.100 --> 00:17:27.140
in order to be able to refer to that.

00:17:28.480 --> 00:17:30.640
So I'll show you the other example here.

00:17:31.120 --> 00:17:35.860
Let's do something like maybe a file name.

00:17:35.900 --> 00:17:37.760
So maybe I wanna keep track of a file name.

00:17:38.540 --> 00:17:40.780
So again, I have to give it a certain data type,

00:17:40.820 --> 00:17:42.440
and then I have to give it a name.

00:17:43.380 --> 00:17:46.260
You're gonna notice also C Sharp always ends

00:17:46.260 --> 00:17:47.300
in a semicolon.

00:17:47.520 --> 00:17:48.480
So every line,

00:17:48.820 --> 00:17:51.520
how the computer knows that one line

00:17:51.520 --> 00:17:53.040
is different from the next line

00:17:53.040 --> 00:17:54.900
is actually the semicolon.

00:17:56.240 --> 00:17:57.500
So if I don't put that in,

00:17:57.600 --> 00:17:58.940
I think you'll notice I'm getting

00:17:58.940 --> 00:18:01.780
like a kind of a red error there when I do that.

00:18:04.460 --> 00:18:08.800
And a string is gonna just be data like character data,

00:18:08.940 --> 00:18:11.720
like a first name or a file name,

00:18:13.060 --> 00:18:14.620
paragraph, something that would be a string.

00:18:15.100 --> 00:18:17.080
Now, all I've done here on this line

00:18:17.080 --> 00:18:20.600
is just created this variable, the name of it,

00:18:20.600 --> 00:18:22.920
and what type it is.

00:18:23.640 --> 00:18:26.720
How do I actually get data in that variable?

00:18:28.440 --> 00:18:30.860
So in C Sharp, I'll use the name of that variable,

00:18:31.800 --> 00:18:33.200
and then the equal sign,

00:18:33.980 --> 00:18:38.120
and then that'll allow me to assign some data to there.

00:18:38.140 --> 00:18:40.260
So maybe I'll do something like this.

00:18:43.880 --> 00:18:46.600
So the equal sign is basically saying,

00:18:46.600 --> 00:18:51.300
take whatever data is on the right side of this

00:18:52.040 --> 00:18:55.060
and store that in that variable.

00:18:58.960 --> 00:19:00.820
Any questions on that part so far?

00:19:01.020 --> 00:19:01.900
For the file name,

00:19:02.080 --> 00:19:03.520
so you don't have to do like a,

00:19:04.440 --> 00:19:06.440
I said, give you a whole path.

00:19:07.940 --> 00:19:09.580
What was the question for file name?

00:19:10.300 --> 00:19:11.860
I'm wondering for a file name,

00:19:11.900 --> 00:19:14.880
do you have to give like a whole file path name

00:19:14.880 --> 00:19:17.660
or you just have, it just doesn't set

00:19:17.660 --> 00:19:21.800
whatever inside this folder it will look for a name?

00:19:22.500 --> 00:19:25.280
Oh, we can, we'll talk more about paths in a little bit,

00:19:25.560 --> 00:19:27.480
but for right now, just keep in mind,

00:19:27.640 --> 00:19:29.060
like if any kind of character data

00:19:29.060 --> 00:19:31.240
or string data that I wanna store in here,

00:19:31.760 --> 00:19:33.280
this is how I would do it.

00:19:33.280 --> 00:19:35.040
So I declare this variable,

00:19:35.480 --> 00:19:38.060
and then I'm able to assign stuff in there

00:19:38.560 --> 00:19:39.620
using the equal sign.

00:19:39.680 --> 00:19:41.380
So equal sign is what's gonna allow me

00:19:41.380 --> 00:19:43.300
to actually assign data into that.

00:19:46.280 --> 00:19:46.980
Great question.

00:19:47.160 --> 00:19:48.800
Yeah, we'll talk more about files

00:19:48.800 --> 00:19:50.200
as we work with files later on.

00:19:51.040 --> 00:19:53.000
So, oh, go ahead.

00:19:53.660 --> 00:19:54.980
Sorry, who was that?

00:19:55.120 --> 00:19:56.040
Is that Harry again?

00:19:56.460 --> 00:19:56.620
No.

00:19:57.540 --> 00:19:58.780
Oh, no, go ahead, Maria, I'm sorry.

00:19:59.820 --> 00:20:02.780
Oh, I was just gonna ask what,

00:20:03.060 --> 00:20:04.900
so you'll probably cover this later,

00:20:04.960 --> 00:20:06.360
so this might, I don't know.

00:20:06.920 --> 00:20:08.640
You might tell me, just wait, we'll get to it.

00:20:08.720 --> 00:20:09.980
But what is the difference,

00:20:10.600 --> 00:20:12.780
like what is the different use case for,

00:20:12.780 --> 00:20:14.940
you declare the type of a variable

00:20:14.940 --> 00:20:15.920
and then you set the variable

00:20:15.920 --> 00:20:17.780
versus using like the far keyword?

00:20:19.100 --> 00:20:20.880
Oh, absolutely, we'll talk about this.

00:20:22.460 --> 00:20:23.820
So I just wanna show you

00:20:23.820 --> 00:20:25.440
that there's actually two parts to this.

00:20:25.500 --> 00:20:28.760
So you can declare variables ahead of time.

00:20:28.920 --> 00:20:30.120
You're always gonna have to say,

00:20:30.220 --> 00:20:31.920
if I want things that I wanna track

00:20:31.920 --> 00:20:32.780
or I wanna store,

00:20:33.280 --> 00:20:35.940
you'll have to, ahead of time, let C-sharp know,

00:20:36.520 --> 00:20:38.440
here's something I am interested in tracking.

00:20:38.860 --> 00:20:40.940
So by saying string file name,

00:20:41.460 --> 00:20:43.080
I'm letting C-sharp know,

00:20:43.600 --> 00:20:45.720
hey, there's this data that I'm interested in tracking.

00:20:45.800 --> 00:20:47.180
I'm gonna call it file name.

00:20:47.740 --> 00:20:50.080
Here's the type of data that'll go in there.

00:20:50.440 --> 00:20:53.640
And then later on, I'll use that.

00:20:54.060 --> 00:20:55.880
And then when I decide to use it,

00:20:55.920 --> 00:21:00.020
I'll actually assign values or store data in there.

00:21:00.260 --> 00:21:01.960
So this file name equals read me

00:21:01.960 --> 00:21:05.080
is actually storing read me in that file name.

00:21:05.840 --> 00:21:07.840
And I think, Maria, what you were just asking is,

00:21:08.000 --> 00:21:09.940
well, couldn't I just do this instead?

00:21:09.940 --> 00:21:13.440
Couldn't I just say, for example,

00:21:18.900 --> 00:21:20.380
couldn't I just do something like this

00:21:20.380 --> 00:21:23.620
where I just say string first name and then equals it?

00:21:24.120 --> 00:21:25.080
You absolutely can.

00:21:25.220 --> 00:21:27.960
You can actually do both of those things at the same time.

00:21:28.420 --> 00:21:30.600
So you're actually doing two things at once here.

00:21:30.600 --> 00:21:32.020
So I'm just showing you that

00:21:32.620 --> 00:21:34.400
there's the declaring variable part

00:21:34.400 --> 00:21:35.660
and then there's the assigning it.

00:21:35.880 --> 00:21:38.300
And you can absolutely do both at the same time.

00:21:40.840 --> 00:21:42.900
That was your question, I think, right?

00:21:48.280 --> 00:21:50.020
Why would you do one versus the other?

00:21:50.140 --> 00:21:51.980
I think that was the other part of your question.

00:21:53.360 --> 00:21:54.100
Was that the other part?

00:21:55.860 --> 00:21:59.260
So if in this case, I know at the time

00:21:59.260 --> 00:22:00.180
that I'm creating this,

00:22:00.300 --> 00:22:02.200
I know exactly what that data is gonna be.

00:22:02.480 --> 00:22:04.860
I could just assign it right at the time I'm using it.

00:22:05.740 --> 00:22:08.000
What if I wanted to ask the user

00:22:08.840 --> 00:22:10.620
what file name they wanted the user,

00:22:10.660 --> 00:22:12.200
what their first name is.

00:22:12.640 --> 00:22:14.400
Or so for example, say last name.

00:22:14.900 --> 00:22:16.600
So here I could say,

00:22:16.600 --> 00:22:18.860
let's create a variable called last name.

00:22:19.200 --> 00:22:20.820
And I don't know at this point

00:22:20.820 --> 00:22:22.180
what data is gonna go in there.

00:22:22.660 --> 00:22:23.500
At some point later,

00:22:23.500 --> 00:22:25.900
I'm gonna ask the user what that information is.

00:22:26.300 --> 00:22:28.060
So I know that I need it.

00:22:28.060 --> 00:22:29.740
I would still have to declare that variable.

00:22:29.980 --> 00:22:31.080
And then later on,

00:22:31.100 --> 00:22:32.980
something will assign data into that.

00:22:33.840 --> 00:22:36.060
That's the only reason you would do one versus the other.

00:22:36.660 --> 00:22:37.780
Does that answer your question?

00:22:38.680 --> 00:22:39.680
Yeah, thank you.

00:22:39.920 --> 00:22:40.560
Perfect, okay.

00:22:41.020 --> 00:22:43.260
So the only other question we have now is,

00:22:43.900 --> 00:22:45.780
we know that we have to have a name for variable.

00:22:45.880 --> 00:22:47.060
We know we have to have a data type.

00:22:47.280 --> 00:22:49.360
How do I know what data types are available

00:22:49.360 --> 00:22:52.520
or even what those different data types would represent?

00:22:57.000 --> 00:23:00.000
This is a question for you all, the class.

00:23:00.540 --> 00:23:02.720
How do I know what the data types are available

00:23:02.720 --> 00:23:03.940
or what's even out there?

00:23:06.060 --> 00:23:07.220
I would probably Google.

00:23:08.120 --> 00:23:10.160
Yeah, absolutely, absolutely.

00:23:10.940 --> 00:23:14.080
So you're gonna see Google as your friend, absolutely.

00:23:14.560 --> 00:23:15.260
So we're gonna,

00:23:15.940 --> 00:23:17.540
I'll provide you in the activity,

00:23:17.640 --> 00:23:19.160
you'll see that I'm gonna give you a list

00:23:19.160 --> 00:23:20.780
of different data types that are available.

00:23:21.680 --> 00:23:22.580
But yeah, absolutely,

00:23:22.620 --> 00:23:23.960
Google is gonna be your friend

00:23:23.960 --> 00:23:25.600
to know what those things are.

00:23:26.100 --> 00:23:29.140
And if you take a look here in the activity coming up

00:23:33.600 --> 00:23:35.480
in that read me for the activity,

00:23:36.320 --> 00:23:39.820
we're actually gonna give you

00:23:39.820 --> 00:23:42.720
some examples of what those different data types are.

00:23:45.320 --> 00:23:46.820
So here's a little chart

00:23:46.820 --> 00:23:48.300
that'll have different data types.

00:23:51.160 --> 00:23:53.100
Are you familiar with Boolean types?

00:23:53.340 --> 00:23:54.440
Do you use those currently?

00:23:55.000 --> 00:23:58.740
Okay, so everyone knows what a Boolean type is?

00:23:58.740 --> 00:24:01.080
So Boolean is really just true or false.

00:24:01.940 --> 00:24:03.680
If you're only storing true or false,

00:24:03.780 --> 00:24:05.520
there's a special data type for that

00:24:05.520 --> 00:24:06.500
that'll make that simpler.

00:24:06.580 --> 00:24:07.680
So that will be Boolean.

00:24:08.500 --> 00:24:10.260
There's a lot of data types in this list.

00:24:10.280 --> 00:24:11.820
We're not gonna use all of these,

00:24:12.120 --> 00:24:14.300
but the common ones we're gonna use,

00:24:15.180 --> 00:24:17.620
you'll see string we're gonna be using very commonly.

00:24:18.060 --> 00:24:19.960
And then there's actually lots

00:24:19.960 --> 00:24:21.800
of different data types for numbers.

00:24:22.740 --> 00:24:24.680
And the difference between those you're gonna see

00:24:24.680 --> 00:24:28.940
is what the size of the number you can store in there is.

00:24:30.260 --> 00:24:34.580
So for example, let me go back to my code window here.

00:24:38.060 --> 00:24:41.080
And let me just close this guy out.

00:24:49.980 --> 00:24:51.080
Yeah, it seems like it takes

00:24:51.080 --> 00:24:52.840
just a little bit of time there, unfortunately,

00:24:52.840 --> 00:24:54.080
a little bit of a...

00:24:58.580 --> 00:25:00.200
Let me move this window around.

00:25:01.000 --> 00:25:02.560
Zoom wants to sit on top of everything

00:25:02.560 --> 00:25:04.080
at the bottom of the screen, apparently.

00:25:06.300 --> 00:25:07.180
Here we go.

00:25:08.160 --> 00:25:10.500
So let me go ahead and show you.

00:25:24.760 --> 00:25:26.140
Hmm, yeah, it's interesting.

00:25:26.440 --> 00:25:28.540
I actually picked a larger size machine

00:25:28.540 --> 00:25:30.780
or more memories that these would open faster,

00:25:30.960 --> 00:25:32.440
but it still seems a little bit slow.

00:25:33.340 --> 00:25:36.500
Yes, seems like everything looks good on my end.

00:25:38.020 --> 00:25:38.880
Yeah, yeah, it's interesting.

00:25:38.960 --> 00:25:42.740
It still takes a little bit of time, but...

00:25:42.740 --> 00:25:44.080
All right, so let's take a look.

00:25:44.140 --> 00:25:45.380
So here we were talking before.

00:25:45.520 --> 00:25:46.700
Let me zoom in on that for you

00:25:46.700 --> 00:25:48.180
so you can see what I'm talking about there.

00:25:50.460 --> 00:25:52.820
So we were talking before that file name

00:25:52.820 --> 00:25:53.380
is a good example.

00:25:53.420 --> 00:25:55.920
Again, you're gonna have to have a name for a variable

00:25:55.920 --> 00:25:58.220
as well as the type of the variable.

00:25:59.120 --> 00:26:00.500
And then when you're assigning

00:26:00.500 --> 00:26:02.300
and actually assigning data to it,

00:26:02.480 --> 00:26:03.700
you'll use the equal sign.

00:26:05.900 --> 00:26:09.180
And then how would we actually use that data?

00:26:09.240 --> 00:26:13.500
Well, you can see here that when I'm writing some code,

00:26:13.700 --> 00:26:15.880
this right line we'll talk more about

00:26:15.880 --> 00:26:17.020
as we get further in,

00:26:17.060 --> 00:26:20.660
but this is gonna be a built-in ability for us

00:26:20.660 --> 00:26:22.900
to be able to write things out to the window.

00:26:23.920 --> 00:26:24.700
And so you're gonna see,

00:26:24.740 --> 00:26:27.520
if I just write out the name of that variable,

00:26:28.720 --> 00:26:31.260
it'll actually take and look at the value

00:26:31.260 --> 00:26:32.800
that's stored in that variable,

00:26:32.900 --> 00:26:34.860
and that's what'll get displayed on the screen.

00:26:35.680 --> 00:26:37.120
So if I run this,

00:26:38.560 --> 00:26:40.540
let me go ahead and hit the little green play button

00:26:40.540 --> 00:26:41.480
here, the start button.

00:26:42.080 --> 00:26:43.780
It'll build that code

00:26:47.020 --> 00:26:48.300
and run that.

00:26:51.980 --> 00:26:54.200
And you're gonna see when it writes that out,

00:26:54.200 --> 00:26:56.140
it's gonna say the name of the file is,

00:26:56.180 --> 00:26:58.480
and it's not writing out the variable name,

00:26:58.840 --> 00:27:00.780
it's actually writing out the value

00:27:00.780 --> 00:27:02.220
that's stored in that variable.

00:27:03.260 --> 00:27:05.080
And hopefully this is fairly straightforward

00:27:05.080 --> 00:27:07.300
from the stuff that you've done already

00:27:07.300 --> 00:27:09.000
in your current work.

00:27:10.480 --> 00:27:11.800
And obviously, if you have any questions,

00:27:11.960 --> 00:27:13.660
I think a lot of you have the Python background.

00:27:13.820 --> 00:27:14.860
If you have any questions about

00:27:16.400 --> 00:27:17.940
something that behaves differently

00:27:17.940 --> 00:27:19.200
or works differently in C Sharp,

00:27:19.200 --> 00:27:21.340
definitely call those out as well.

00:27:21.760 --> 00:27:24.280
So let's look at some other examples of types here.

00:27:24.520 --> 00:27:27.320
Oh, it's showing the background, there we go.

00:27:29.920 --> 00:27:31.640
So let's look at some other examples.

00:27:31.760 --> 00:27:35.400
So here we have char, we have char grade equals a.

00:27:35.820 --> 00:27:38.080
What's the difference between this char?

00:27:38.200 --> 00:27:39.300
Why am I doing that?

00:27:39.380 --> 00:27:40.920
And then I'm using the single quotes.

00:27:41.540 --> 00:27:43.440
And then here for file name,

00:27:43.640 --> 00:27:45.780
I add a string and I'm doing the double quotes.

00:27:46.740 --> 00:27:47.840
Any ideas what's going on there?

00:27:47.840 --> 00:27:49.460
They're both letters, right?

00:27:49.500 --> 00:27:53.680
So why would I need double quotes for this one as a string?

00:27:54.820 --> 00:27:57.340
And then for this grade,

00:27:57.440 --> 00:28:00.100
I only have a single quotes in char.

00:28:00.260 --> 00:28:01.020
Any ideas why?

00:28:03.280 --> 00:28:04.600
Because on the double quotes,

00:28:04.760 --> 00:28:06.320
I think you wanted that to write print

00:28:06.320 --> 00:28:07.840
exactly as read me.

00:28:08.860 --> 00:28:10.400
And on the character and grade,

00:28:10.540 --> 00:28:13.480
the A, you want to find anything with A.

00:28:14.300 --> 00:28:14.720
Am I correct?

00:28:14.900 --> 00:28:16.040
That's a good guess actually.

00:28:16.560 --> 00:28:18.340
But what's happening here is

00:28:18.340 --> 00:28:21.400
a string is gonna be multiple characters.

00:28:21.700 --> 00:28:23.660
So if I have something that's gonna be

00:28:23.660 --> 00:28:24.760
more than one character,

00:28:25.140 --> 00:28:27.880
and so this example, I've got read me,

00:28:28.100 --> 00:28:30.100
or here I have a sentence that says

00:28:30.100 --> 00:28:31.680
the name of the file is.

00:28:32.360 --> 00:28:33.980
Because I have multiple characters,

00:28:34.140 --> 00:28:36.480
I don't necessarily know how long it's gonna be.

00:28:36.800 --> 00:28:39.240
It could be one character, it could be 20 characters.

00:28:40.020 --> 00:28:43.560
So quotes is gonna be how I will use

00:28:43.560 --> 00:28:45.000
if I have multiple characters.

00:28:45.000 --> 00:28:47.360
And I'll use a string data type for that.

00:28:47.640 --> 00:28:50.660
So string data type can be any length.

00:28:51.380 --> 00:28:53.200
It's not limited to a certain size.

00:28:53.940 --> 00:28:55.400
This character data type

00:28:55.920 --> 00:28:58.020
is actually just a single character.

00:28:58.440 --> 00:29:00.660
So the only thing that'll fit into that variable

00:29:00.660 --> 00:29:03.860
that I can store in there is just that letter A.

00:29:05.300 --> 00:29:07.280
And you're gonna see, so as a result,

00:29:07.340 --> 00:29:10.020
I'll use the single quotes around this A,

00:29:10.060 --> 00:29:11.740
and that's all I can store in there.

00:29:12.420 --> 00:29:13.360
Why would it matter?

00:29:13.360 --> 00:29:14.400
Why do you think it matters

00:29:14.400 --> 00:29:17.420
if having this character data type

00:29:17.420 --> 00:29:18.720
versus a string data type?

00:29:18.840 --> 00:29:20.540
Why would I use this here?

00:29:20.620 --> 00:29:22.680
Why wouldn't I just use maybe string everywhere?

00:29:23.900 --> 00:29:25.320
Does it compile faster?

00:29:27.220 --> 00:29:28.840
It's really efficiency, right?

00:29:28.900 --> 00:29:30.300
So if I know up front

00:29:30.300 --> 00:29:32.840
that I'm only gonna store a single character in there,

00:29:33.660 --> 00:29:35.100
then this is much more efficient

00:29:35.100 --> 00:29:39.600
because it's only gonna set aside space for one character

00:29:40.160 --> 00:29:41.840
and it's gonna allow me

00:29:41.840 --> 00:29:44.140
to work with that data more efficiently.

00:29:45.060 --> 00:29:46.540
If I don't know up front,

00:29:46.840 --> 00:29:48.860
or I know that I have multiple things

00:29:48.860 --> 00:29:49.560
that I'm gonna store in there,

00:29:49.580 --> 00:29:50.780
then I would use the string data.

00:29:51.020 --> 00:29:53.120
So yeah, so it would actually compile faster,

00:29:53.120 --> 00:29:55.300
but it's really about the storage

00:29:55.300 --> 00:29:56.180
that you're setting aside.

00:29:56.880 --> 00:29:57.820
So same idea here.

00:29:57.860 --> 00:29:59.280
Let's look at these different numbers.

00:30:00.200 --> 00:30:02.420
So I've got all these different data types for numbers.

00:30:03.320 --> 00:30:06.300
Int, long, float, double, decimal.

00:30:07.520 --> 00:30:09.960
Why do you think there's so many different data types

00:30:09.960 --> 00:30:10.640
for numbers?

00:30:13.100 --> 00:30:15.160
I would think storage is efficiency,

00:30:15.200 --> 00:30:16.180
like you mentioned earlier.

00:30:16.240 --> 00:30:17.660
You've got to have enough storage

00:30:17.660 --> 00:30:21.080
for these different lengths of numbers.

00:30:21.780 --> 00:30:22.860
Yeah, that's absolutely right.

00:30:23.040 --> 00:30:25.980
And the other thing too is that you're gonna see,

00:30:26.280 --> 00:30:28.800
so for example, an int is an integer.

00:30:29.080 --> 00:30:30.620
An int is gonna be a whole number.

00:30:31.040 --> 00:30:32.620
There's no decimal part of that.

00:30:32.880 --> 00:30:34.300
So if I know right up front,

00:30:34.720 --> 00:30:36.080
just like Lisa was saying,

00:30:36.120 --> 00:30:37.180
if I know right up front

00:30:37.180 --> 00:30:39.680
that I'm not storing any decimals in there,

00:30:40.400 --> 00:30:42.320
it's more efficient to store as an integer.

00:30:42.820 --> 00:30:45.600
And also when I start doing math operations,

00:30:46.380 --> 00:30:48.540
it's gonna handle that a little bit differently, right?

00:30:48.540 --> 00:30:50.900
With an integer, there's no decimal part.

00:30:51.160 --> 00:30:53.100
So I'm always gonna just get whole numbers.

00:30:54.060 --> 00:30:57.800
If I do care about the decimal part,

00:30:57.840 --> 00:30:59.500
then I would have to use a different data type.

00:31:01.720 --> 00:31:03.560
What's the difference between long and int,

00:31:03.620 --> 00:31:05.560
do you think, just from looking at the data

00:31:05.560 --> 00:31:06.760
that I'm showing you here?

00:31:09.680 --> 00:31:13.240
I think it's still something higher than you

00:31:13.240 --> 00:31:13.960
under that certain limit.

00:31:15.140 --> 00:31:16.400
Yeah, so int, exactly.

00:31:16.540 --> 00:31:18.580
Int is looking for a certain size number.

00:31:18.700 --> 00:31:21.740
And if you know your number is under that certain size,

00:31:22.180 --> 00:31:23.540
then you can store it as an int.

00:31:23.560 --> 00:31:24.900
And again, you're just gonna save

00:31:24.900 --> 00:31:26.400
a little bit of space memory-wise.

00:31:26.640 --> 00:31:28.200
It's gonna work a little bit faster.

00:31:28.720 --> 00:31:31.540
And then if your data exceeds that,

00:31:32.040 --> 00:31:33.140
then you can use the long

00:31:33.140 --> 00:31:36.040
and then that'll have more space, right?

00:31:36.040 --> 00:31:38.400
It'll allow you to store larger numbers in there.

00:31:39.320 --> 00:31:41.220
And you're gonna see some similar scenarios too.

00:31:41.680 --> 00:31:43.900
So here, if I do have decimals,

00:31:44.220 --> 00:31:47.200
you're gonna see there's actually three different data types

00:31:47.200 --> 00:31:48.620
that let me work with decimals.

00:31:48.680 --> 00:31:51.960
So I'll have floats, doubles, and decimals.

00:31:53.060 --> 00:31:55.980
And the difference that you're gonna see there

00:31:55.980 --> 00:31:58.020
is the precision.

00:31:58.720 --> 00:32:00.440
When I say precision for a number,

00:32:00.680 --> 00:32:01.540
what does that mean?

00:32:01.940 --> 00:32:03.080
Does anybody know what that means

00:32:03.080 --> 00:32:05.400
when I'm talking about numbers and precision?

00:32:06.760 --> 00:32:08.760
Like significant figures in calculation?

00:32:09.880 --> 00:32:10.560
Yeah, absolutely.

00:32:10.780 --> 00:32:16.200
So what'll happen is I have the numbers

00:32:16.200 --> 00:32:18.460
that are to the right of the decimal point.

00:32:19.380 --> 00:32:22.180
And the more numbers that I have

00:32:22.180 --> 00:32:23.440
to the right of the decimal point,

00:32:23.480 --> 00:32:25.820
I can be more precise, right?

00:32:25.820 --> 00:32:27.640
So if I only have two numbers

00:32:27.640 --> 00:32:29.720
to the right of the decimal point

00:32:29.720 --> 00:32:33.480
and I'm doing addition, division, things like that,

00:32:33.480 --> 00:32:37.680
I might wind up losing some of that information

00:32:37.680 --> 00:32:40.420
because I don't have enough space to store it.

00:32:40.720 --> 00:32:43.380
So for certain things that won't matter, right?

00:32:43.400 --> 00:32:45.460
So if I'm trying to figure out

00:32:46.740 --> 00:32:48.580
like an average or something like that,

00:32:48.580 --> 00:32:50.020
it might not matter.

00:32:50.740 --> 00:32:52.160
When do you think it does matter though?

00:32:52.200 --> 00:32:54.440
When does that precision really make a difference

00:32:54.440 --> 00:32:55.520
for most people?

00:32:55.900 --> 00:32:56.160
Money.

00:32:56.420 --> 00:32:58.620
When we talk about money, right?

00:32:59.060 --> 00:33:02.820
So with money, do you care if you lose that cent or not?

00:33:02.820 --> 00:33:04.060
Absolutely, right?

00:33:04.600 --> 00:33:08.420
So that's why we actually have a special data type

00:33:08.420 --> 00:33:11.900
in C Sharp called decimal that'll be the most precise.

00:33:11.980 --> 00:33:14.560
So when you're working with money,

00:33:15.240 --> 00:33:17.200
this is gonna have a very high precision

00:33:17.200 --> 00:33:21.140
so that you're gonna not lose those pennies, right?

00:33:21.200 --> 00:33:22.760
That's fine, those financial calculations.

00:33:23.840 --> 00:33:25.440
For these other numbers, you'll notice

00:33:25.440 --> 00:33:27.060
I just have the number of value.

00:33:27.300 --> 00:33:29.860
And then for these float, double, and decimal,

00:33:30.620 --> 00:33:32.620
you'll see there's actually an F there

00:33:32.620 --> 00:33:34.340
and then there's an M after that.

00:33:34.560 --> 00:33:36.340
Why do you think that I have to have

00:33:36.340 --> 00:33:38.500
that sort of extra character on there

00:33:38.500 --> 00:33:39.940
for those different types?

00:33:41.720 --> 00:33:45.000
Yeah, what'll happen is that if I don't put,

00:33:45.240 --> 00:33:46.780
so they're all decimals, right?

00:33:47.100 --> 00:33:48.800
If I don't put the decimal,

00:33:49.480 --> 00:33:52.880
C Sharp will try to guess what type of data that is.

00:33:53.200 --> 00:33:55.220
And by default, it's gonna guess

00:33:55.220 --> 00:33:56.860
that this data is a double.

00:33:58.800 --> 00:34:01.980
And so I can actually put an extra character

00:34:01.980 --> 00:34:04.540
to sort of say, no, this actually is a float.

00:34:06.420 --> 00:34:09.320
So I can sort of help give C Sharp a little bit of a hint

00:34:09.960 --> 00:34:12.080
when I'm trying to convert these to different numbers

00:34:12.080 --> 00:34:13.480
or store these different numbers.

00:34:13.640 --> 00:34:17.380
And then you would think decimal would be D,

00:34:17.640 --> 00:34:19.220
but of course it's M.

00:34:19.840 --> 00:34:21.700
So I think M is money,

00:34:23.960 --> 00:34:26.360
but it's a little bit different than what you'd expect.

00:34:26.400 --> 00:34:29.440
Float is an F, but decimal is actually an M.

00:34:31.100 --> 00:34:33.520
And again, all these different data types,

00:34:34.200 --> 00:34:35.480
the importance you're getting with those

00:34:35.480 --> 00:34:37.140
is the precision for the numbers,

00:34:37.240 --> 00:34:40.740
and then you're setting aside a certain amount of space,

00:34:41.100 --> 00:34:43.160
and you're telling C Sharp, hey,

00:34:43.180 --> 00:34:45.680
this is the kind of data that I'm gonna store in here.

00:34:46.140 --> 00:34:48.000
And then obviously with the Booleans,

00:34:48.100 --> 00:34:50.760
you're just getting those values of true or false.

00:34:52.200 --> 00:34:55.600
Some languages you'll see are not case sensitive.

00:34:56.820 --> 00:34:58.320
C Sharp is case sensitive.

00:34:59.180 --> 00:35:02.620
So this lower case true is what you're gonna see,

00:35:02.720 --> 00:35:03.780
or lower case false.

00:35:04.900 --> 00:35:05.800
If you try to type,

00:35:06.760 --> 00:35:08.480
Visual Studio is gonna give you a lot of help actually.

00:35:08.560 --> 00:35:11.460
So if you try to type this, for example, as cap,

00:35:12.340 --> 00:35:14.420
you're gonna see it's not buying that, right?

00:35:14.420 --> 00:35:16.740
It's telling you right away, like that doesn't exist.

00:35:20.740 --> 00:35:22.160
So you're gonna see the two are in false.

00:35:22.860 --> 00:35:23.960
And then the same idea,

00:35:24.000 --> 00:35:26.240
if I write these out to the console,

00:35:26.240 --> 00:35:30.580
so if I write the value of grade, console write grade,

00:35:30.640 --> 00:35:31.920
it's gonna write the value,

00:35:32.240 --> 00:35:34.700
not the name of the variable.

00:35:35.400 --> 00:35:37.140
So grade will write out whatever that is.

00:35:37.180 --> 00:35:39.160
In this case, that's an A.

00:35:41.540 --> 00:35:44.440
It's showing my Zoom window here.

00:35:44.660 --> 00:35:46.880
Let's move that a little bit.

00:35:47.660 --> 00:35:48.520
Gonna adjust.

00:35:52.160 --> 00:35:53.500
Okay, there we go.

00:35:54.040 --> 00:35:56.220
So same idea, for all these variables,

00:35:56.320 --> 00:35:58.960
it's gonna write out the value of that variable.

00:35:59.720 --> 00:36:01.440
It's smart enough not to write out the name

00:36:01.440 --> 00:36:03.560
and notice you're trying to use the value for those.

00:36:05.320 --> 00:36:06.960
What else I wanna show you?

00:36:07.260 --> 00:36:10.160
Oh, typically, and this is sort of a best practice thing,

00:36:10.320 --> 00:36:13.520
but typically naming variables in C Sharp,

00:36:13.980 --> 00:36:15.620
they're gonna be lower case.

00:36:16.200 --> 00:36:18.160
And then you're gonna see that they use

00:36:18.160 --> 00:36:19.760
camel case is what we call it.

00:36:20.460 --> 00:36:22.720
So for example, total population,

00:36:23.360 --> 00:36:28.220
we're capitalizing the other words in that variable name.

00:36:28.620 --> 00:36:31.520
Height and meters, we're capitalizing the I and the M.

00:36:32.500 --> 00:36:34.500
Does it matter what you name your variables?

00:36:35.160 --> 00:36:36.820
Is the code still gonna work?

00:36:37.200 --> 00:36:39.280
The code will still work, right?

00:36:39.640 --> 00:36:42.460
But this is just a typical common practice.

00:36:42.840 --> 00:36:44.500
And if you're looking at other people's code

00:36:44.500 --> 00:36:47.440
or people are coming to look at your code,

00:36:47.680 --> 00:36:50.100
this is just sort of what they're expecting as practice.

00:36:51.120 --> 00:36:52.380
Every language that you work with,

00:36:52.380 --> 00:36:56.560
I'm sure Python has its own naming standards and variations.

00:36:57.120 --> 00:37:00.040
The important thing is really to be consistent

00:37:00.620 --> 00:37:01.980
in your application.

00:37:03.220 --> 00:37:05.380
So this is the common C Sharp standard.

00:37:06.060 --> 00:37:07.940
Again, the important thing is to be consistent.

00:37:08.420 --> 00:37:11.000
And the important thing too is to name your variable

00:37:11.000 --> 00:37:14.980
something that makes sense, right?

00:37:15.060 --> 00:37:18.280
So here, if I just put speed,

00:37:19.260 --> 00:37:20.960
you might know what it is, but you might be like,

00:37:20.960 --> 00:37:22.520
well, what's that speed represent?

00:37:22.660 --> 00:37:24.180
Is that 110 miles an hour?

00:37:24.300 --> 00:37:26.980
Is it 110 feet per second, right?

00:37:27.280 --> 00:37:31.840
So just having consistent, well-named variables

00:37:31.840 --> 00:37:33.380
is only gonna help you later.

00:37:33.720 --> 00:37:35.120
I could name these, right?

00:37:35.120 --> 00:37:38.660
G, S, T, H, Z, X, right?

00:37:38.960 --> 00:37:41.120
But that's gonna be so much more confusing later

00:37:41.120 --> 00:37:42.500
when I'm trying to look at that and figure out.

00:37:42.560 --> 00:37:44.880
Any questions before we try using some variables,

00:37:45.280 --> 00:37:47.340
declaring a few variables and using them in our code?

00:37:49.100 --> 00:37:49.600
Fantastic.

00:37:49.600 --> 00:37:52.540
Let's take a look at this next activity.

00:37:54.620 --> 00:37:56.160
This will be 04 variables.

00:37:56.440 --> 00:37:58.040
And if you look at the README file,

00:37:58.620 --> 00:38:00.120
it's gonna have some information

00:38:00.120 --> 00:38:01.680
about those different data types.

00:38:02.360 --> 00:38:03.520
And then at the top of this,

00:38:03.560 --> 00:38:04.820
it'll have some directions

00:38:04.820 --> 00:38:06.460
about what we're gonna do here,

00:38:06.900 --> 00:38:09.000
as well as we're giving you some sample output.

00:38:10.120 --> 00:38:12.160
So what your output should look like.

00:38:13.460 --> 00:38:15.540
And then the starter code,

00:38:15.540 --> 00:38:19.900
if you open that up in Visual Studio, 2022,

00:38:20.920 --> 00:38:22.360
open that solution file,

00:38:23.100 --> 00:38:25.120
and that'll already have all the starter code.

00:38:25.400 --> 00:38:26.840
And then all you'll have to do is go

00:38:26.840 --> 00:38:30.100
into your program file and start writing your code.

00:38:32.020 --> 00:38:32.680
All right, so let's take a look.

00:38:32.700 --> 00:38:33.700
Let's try this activity.

00:38:34.280 --> 00:38:37.160
We'll do this for about 10 minutes as well.

00:38:37.520 --> 00:38:40.020
And then we'll come back and take a look and review that.

00:38:46.740 --> 00:38:48.800
I don't see if you have any questions at all.

00:38:48.980 --> 00:38:49.780
Please ask.

00:38:50.200 --> 00:38:53.100
I can easily share your desktops

00:38:53.100 --> 00:38:54.660
and help out wherever we need to.

00:38:54.920 --> 00:38:58.140
I'm already lost to try to find that file, sorry.

00:38:58.320 --> 00:38:59.000
Oh, no problem.

00:38:59.300 --> 00:38:59.740
Let's see.

00:39:00.160 --> 00:39:02.040
Let me take a look at your desktop there.

00:39:02.800 --> 00:39:07.000
When to desktop, cash for automation,

00:39:07.500 --> 00:39:10.620
lesson one, activities.

00:39:12.860 --> 00:39:13.860
Let me see.

00:39:13.940 --> 00:39:16.660
Let me go to your screen really quick.

00:39:18.260 --> 00:39:21.240
Yes, so go into, it's the variables, 04 variables.

00:39:24.100 --> 00:39:26.000
And then inside there, there's a starter.

00:39:26.620 --> 00:39:27.360
Yeah, that was the thing.

00:39:28.120 --> 00:39:29.600
Yep, and then there'll be a solution file.

00:39:29.660 --> 00:39:30.800
If you just double click on that.

00:39:31.240 --> 00:39:31.660
Solution file.

00:39:31.900 --> 00:39:34.440
The .SLN, yeah, that file, yep, right there.

00:39:34.860 --> 00:39:35.420
Right here?

00:39:35.420 --> 00:39:35.580
Yep.

00:39:35.580 --> 00:39:35.980
Okay.

00:39:37.340 --> 00:39:38.300
Yep, and that'll open

00:39:38.300 --> 00:39:39.620
and then it should have all your files

00:39:39.620 --> 00:39:40.480
and everything for you.

00:39:40.480 --> 00:39:40.600
Yes.

00:39:40.600 --> 00:39:41.700
So on the right side of your screen,

00:39:41.700 --> 00:39:44.880
can you see the mouse on your screen or no?

00:39:46.440 --> 00:39:47.760
Oh, I see mine.

00:39:47.880 --> 00:39:48.400
I see mine.

00:39:48.560 --> 00:39:49.000
Okay.

00:39:49.500 --> 00:39:50.460
So expand variables.

00:39:50.580 --> 00:39:51.180
Yep, expand that.

00:39:51.200 --> 00:39:53.560
And then there's a program.CS file.

00:39:53.940 --> 00:39:56.040
Just double click on the program.CS file.

00:39:57.200 --> 00:39:57.720
Yeah, right there.

00:39:57.800 --> 00:39:58.380
Yeah, perfect.

00:39:58.840 --> 00:40:00.740
And then that'll open the code up for you.

00:40:01.760 --> 00:40:03.180
And so see on line nine there,

00:40:03.180 --> 00:40:04.680
there's a little comment that says

00:40:04.680 --> 00:40:06.820
to do about writing your code here.

00:40:08.360 --> 00:40:08.840
Yeah.

00:40:08.840 --> 00:40:10.540
So that's where we're gonna write some code.

00:40:11.320 --> 00:40:13.100
And if you look at the activity instructions,

00:40:13.180 --> 00:40:15.800
it'll walk through the code that we wanna write in there.

00:40:15.900 --> 00:40:18.760
And the activity instructions are where?

00:40:19.080 --> 00:40:21.140
So go back to your Windows Explorer

00:40:21.140 --> 00:40:22.440
that you were just in.

00:40:22.580 --> 00:40:23.560
Yep, right in there.

00:40:24.320 --> 00:40:27.820
And go back up to the variables folder.

00:40:28.540 --> 00:40:30.240
So at the top of your screen there,

00:40:30.320 --> 00:40:32.020
there's in your path at the top.

00:40:33.000 --> 00:40:34.640
Yeah, just click on variables.

00:40:35.820 --> 00:40:36.300
Yep.

00:40:36.580 --> 00:40:39.140
And then there's that README file right there.

00:40:40.460 --> 00:40:42.560
And so here are the instructions that it says,

00:40:42.680 --> 00:40:44.280
open the variable solution.

00:40:45.000 --> 00:40:46.160
And then line eight.

00:40:47.440 --> 00:40:48.380
This is what we want you to do.

00:40:48.400 --> 00:40:49.860
We want you to create some variables

00:40:50.560 --> 00:40:51.620
to hold some values.

00:40:51.880 --> 00:40:54.320
So we wanna have you create a variable for your name,

00:40:55.040 --> 00:40:56.740
a variable for the number of years

00:40:56.740 --> 00:40:59.400
programming experience you have,

00:41:00.780 --> 00:41:02.920
your ideal salary and dollars,

00:41:03.460 --> 00:41:05.780
and whether you are excited to be here.

00:41:06.260 --> 00:41:07.360
And then you'll obviously,

00:41:07.600 --> 00:41:08.760
we'll have you create those variables

00:41:08.760 --> 00:41:11.020
and then we're gonna have you display those,

00:41:11.600 --> 00:41:12.380
the values of those.

00:41:14.300 --> 00:41:15.580
Oh, is there a question in the chat?

00:41:15.660 --> 00:41:16.540
Oh, okay.

00:41:28.720 --> 00:41:32.620
So it's 11, or headed towards 11 for you, right?

00:41:33.280 --> 00:41:34.440
Am I doing my time right here?

00:41:35.280 --> 00:41:36.420
It's 10.30.

00:41:37.140 --> 00:41:38.220
Okay, okay.

00:41:38.280 --> 00:41:40.020
So I'm gonna try to make sure

00:41:40.020 --> 00:41:43.240
we plan our breaks accordingly based on your time.

00:41:43.300 --> 00:41:44.260
So not my time zone.

00:41:45.420 --> 00:41:46.380
Okay, so I'm gonna try to make sure

00:41:46.380 --> 00:41:46.400
we plan our breaks accordingly based on your time zone,

00:42:56.180 --> 00:42:57.580
okay?

00:43:27.000 --> 00:43:28.400
Okay.

00:43:50.540 --> 00:43:54.920
Another minute or so, and then we'll take a look.

00:44:00.640 --> 00:44:04.140
Let me just adjust my zoom with Windows here.

00:44:04.340 --> 00:44:06.760
Let's see, hide that.

00:44:10.580 --> 00:44:12.420
And put this back.

00:44:12.520 --> 00:44:13.820
There we go, okay.

00:44:15.580 --> 00:44:16.400
Let's zoom out a little bit.

00:44:16.400 --> 00:44:17.840
It's kind of out of the way a little bit there.

00:44:19.180 --> 00:44:20.140
All right, so let's take a look.

00:44:20.280 --> 00:44:22.060
I'm gonna close this off here.

00:44:24.900 --> 00:44:26.480
So as we're working these different activities,

00:44:26.700 --> 00:44:27.640
are you able to see my screen?

00:44:28.780 --> 00:44:29.180
Yes.

00:44:29.620 --> 00:44:29.980
Okay.

00:44:30.200 --> 00:44:31.560
So as we're working these different activities,

00:44:31.780 --> 00:44:34.620
so you'll see I'm in this activities, variables folder,

00:44:35.840 --> 00:44:38.500
and each of these is gonna have that solution file,

00:44:38.680 --> 00:44:40.080
right, that .SLN.

00:44:41.420 --> 00:44:43.080
You're gonna just double click on that

00:44:43.080 --> 00:44:45.100
and that'll open it up into Visual Studio.

00:44:50.340 --> 00:44:54.080
And then once that opens, you're gonna see,

00:44:54.940 --> 00:44:56.300
it takes a second there.

00:44:57.660 --> 00:44:59.500
Let me just zoom on this for you.

00:45:01.320 --> 00:45:03.700
You'll see that once that opens,

00:45:07.040 --> 00:45:08.840
what happens there?

00:45:09.040 --> 00:45:11.940
Why is that displaying it like that?

00:45:13.200 --> 00:45:14.680
Let me hide zoom for a second.

00:45:19.720 --> 00:45:22.260
It's trying to minimize that window.

00:45:24.680 --> 00:45:26.220
Oh my gosh, okay.

00:45:26.220 --> 00:45:27.200
Well, that's not gonna work.

00:45:27.260 --> 00:45:29.060
Let me try this again.

00:45:34.420 --> 00:45:35.480
Put this down here.

00:45:35.600 --> 00:45:36.220
Is that gonna do?

00:45:41.760 --> 00:45:44.020
Oh, it's auto sizing this window now.

00:45:44.140 --> 00:45:45.500
All right, well, one second here.

00:46:00.660 --> 00:46:01.020
Okay.

00:46:01.020 --> 00:46:01.740
Are you able to see that?

00:46:01.860 --> 00:46:03.920
It's not very zoomed in, I don't feel like.

00:46:04.500 --> 00:46:06.160
Is that big enough for you to see

00:46:06.160 --> 00:46:07.740
what I've got showing on the screen there?

00:46:08.820 --> 00:46:10.060
Yeah, let's get them in.

00:46:10.360 --> 00:46:10.720
Okay.

00:46:10.980 --> 00:46:13.340
So if I double click on that program.cs file,

00:46:14.860 --> 00:46:17.280
it's gonna open the solution for me there.

00:46:17.620 --> 00:46:20.220
And we're gonna give you some comments here

00:46:20.220 --> 00:46:21.320
about where to put your code.

00:46:22.000 --> 00:46:23.420
So a couple of things to call out.

00:46:23.800 --> 00:46:26.040
One is that if you wanna do comments,

00:46:27.080 --> 00:46:30.520
the little double slash indicates that it's a comment.

00:46:30.740 --> 00:46:32.940
So Visual Studio and C Sharp will ignore

00:46:32.940 --> 00:46:34.240
whatever is on that line.

00:46:35.220 --> 00:46:38.520
So comments are super useful for leaving yourself notes.

00:46:39.000 --> 00:46:40.720
In this case, we're leaving you a note

00:46:40.720 --> 00:46:42.360
to say where to put your code at.

00:46:43.460 --> 00:46:46.160
I like to think of comments as a way

00:46:47.180 --> 00:46:50.400
for current Shane to let future Shane know

00:46:50.400 --> 00:46:52.720
what the heck current Shane was thinking, right?

00:46:53.220 --> 00:46:56.440
So a lot of times when you're writing code,

00:46:56.760 --> 00:46:59.320
you may write something that's not obvious.

00:47:00.020 --> 00:47:01.720
And if it's not obvious,

00:47:02.220 --> 00:47:04.680
you're not gonna remember later what it was doing, right?

00:47:04.700 --> 00:47:07.320
So it's very useful to be able to leave yourself

00:47:07.320 --> 00:47:10.260
a little note that you can look at in the future

00:47:10.260 --> 00:47:12.640
and go, oh, that's what I was doing here,

00:47:12.640 --> 00:47:15.360
that's what this calculation is doing.

00:47:16.560 --> 00:47:19.800
You can easily do that by using the little double slash.

00:47:20.760 --> 00:47:23.620
In Visual Studio also, and on your toolbar,

00:47:24.440 --> 00:47:27.220
you're gonna see there's these little buttons here,

00:47:27.240 --> 00:47:28.240
these toggles.

00:47:28.980 --> 00:47:30.520
And if you have something highlighted,

00:47:30.720 --> 00:47:33.460
you can just click this to easily comment

00:47:33.460 --> 00:47:36.740
or uncomment a whole block of code.

00:47:37.380 --> 00:47:38.980
So sometimes when you're writing code,

00:47:39.200 --> 00:47:40.700
you'll try something and you'll be like,

00:47:40.700 --> 00:47:42.640
I'm not sure if this is gonna work, right?

00:47:42.800 --> 00:47:44.520
So you'll try something like this.

00:47:44.820 --> 00:47:47.100
And you can easily use these buttons.

00:47:47.840 --> 00:47:50.160
So if I click this comment button,

00:47:50.980 --> 00:47:52.620
you're gonna see that it'll automatically

00:47:52.620 --> 00:47:54.160
comment that out for me.

00:47:55.320 --> 00:47:57.320
And then if I wanna uncomment that,

00:47:57.340 --> 00:47:59.120
there's a button right next to it here

00:47:59.120 --> 00:48:00.680
that does the same, this removes.

00:48:03.020 --> 00:48:03.760
Oh, did I click it?

00:48:03.760 --> 00:48:04.940
Apparently not.

00:48:09.240 --> 00:48:10.780
Yeah, there we go.

00:48:11.040 --> 00:48:13.320
So you get the option to do that as well.

00:48:14.640 --> 00:48:15.840
So what do we need to do for this?

00:48:15.940 --> 00:48:17.480
We needed to create some variables

00:48:18.160 --> 00:48:20.700
to represent the data we wanted to store, right?

00:48:21.720 --> 00:48:24.040
And so one of the two things that I need for variables

00:48:24.040 --> 00:48:27.040
in order to create a variable.

00:48:28.420 --> 00:48:29.600
I need a data type,

00:48:29.640 --> 00:48:31.880
and I need to be able to have a name of it, right?

00:48:32.240 --> 00:48:33.580
So for this one,

00:48:34.040 --> 00:48:34.920
I wanna store some data.

00:48:34.920 --> 00:48:36.020
I wanna store string data in it,

00:48:36.040 --> 00:48:37.360
so I'll call it string.

00:48:38.780 --> 00:48:42.020
And I think I wanted to store like my name, right?

00:48:42.180 --> 00:48:43.180
So we're storing in this.

00:48:44.420 --> 00:48:46.960
And we're gonna assign that some data, right?

00:48:48.680 --> 00:48:50.460
So obviously not my real name,

00:48:50.520 --> 00:48:52.900
this is just a sample data name.

00:48:55.320 --> 00:48:57.020
So we'll store value in there.

00:48:57.040 --> 00:48:58.340
And then remember, semipole,

00:48:58.380 --> 00:49:00.380
and I was gonna put that on the end

00:49:01.040 --> 00:49:03.400
to indicate that's the end of that line.

00:49:04.920 --> 00:49:06.080
What else do we wanna store?

00:49:06.120 --> 00:49:07.820
We wanna store years of experience.

00:49:07.980 --> 00:49:10.380
What data type should we use for years of experience?

00:49:14.220 --> 00:49:15.900
Yeah, integer probably makes the most sense.

00:49:15.980 --> 00:49:19.240
I mean, you could use a decimal value for that,

00:49:19.280 --> 00:49:21.260
but integer is probably enough

00:49:21.260 --> 00:49:22.460
for what we wanna do there.

00:49:22.900 --> 00:49:25.540
And so I'll just call this years of experience.

00:49:29.640 --> 00:49:31.500
And we'll say 20,

00:49:31.820 --> 00:49:33.200
just round it off there.

00:49:35.800 --> 00:49:37.140
What about salary?

00:49:37.460 --> 00:49:41.060
What kind of a data type would you expect to use for salary?

00:49:43.900 --> 00:49:45.940
Yeah, so as soon as you think about money,

00:49:46.560 --> 00:49:48.380
I would always use a decimal,

00:49:48.460 --> 00:49:52.740
just because that's gonna handle the rounding better.

00:49:52.760 --> 00:49:56.000
And so you're not gonna lose those imported pennies.

00:49:56.840 --> 00:49:59.360
And I don't know, let's just say 220, right?

00:49:59.360 --> 00:50:00.160
That sounds good.

00:50:04.640 --> 00:50:06.540
And what was the last thing when you did?

00:50:06.760 --> 00:50:08.080
Oh, whether you're excited or not.

00:50:08.160 --> 00:50:09.920
What data type would that be?

00:50:11.920 --> 00:50:13.800
It should be a true or false, right?

00:50:14.040 --> 00:50:15.160
Yeah, absolutely.

00:50:18.860 --> 00:50:20.340
Oh, can't spell apparently.

00:50:22.280 --> 00:50:24.320
And then we'll assign a value to that.

00:50:24.500 --> 00:50:25.540
And you're gonna notice too,

00:50:25.540 --> 00:50:27.180
as you're typing in this,

00:50:27.180 --> 00:50:29.280
Visual Studio is actually doing

00:50:29.280 --> 00:50:31.640
a lot of guessing for you, right?

00:50:31.760 --> 00:50:34.180
So as I start to type, for example, true,

00:50:35.080 --> 00:50:37.660
you see how it's giving me the option to accept that,

00:50:37.760 --> 00:50:41.520
so I can hit the tab key to accept that.

00:50:42.900 --> 00:50:44.560
So Visual Studio is actually gonna try

00:50:45.260 --> 00:50:47.040
to help you write your code.

00:50:48.520 --> 00:50:51.000
So some of the things it suggests are great.

00:50:51.060 --> 00:50:52.680
Some of the things it suggests are not so great.

00:50:52.700 --> 00:50:54.460
So you're still gonna have to kind of pay attention

00:50:54.460 --> 00:50:55.260
to what it's asking,

00:50:55.260 --> 00:50:57.080
but just be aware that it does try

00:50:57.080 --> 00:50:58.160
to give you a lot of help.

00:50:59.720 --> 00:51:01.000
It's also giving me some help here.

00:51:01.020 --> 00:51:01.620
What is it?

00:51:01.820 --> 00:51:03.520
Why are these all underlined with green?

00:51:06.460 --> 00:51:08.660
Yeah, so it's actually doing two things.

00:51:08.780 --> 00:51:10.340
Because I've declared these variables,

00:51:10.400 --> 00:51:11.820
but I'm not using them anywhere,

00:51:12.440 --> 00:51:15.180
it's actually sort of graying out the names of these,

00:51:15.380 --> 00:51:17.700
as well as putting a little squiggly under there.

00:51:17.760 --> 00:51:19.120
And if I hover under this,

00:51:19.460 --> 00:51:21.280
it's actually telling me that this is a sign,

00:51:21.300 --> 00:51:22.160
but never used.

00:51:22.620 --> 00:51:24.220
So it's actually pretty useful.

00:51:24.220 --> 00:51:27.020
If you have actual code that you're working on,

00:51:27.360 --> 00:51:28.520
and you see that,

00:51:28.780 --> 00:51:30.140
it's telling you that at some point

00:51:30.140 --> 00:51:31.280
you declared that variable,

00:51:31.300 --> 00:51:32.760
but you didn't really use it anywhere.

00:51:32.960 --> 00:51:34.900
So you can probably get rid of that variable

00:51:34.900 --> 00:51:36.220
is what it's telling you.

00:51:37.320 --> 00:51:37.900
All right, let's go ahead

00:51:37.900 --> 00:51:39.200
and write the values of these out.

00:51:39.200 --> 00:51:41.480
So that would be console write line.

00:51:43.580 --> 00:51:45.800
And again, here, as I'm starting to type this,

00:51:46.060 --> 00:51:47.780
you'll notice it's suggesting

00:51:49.240 --> 00:51:51.240
what it thinks I'm gonna do there.

00:51:52.980 --> 00:51:55.620
And so we can write those different variables out

00:51:55.620 --> 00:51:58.040
just by using the name of those variables.

00:52:01.240 --> 00:52:04.280
And then obviously semi-colon to end all of those.

00:52:06.460 --> 00:52:07.500
Any questions on this?

00:52:07.700 --> 00:52:11.360
So hopefully this is fairly introductory stuff for you

00:52:11.360 --> 00:52:13.860
as far as just maybe doing it a little bit differently.

00:52:14.740 --> 00:52:16.860
Python doesn't require the semi-colon, right?

00:52:18.340 --> 00:52:20.880
But does white space matter in Python?

00:52:22.420 --> 00:52:24.560
Is like the indentation pretty important?

00:52:27.720 --> 00:52:30.440
Yeah, so in Visual Studio,

00:52:30.860 --> 00:52:32.440
the white space doesn't matter at all, right?

00:52:32.440 --> 00:52:34.440
So I can put tons of white space here.

00:52:35.000 --> 00:52:37.160
I can put this way over here.

00:52:38.380 --> 00:52:41.200
This will make you crazy as a developer,

00:52:41.980 --> 00:52:44.660
but C Sharp doesn't care at all about the white space.

00:52:46.300 --> 00:52:48.340
Another thing that you can do as well

00:52:48.340 --> 00:52:49.920
is when you're in these different files,

00:52:49.920 --> 00:52:53.020
if you do the menu, the right-click menu,

00:52:53.680 --> 00:52:56.040
you're gonna see a lot of times you'll get...

00:52:56.720 --> 00:53:00.120
I can't believe it doesn't hide the Zoom thing in there.

00:53:00.120 --> 00:53:00.760
That's crazy.

00:53:02.120 --> 00:53:02.700
Let's see here.

00:53:02.760 --> 00:53:04.320
Let me see if I can move that.

00:53:06.460 --> 00:53:08.020
Toggle it off or something.

00:53:13.840 --> 00:53:15.380
A lot of times it'll give you suggestions

00:53:15.380 --> 00:53:16.920
in formatting as well.

00:53:16.920 --> 00:53:19.560
So it'll give you tips to help format your code.

00:53:22.520 --> 00:53:25.400
It's not showing up in the menu here, is it?

00:53:25.480 --> 00:53:26.580
I don't believe so.

00:53:28.040 --> 00:53:29.960
But you do get these different quick actions

00:53:29.960 --> 00:53:30.700
that you can do.

00:53:31.440 --> 00:53:34.460
Oh, that didn't disappear for me there.

00:53:36.900 --> 00:53:39.320
So white space, again, not important.

00:53:39.900 --> 00:53:41.800
Semi-colons, very important.

00:53:46.920 --> 00:53:47.400
What else?

00:53:47.540 --> 00:53:48.060
I want to show you this one.

00:53:48.100 --> 00:53:48.940
I think that's really it.

00:53:49.040 --> 00:53:50.260
And then again, the data type.

00:53:50.380 --> 00:53:52.020
Somebody, I forgot you said this earlier,

00:53:52.360 --> 00:53:53.860
maybe it was Lisa, about

00:53:54.420 --> 00:53:56.140
how do I know when data types are available?

00:53:56.620 --> 00:53:57.980
Google is definitely your friend.

00:53:59.180 --> 00:54:01.200
If you have a question about it,

00:54:01.560 --> 00:54:03.060
absolutely just do a quick Google search

00:54:03.060 --> 00:54:05.760
and you'll find the answer to the information.

00:54:07.820 --> 00:54:11.200
The majority of times it's gonna be the numbers

00:54:11.760 --> 00:54:12.540
when you're looking at those

00:54:12.540 --> 00:54:16.040
to try to decide what type of data am I storing

00:54:16.040 --> 00:54:18.480
and does that precision matter on your numbers?

00:54:19.400 --> 00:54:20.560
A lot of times you're gonna see

00:54:20.560 --> 00:54:22.420
we'll be using very similar data types

00:54:22.420 --> 00:54:25.760
as far as strings and integers and Booleans.

00:54:25.920 --> 00:54:27.480
So very common data types.

00:54:29.220 --> 00:54:31.420
What other questions that I have for you on this?

00:54:31.720 --> 00:54:32.340
Let's see.

00:54:33.580 --> 00:54:33.880
Oh, sure.

00:54:39.020 --> 00:54:40.800
Oh, so that's a great question actually.

00:54:41.080 --> 00:54:44.120
So what's interesting is there is actually a data type

00:54:45.500 --> 00:54:48.980
in C-sharp that they added called VAR.

00:54:50.220 --> 00:54:51.840
What does VAR do for me?

00:54:54.360 --> 00:54:54.940
Any ideas?

00:54:56.940 --> 00:54:58.440
It tries to guess what you're trying,

00:54:58.740 --> 00:55:00.360
like the data type you're trying to use.

00:55:01.560 --> 00:55:03.880
Yeah, so what VAR will do is

00:55:04.640 --> 00:55:06.400
C-sharp is strongly typed,

00:55:06.440 --> 00:55:09.080
which means that every variable

00:55:09.080 --> 00:55:12.040
has a specific data type associated to it

00:55:12.040 --> 00:55:14.960
and you can't store data of a different type

00:55:15.880 --> 00:55:16.480
in that variable.

00:55:16.520 --> 00:55:18.680
You have to do some kind of conversion, right?

00:55:19.780 --> 00:55:22.440
So the VAR, if you look at this,

00:55:22.520 --> 00:55:25.020
it is actually still strongly typed.

00:55:25.360 --> 00:55:28.320
So this, my name is actually still a string.

00:55:28.760 --> 00:55:29.880
If I hover over that,

00:55:30.320 --> 00:55:32.360
you can see that that's still gonna be a string.

00:55:32.860 --> 00:55:35.980
But VAR is basically telling Visual Studio

00:55:35.980 --> 00:55:38.100
to figure out the type for you.

00:55:39.260 --> 00:55:44.560
So you actually can use this to declare a variable.

00:55:45.100 --> 00:55:47.680
And how does it figure out what type of data

00:55:47.680 --> 00:55:50.540
is what my name is, what the value that is?

00:55:52.180 --> 00:55:53.760
It's actually gonna look at the data

00:55:53.760 --> 00:55:55.560
that you're assigning to it.

00:55:55.940 --> 00:55:57.440
And so since this is a string,

00:55:57.540 --> 00:55:59.220
it's gonna assume that's a string.

00:56:01.940 --> 00:56:03.460
So here's what I would say,

00:56:03.620 --> 00:56:05.840
what I would recommend is when you're first learning

00:56:05.840 --> 00:56:07.000
to use the language,

00:56:07.720 --> 00:56:11.220
I would suggest that you actually explicitly use

00:56:11.220 --> 00:56:12.660
the data types that you want.

00:56:14.020 --> 00:56:15.440
That way you know what you're getting.

00:56:16.740 --> 00:56:18.540
And then as you get more familiar

00:56:18.540 --> 00:56:21.100
with using C Sharp and the data,

00:56:22.000 --> 00:56:25.300
then you can decide when to use VAR or not to use VAR.

00:56:26.420 --> 00:56:28.420
I think beginning it, when you're first learning it,

00:56:28.440 --> 00:56:29.480
it's better to make sure

00:56:29.480 --> 00:56:31.640
that you know exactly what data type it is

00:56:31.640 --> 00:56:33.960
and you're telling C Sharp what data type to use.

00:56:33.960 --> 00:56:37.200
And then later on you can experiment with VAR

00:56:37.200 --> 00:56:41.140
and see how it works or how it assigns the values.

00:56:43.320 --> 00:56:44.680
Does that answer your question?

00:56:45.360 --> 00:56:45.940
Yes, it does.

00:56:46.620 --> 00:56:47.040
Perfect.

00:56:47.640 --> 00:56:49.280
The other reason you might use VAR

00:56:49.280 --> 00:56:51.280
is sometimes when you're working,

00:56:51.300 --> 00:56:52.320
and you'll see later,

00:56:53.080 --> 00:56:55.460
we'll talk about variables can be things

00:56:55.460 --> 00:56:57.580
other than these few data types.

00:56:58.080 --> 00:56:59.860
And we'll show you some more examples

00:56:59.860 --> 00:57:01.660
when we start doing that as well.

00:57:02.240 --> 00:57:03.040
Great question.

00:57:04.260 --> 00:57:06.540
Let's take a look at now.

00:57:06.720 --> 00:57:08.880
We've got these data that we wanna track

00:57:08.880 --> 00:57:09.900
where we've got variables.

00:57:10.340 --> 00:57:13.340
And now we're gonna learn about using some operators

00:57:13.340 --> 00:57:15.140
that'll allow us to work with those variables.

00:57:15.600 --> 00:57:16.720
So let's take a look.

00:57:16.900 --> 00:57:18.680
I'm gonna go ahead and close this.

00:57:22.700 --> 00:57:24.220
Yeah, it's just a little bit.

00:57:24.840 --> 00:57:26.620
I can't tell if it's the machine.

00:57:26.680 --> 00:57:28.640
I feel like it's my connectivity to the machine

00:57:28.640 --> 00:57:30.220
that's like a little bit lagging maybe.

00:57:32.980 --> 00:57:34.900
So let's take a look at operators.

00:57:39.840 --> 00:57:42.560
So operators are gonna be things

00:57:42.560 --> 00:57:45.200
that allow us to work with our variables.

00:57:45.800 --> 00:57:47.280
And you'll see that they're kind of grouped

00:57:47.280 --> 00:57:48.620
into some categories here.

00:57:49.400 --> 00:57:51.340
Once this opens up.

00:57:57.440 --> 00:57:59.800
Okay, so they're kind of grouped into some categories.

00:57:59.800 --> 00:58:01.680
So there's gonna be operators

00:58:01.680 --> 00:58:04.220
that allow us to do arithmetic operations.

00:58:04.900 --> 00:58:07.460
There's operators that allow us to do logical operations.

00:58:08.680 --> 00:58:10.580
There's also equality operators.

00:58:11.120 --> 00:58:13.100
And then finally, we'll look at comparison.

00:58:13.480 --> 00:58:15.580
So all of these operators are gonna allow us

00:58:15.580 --> 00:58:16.760
to work with our variables

00:58:16.760 --> 00:58:18.900
and do different things with those variables.

00:58:20.300 --> 00:58:22.220
Oh, let me zoom in on that as well.

00:58:23.440 --> 00:58:25.100
Hopefully this zoom will work.

00:58:25.520 --> 00:58:26.080
There we go.

00:58:26.580 --> 00:58:28.440
All right, so let's take a look at arithmetic operators.

00:58:28.440 --> 00:58:31.400
So you're gonna notice that this is in yellow

00:58:31.400 --> 00:58:34.460
and there's this little arrow on the side of my screen.

00:58:34.960 --> 00:58:37.320
I'm gonna call this out right while we're looking at it.

00:58:37.520 --> 00:58:40.100
This has nothing to do with your code.

00:58:40.460 --> 00:58:42.620
It doesn't affect your code in any way.

00:58:43.060 --> 00:58:46.560
But C Sharp does have this kind of cool comment.

00:58:47.520 --> 00:58:50.420
If you put a little hashtag in front of it,

00:58:51.160 --> 00:58:53.140
this region allows me to say,

00:58:53.240 --> 00:58:55.920
hey, this region of code is related.

00:58:56.640 --> 00:58:59.700
Let me see if I can hide this silly zoom window thing here.

00:58:59.880 --> 00:59:00.340
Let's see.

00:59:00.440 --> 00:59:03.660
Doesn't it, it's like Control-Alt-H

00:59:03.660 --> 00:59:05.060
or something silly, right?

00:59:05.900 --> 00:59:09.260
Let's see, hide Control-Alt-Shift-H.

00:59:09.860 --> 00:59:11.100
That's easy to remember.

00:59:14.540 --> 00:59:15.920
Let me show you this region.

00:59:17.320 --> 00:59:19.800
So this region in my code here,

00:59:19.800 --> 00:59:20.800
I've created a region

00:59:20.800 --> 00:59:23.200
and there's a end region tag down here.

00:59:23.840 --> 00:59:26.580
This doesn't affect the way your code runs at all.

00:59:27.120 --> 00:59:28.640
It's just a way for you,

00:59:28.640 --> 00:59:30.920
particularly in demos like I'm showing you,

00:59:31.080 --> 00:59:32.180
to have a block of code

00:59:32.180 --> 00:59:34.000
that you can sort of hide or collapse.

00:59:34.920 --> 00:59:37.380
So it's completely a UI thing.

00:59:38.140 --> 00:59:39.920
Doesn't affect the way your code runs at all.

00:59:40.160 --> 00:59:41.440
So when you see that,

00:59:41.620 --> 00:59:43.160
just be aware that's what it's doing.

00:59:45.580 --> 00:59:47.340
And it doesn't affect the way the code runs.

00:59:47.440 --> 00:59:48.960
It's just something that might make it

00:59:48.960 --> 00:59:50.880
a little bit easier to work with that block of code.

00:59:51.520 --> 00:59:52.580
So let's take a look at some different

00:59:52.580 --> 00:59:54.060
arithmetic operators we can do.

00:59:54.380 --> 00:59:57.280
So I've got some numbers here online, 11 and 12,

00:59:58.160 --> 01:00:00.360
that we've declared and assigned some values to.

01:00:00.820 --> 01:00:02.980
And we're gonna support in C Sharp, of course,

01:00:03.200 --> 01:00:05.960
all of the basic math operations.

01:00:06.560 --> 01:00:08.460
So if I wanna add two numbers together,

01:00:09.040 --> 01:00:13.040
I'm gonna use the plus, right?

01:00:13.040 --> 01:00:16.120
So number one plus number two.

01:00:16.380 --> 01:00:17.820
And then what am I doing here?

01:00:17.820 --> 01:00:20.260
I'm storing the result of that

01:00:20.260 --> 01:00:22.280
in a variable called result.

01:00:22.440 --> 01:00:27.240
And so plus is how you do addition in C Sharp,

01:00:27.440 --> 01:00:29.620
minus, not surprisingly, right?

01:00:29.620 --> 01:00:31.700
That's how you do subtraction.

01:00:33.200 --> 01:00:34.860
I think this is similar to Python, right?

01:00:34.860 --> 01:00:36.480
The asterisk is multiplication

01:00:36.480 --> 01:00:39.440
and then the forward slash is gonna be division.

01:00:40.620 --> 01:00:41.520
Any questions on those?

01:00:41.540 --> 01:00:43.520
Hopefully those are fairly familiar operators.

01:00:43.520 --> 01:00:46.800
So math-wise, we've got plus, minus,

01:00:47.640 --> 01:00:49.040
multiplication and division.

01:00:51.040 --> 01:00:53.360
What is the percent here?

01:00:53.420 --> 01:00:54.820
What does this operator do?

01:00:56.800 --> 01:00:57.120
Any ideas?

01:00:58.760 --> 01:01:01.320
Yeah, so sometimes it's important to know

01:01:01.320 --> 01:01:02.860
not the result of the division,

01:01:02.920 --> 01:01:04.480
but you wanna know what's left over.

01:01:05.380 --> 01:01:09.400
So this percent is actually gonna take number one,

01:01:10.120 --> 01:01:11.620
divide it by number two,

01:01:11.620 --> 01:01:13.860
and then we call it in C Sharp,

01:01:13.880 --> 01:01:15.340
they change the name of it actually.

01:01:15.340 --> 01:01:17.380
It's called the remainder operator now.

01:01:17.740 --> 01:01:19.800
It literally is gonna give you what's left over.

01:01:19.840 --> 01:01:24.580
So if I had, for example, seven divided by two,

01:01:25.720 --> 01:01:28.720
what is the remainder operator

01:01:28.720 --> 01:01:30.640
gonna put into result for me here?

01:01:32.980 --> 01:01:34.160
One, yeah.

01:01:34.320 --> 01:01:36.060
So it'll say, hey, seven divided by two,

01:01:36.080 --> 01:01:38.600
okay, it goes in there evenly three times

01:01:38.600 --> 01:01:40.180
and there's one left over

01:01:40.180 --> 01:01:42.480
and that's what goes into that result.

01:01:43.040 --> 01:01:45.740
So that's probably one that you may or may not

01:01:45.740 --> 01:01:48.440
be familiar with from other languages.

01:01:48.720 --> 01:01:51.580
Does Python use the percent also?

01:01:51.660 --> 01:01:52.040
Yeah, it does.

01:01:52.200 --> 01:01:52.700
Okay, perfect.

01:01:53.600 --> 01:01:54.860
So those are the math operators,

01:01:55.100 --> 01:01:56.220
pretty straightforward, hopefully.

01:01:56.920 --> 01:01:59.220
Let's take a look at the next block here.

01:01:59.360 --> 01:02:00.620
So logical operators.

01:02:02.920 --> 01:02:05.480
So here we've got some Boolean values that we've defined.

01:02:05.680 --> 01:02:08.200
So is big, is green, is quiet.

01:02:09.240 --> 01:02:12.120
And we can write some of these values out.

01:02:14.580 --> 01:02:21.080
So what does the little exclamation point do

01:02:21.820 --> 01:02:24.480
if I put that in front of my Boolean operator?

01:02:24.620 --> 01:02:25.420
Is it like a knot?

01:02:25.780 --> 01:02:27.080
Yes, exactly.

01:02:27.600 --> 01:02:30.980
So what it'll do is it'll say basically

01:02:30.980 --> 01:02:32.740
whatever the value of this is,

01:02:32.800 --> 01:02:34.520
so is green is true

01:02:34.520 --> 01:02:37.480
and with the exclamation point in front of it,

01:02:38.200 --> 01:02:39.440
it'll be a knot.

01:02:39.500 --> 01:02:44.580
So this is basically saying not true, right?

01:02:44.580 --> 01:02:46.340
So the result of that would be false.

01:02:46.860 --> 01:02:47.560
And you're gonna see,

01:02:47.740 --> 01:02:50.580
we'll actually use that exclamation point, that knot,

01:02:51.140 --> 01:02:53.380
quite a bit in our C-sharp code.

01:02:54.420 --> 01:02:55.900
So this is one example of that.

01:02:55.900 --> 01:02:58.160
I can put that in front of a Boolean value

01:02:58.680 --> 01:03:01.620
and it basically swaps the value of that.

01:03:01.900 --> 01:03:02.880
So if it's true,

01:03:03.120 --> 01:03:04.960
putting the knot in front of it makes it false.

01:03:05.580 --> 01:03:06.260
If it's false,

01:03:06.260 --> 01:03:08.900
putting the knot in front of it makes it true.

01:03:09.940 --> 01:03:10.620
Are all of you familiar?

01:03:10.680 --> 01:03:12.280
How do you feel about Boolean operations

01:03:12.280 --> 01:03:13.580
on like one fist to five?

01:03:13.800 --> 01:03:16.860
Everybody's pretty familiar with ands and ors and knots,

01:03:16.920 --> 01:03:17.620
that type of stuff.

01:03:18.280 --> 01:03:18.540
Okay.

01:03:19.280 --> 01:03:21.480
So C-sharp of course has logical operators.

01:03:22.200 --> 01:03:26.260
In C-sharp, we use the ampersand to indicate an and.

01:03:27.980 --> 01:03:31.020
So if I have is quiet and is green,

01:03:31.200 --> 01:03:33.300
both of those values have to be true

01:03:33.300 --> 01:03:35.840
in order for the result to be true, right?

01:03:35.840 --> 01:03:38.280
Same idea, both of those values have to be true

01:03:38.280 --> 01:03:39.360
in order for the result.

01:03:40.300 --> 01:03:41.680
So when you're using the and,

01:03:42.320 --> 01:03:46.560
if either one of those variables has a value of false,

01:03:46.980 --> 01:03:48.340
the result would be false.

01:03:48.800 --> 01:03:51.260
Right, and says that everything has to be true

01:03:51.260 --> 01:03:53.440
in order for the result to be true.

01:03:54.420 --> 01:03:56.920
And we use the ampersand for that in C-sharp.

01:03:57.620 --> 01:04:01.060
In C-sharp, we use the pipe symbol for or.

01:04:01.180 --> 01:04:03.980
So this is is quiet or is green.

01:04:04.840 --> 01:04:07.220
And the pipe symbol, if you're on your keyboard,

01:04:08.000 --> 01:04:10.100
that's right above your forward slash.

01:04:10.200 --> 01:04:12.700
So your enter key typically forward slash

01:04:12.700 --> 01:04:14.100
is right above there.

01:04:14.340 --> 01:04:16.260
And if you do the shift on that,

01:04:16.280 --> 01:04:17.300
that's for your pipe symbol,

01:04:17.380 --> 01:04:18.760
it's a straight up and down line.

01:04:20.200 --> 01:04:22.740
So that's represents or in C-sharp.

01:04:26.440 --> 01:04:29.360
All right, so let's talk about some differences

01:04:29.360 --> 01:04:30.100
C-sharp has.

01:04:30.100 --> 01:04:34.260
What do you think the double and is doing in C-sharp?

01:04:35.020 --> 01:04:37.060
I don't believe to use the double and in Python,

01:04:37.240 --> 01:04:38.000
is that correct?

01:04:38.460 --> 01:04:41.820
So what'll happen here is with an and,

01:04:42.220 --> 01:04:44.680
both of these values would have to be true

01:04:44.680 --> 01:04:46.360
in order for the result to be true.

01:04:47.320 --> 01:04:50.300
So if the computer looks at is quiet

01:04:50.300 --> 01:04:51.980
and his quiet is false,

01:04:52.980 --> 01:04:55.360
it doesn't have to look any further, right?

01:04:55.360 --> 01:04:58.280
It can tell already, well, this one's false.

01:04:58.280 --> 01:05:00.940
I don't even care what the value of this is,

01:05:01.280 --> 01:05:02.500
the result is false.

01:05:03.520 --> 01:05:05.700
So if you use the double and percent,

01:05:06.340 --> 01:05:08.620
it allows you to do what we call short circuit,

01:05:09.160 --> 01:05:10.480
because it basically says,

01:05:11.120 --> 01:05:12.880
if this value is false,

01:05:13.660 --> 01:05:15.940
I don't even care what the second value is,

01:05:15.940 --> 01:05:17.420
I don't have to look at that

01:05:17.420 --> 01:05:20.160
because I know that they both have to be true

01:05:20.160 --> 01:05:21.840
in order for it to be true.

01:05:22.520 --> 01:05:24.440
So as soon as it sees a false here,

01:05:24.560 --> 01:05:26.660
it actually doesn't execute the rest of this.

01:05:28.840 --> 01:05:30.080
Why does that matter?

01:05:30.240 --> 01:05:31.980
Why do you think that's valuable or useful?

01:05:34.120 --> 01:05:35.260
It's really just exactly,

01:05:35.320 --> 01:05:36.960
it's just a time saver, it's more efficient.

01:05:37.160 --> 01:05:38.520
It can literally just say,

01:05:38.820 --> 01:05:39.920
and right now we've just got

01:05:39.920 --> 01:05:41.460
these kind of two simple conditions,

01:05:41.960 --> 01:05:43.660
if these things were a little bit more complicated,

01:05:44.340 --> 01:05:46.380
but yeah, it's really just a time saver.

01:05:46.460 --> 01:05:47.360
It hits this first part,

01:05:47.420 --> 01:05:48.940
it's like, I don't even have to continue.

01:05:50.160 --> 01:05:51.160
With the double and percent,

01:05:51.900 --> 01:05:52.660
oh, was there a question?

01:05:54.480 --> 01:05:55.680
I was just thinking like,

01:05:55.820 --> 01:05:58.420
why would you ever use just one and percent then?

01:06:01.500 --> 01:06:02.500
That's a good question.

01:06:02.640 --> 01:06:04.140
It depends on what you're evaluating.

01:06:04.280 --> 01:06:07.240
Sometimes you actually want to evaluate both sides of it.

01:06:07.680 --> 01:06:09.000
It just entirely depends upon

01:06:09.000 --> 01:06:10.720
what it is that you're checking

01:06:10.720 --> 01:06:12.460
or what those conditions are.

01:06:13.560 --> 01:06:16.020
If it doesn't matter, you can use the AND.

01:06:16.280 --> 01:06:17.980
You're gonna see this used a lot though,

01:06:18.020 --> 01:06:20.780
because you're typically trying to do it faster,

01:06:21.660 --> 01:06:23.700
and a lot of times the things that you're comparing

01:06:24.300 --> 01:06:25.960
are fairly complicated.

01:06:26.540 --> 01:06:29.020
And so, if you can save time

01:06:29.020 --> 01:06:32.220
by not even looking or evaluating this side of something,

01:06:32.720 --> 01:06:33.500
you're gonna do that.

01:06:33.500 --> 01:06:36.520
So you'll see the double and percent used quite a bit.

01:06:39.380 --> 01:06:41.580
What happens if this is quite as true?

01:06:42.620 --> 01:06:44.500
And we still have to check both sides, right?

01:06:45.140 --> 01:06:46.960
The only time the short circuit works

01:06:46.960 --> 01:06:48.840
is actually if the first value is false.

01:06:49.120 --> 01:06:50.300
If this is true,

01:06:50.300 --> 01:06:52.080
the other value could be false,

01:06:52.180 --> 01:06:54.340
so it still has to look at the other value, right?

01:06:56.420 --> 01:06:58.560
And same idea we'll get for,

01:06:59.020 --> 01:07:00.300
let me just scroll down a little bit.

01:07:00.380 --> 01:07:03.000
It's so weird that it doesn't move that automatically.

01:07:06.380 --> 01:07:08.460
Same thing we'll get with the double and percent.

01:07:08.620 --> 01:07:10.420
This is gonna be short circuit also.

01:07:11.560 --> 01:07:13.180
So with the short circuit,

01:07:14.100 --> 01:07:18.640
with an OR, either condition can be true, right?

01:07:18.900 --> 01:07:20.120
So same idea here.

01:07:20.120 --> 01:07:22.220
If the first value is true,

01:07:22.480 --> 01:07:24.760
it doesn't have to even look at the second value.

01:07:26.360 --> 01:07:28.260
So you get the double and percent,

01:07:28.400 --> 01:07:29.120
or not and percent,

01:07:29.120 --> 01:07:31.140
the double pipe symbol for OR as well.

01:07:33.040 --> 01:07:34.380
Any questions at all on that?

01:07:34.480 --> 01:07:35.620
That should be fairly straightforward.

01:07:35.760 --> 01:07:36.960
I think it's the short circuit one.

01:07:37.080 --> 01:07:39.940
It's probably something different in C-sharp

01:07:39.940 --> 01:07:40.840
than what you get in Python.

01:07:41.420 --> 01:07:43.040
All right, let's take a look at

01:07:45.220 --> 01:07:47.420
our equality operators here.

01:07:47.540 --> 01:07:47.900
Oops.

01:07:59.340 --> 01:08:01.880
Okay, so equality,

01:08:02.320 --> 01:08:05.640
we're gonna check and see if something is equal, right?

01:08:06.140 --> 01:08:08.380
So here I've got total one

01:08:08.380 --> 01:08:12.080
and we're signing at this value one plus two plus three

01:08:12.820 --> 01:08:15.780
and total two we're signing at this value six.

01:08:16.980 --> 01:08:20.380
So in C-sharp, we're gonna use the double equal sign.

01:08:21.580 --> 01:08:24.080
We wanna check if something is equal.

01:08:25.120 --> 01:08:28.660
So in this case, is total one equal to total two?

01:08:30.140 --> 01:08:32.120
Right, yes, because six equals six.

01:08:33.180 --> 01:08:35.100
So the double equals is gonna check

01:08:35.100 --> 01:08:36.660
if something is equal.

01:08:37.300 --> 01:08:38.500
And the single equals,

01:08:38.800 --> 01:08:40.400
we're using when we're assigning it.

01:08:40.420 --> 01:08:42.780
So we're assigning the value of six

01:08:42.780 --> 01:08:44.960
to total two with the single equals

01:08:44.960 --> 01:08:48.500
and we use the double equals when we wanna compare

01:08:49.200 --> 01:08:51.360
if those values are the same.

01:08:53.800 --> 01:08:55.480
Let's take a look at that with characters as well.

01:08:55.540 --> 01:08:56.980
So here I've got character data.

01:08:57.080 --> 01:08:59.100
I've got the lowercase a and the uppercase a.

01:08:59.140 --> 01:08:59.920
Are those equal?

01:09:01.220 --> 01:09:03.640
No, because it's case sensitive, right?

01:09:04.060 --> 01:09:09.940
So lowercase a is not equal to uppercase a, right?

01:09:10.180 --> 01:09:11.860
So C-sharp is case sensitive.

01:09:11.960 --> 01:09:13.700
All right, we can also check,

01:09:13.700 --> 01:09:15.700
just like we checked if something is equal,

01:09:15.860 --> 01:09:17.020
we can check inequality

01:09:17.020 --> 01:09:18.880
or we can check if it's not equal.

01:09:19.940 --> 01:09:22.320
So here, just like we saw before

01:09:22.320 --> 01:09:23.840
with the exclamation point,

01:09:23.960 --> 01:09:25.900
the exclamation point is gonna be our not.

01:09:26.580 --> 01:09:29.900
So this is basically saying not equal, right?

01:09:30.420 --> 01:09:33.360
So score not equal to score two.

01:09:34.520 --> 01:09:36.080
And in this case, that's true, right?

01:09:36.340 --> 01:09:38.400
Because seven doesn't equal six.

01:09:39.860 --> 01:09:41.580
So anytime I wanna check inequality,

01:09:41.660 --> 01:09:43.080
I can do the not equal.

01:09:47.340 --> 01:09:48.560
All right, what about this?

01:09:48.560 --> 01:09:49.840
So I've got two strings,

01:09:50.660 --> 01:09:53.100
message one, hello, message two, hello.

01:09:55.000 --> 01:09:57.580
If I check if those are not equal,

01:09:59.160 --> 01:10:00.740
it's gonna tell me false.

01:10:01.020 --> 01:10:02.300
Why are these equal?

01:10:02.520 --> 01:10:03.700
There's two different variables.

01:10:04.740 --> 01:10:05.960
Why are those equal?

01:10:10.020 --> 01:10:13.500
The value assigned to most of the variables is equal.

01:10:14.700 --> 01:10:16.820
Yes, exactly, exactly what Lisa said.

01:10:17.200 --> 01:10:18.360
So in some languages,

01:10:18.480 --> 01:10:20.160
when you're checking if something is equal,

01:10:21.120 --> 01:10:22.940
it would actually look to see

01:10:22.940 --> 01:10:25.540
if the variable is the same.

01:10:26.460 --> 01:10:29.120
C-sharp in this case is looking at the value.

01:10:29.180 --> 01:10:31.060
It's checking the value of those

01:10:31.060 --> 01:10:32.760
when you're checking the equality.

01:10:33.520 --> 01:10:35.800
So it's looking at the value stored

01:10:35.800 --> 01:10:36.840
in each of those variables.

01:10:36.940 --> 01:10:39.000
And because that value is the same,

01:10:39.600 --> 01:10:43.000
it's gonna say that those are the same, right?

01:10:43.000 --> 01:10:44.680
So just be aware of that.

01:10:44.840 --> 01:10:45.540
That's slightly different.

01:10:45.640 --> 01:10:47.120
I don't remember Python equality.

01:10:47.700 --> 01:10:50.120
Would it tell you those are the same

01:10:50.120 --> 01:10:51.440
because they're different variables?

01:10:53.320 --> 01:10:54.820
It compares by value.

01:10:55.280 --> 01:10:55.940
Does value as well?

01:10:56.000 --> 01:10:56.540
Okay, perfect.

01:10:56.760 --> 01:10:59.000
So very familiar what you're used to then.

01:11:00.300 --> 01:11:01.500
All right, so those are equality.

01:11:01.680 --> 01:11:03.800
Let's look at our final group here,

01:11:03.940 --> 01:11:05.060
comparison operators.

01:11:06.140 --> 01:11:08.420
And let's see, we're coming up on about 11 o'clock.

01:11:08.720 --> 01:11:10.260
So we're gonna do, I'll finish this demo.

01:11:10.400 --> 01:11:11.180
We'll do the activity

01:11:11.180 --> 01:11:13.320
and then we'll do our first,

01:11:13.640 --> 01:11:16.120
we'll do basically two 15-minute breaks a day

01:11:16.120 --> 01:11:18.660
and then we'll do an hour for lunch in the middle.

01:11:19.300 --> 01:11:21.060
So coming up here, we'll do an activity

01:11:21.060 --> 01:11:24.240
and then we'll do a 15-minute break after that

01:11:24.240 --> 01:11:28.240
before we review and then we'll keep on rolling.

01:11:28.980 --> 01:11:30.860
All right, let's take a look at comparison operators.

01:11:32.200 --> 01:11:33.980
So here I've got some variables declared,

01:11:34.020 --> 01:11:36.720
some heights, one, two and three.

01:11:37.420 --> 01:11:39.400
Less than, I think this is very familiar to you

01:11:39.400 --> 01:11:40.380
as well in Python.

01:11:40.380 --> 01:11:43.860
We're gonna use the less than symbol.

01:11:43.860 --> 01:11:45.120
It's pointing to the left.

01:11:45.200 --> 01:11:49.080
So we're saying height one is less than height two.

01:11:50.240 --> 01:11:51.840
And in this case, that's false.

01:11:53.820 --> 01:11:57.280
Greater than, we're gonna use that greater than symbol.

01:11:59.060 --> 01:12:00.540
Again, this is saying is height one

01:12:00.540 --> 01:12:01.700
greater than height two.

01:12:01.800 --> 01:12:04.740
Sometimes you wanna know if it's included as well.

01:12:04.760 --> 01:12:08.000
So here we can also do less than or equal to.

01:12:08.000 --> 01:12:11.220
So there's the less than symbol and then equals.

01:12:11.800 --> 01:12:14.820
So we're saying if height one is less than height two

01:12:14.820 --> 01:12:17.380
or if they're the same value.

01:12:18.420 --> 01:12:20.660
So you can actually check both of those conditions

01:12:20.660 --> 01:12:22.920
at the same time, less than or equal to.

01:12:25.620 --> 01:12:27.660
And same idea with greater than or equal to.

01:12:29.180 --> 01:12:30.600
I don't think that's any different

01:12:30.600 --> 01:12:33.000
than what you're, which you'll be able to in Python.

01:12:33.520 --> 01:12:35.640
I think that's very similar as well, right?

01:12:36.420 --> 01:12:38.800
Okay, let's take a look at an activity.

01:12:39.240 --> 01:12:42.000
So in this activity, we're basically gonna have you try

01:12:43.140 --> 01:12:45.300
taking a look at some existing code

01:12:45.300 --> 01:12:47.060
where we're doing some of these different operators

01:12:49.120 --> 01:12:50.700
and writing down what you think

01:12:50.700 --> 01:12:52.140
will be the result of those.

01:12:52.940 --> 01:12:57.280
And then we'll run that code to see how close you were,

01:12:57.440 --> 01:12:59.740
how accurate you were with understanding

01:12:59.740 --> 01:13:02.560
what those different operators are doing.

01:13:03.140 --> 01:13:04.920
Let me show you this in here really quickly.

01:13:04.920 --> 01:13:08.180
So let me go Hello World variables.

01:13:09.360 --> 01:13:11.540
So this is gonna be your operators activity.

01:13:14.820 --> 01:13:16.980
And if I open the preview for that.

01:13:20.040 --> 01:13:23.200
So here we're gonna have you evaluate operators

01:13:23.200 --> 01:13:26.120
and determine what the result that will be written out

01:13:26.120 --> 01:13:26.440
will be.

01:13:26.520 --> 01:13:28.580
So we're gonna take a look at that operator solution.

01:13:29.200 --> 01:13:30.940
And then you'll see there's a bunch of comments

01:13:30.940 --> 01:13:33.740
in there with to-dos where we're asking you

01:13:33.740 --> 01:13:35.080
to answer some different questions.

01:13:35.740 --> 01:13:37.340
And then of course, give me a note that,

01:13:37.340 --> 01:13:39.140
be prepared to discuss your answers.

01:13:39.980 --> 01:13:41.880
And then we'll have you build and run the code

01:13:41.880 --> 01:13:42.760
to see your output.

01:13:44.080 --> 01:13:46.300
So if you take a look at that starter code,

01:13:46.840 --> 01:13:47.680
it's in there.

01:13:48.820 --> 01:13:50.500
So I will open that for you really quick.

01:13:51.080 --> 01:13:51.980
So activities.

01:13:53.620 --> 01:13:54.680
That was in the right folder.

01:13:55.980 --> 01:13:56.860
Operators starter.

01:13:59.160 --> 01:14:00.840
And then if you open this solution,

01:14:03.760 --> 01:14:06.800
you're gonna see that there's a existing code

01:14:06.800 --> 01:14:07.420
already in here.

01:14:07.560 --> 01:14:09.960
We're not having any write any new code for this activity,

01:14:10.240 --> 01:14:12.700
but we'll have you take a look at the existing code.

01:14:19.320 --> 01:14:20.720
So again, those regions,

01:14:20.720 --> 01:14:22.280
you're gonna see they're collapsed.

01:14:22.760 --> 01:14:24.880
You can just click the little arrow,

01:14:24.880 --> 01:14:26.340
the care there to expand those.

01:14:27.400 --> 01:14:29.600
And so we just got a series of operations

01:14:29.600 --> 01:14:31.120
and we're basically asking you,

01:14:31.360 --> 01:14:32.680
what's this gonna write out?

01:14:33.840 --> 01:14:35.020
To the console.

01:14:36.020 --> 01:14:38.020
So just some quick understanding

01:14:38.020 --> 01:14:40.460
of what those different operators are gonna do,

01:14:40.700 --> 01:14:42.220
or what they're gonna output.

01:14:45.420 --> 01:14:46.160
So as you expand those,

01:14:46.280 --> 01:14:48.040
you'll see there's quite a few of these.

01:14:49.760 --> 01:14:51.940
And then once you're finished putting your,

01:14:52.060 --> 01:14:52.880
you can write in a comment,

01:14:52.980 --> 01:14:54.600
you can put what you think the result will be.

01:14:54.920 --> 01:14:56.200
And then once you're finished with that,

01:14:56.280 --> 01:14:58.940
we'll run that and we'll actually take a look and see,

01:14:59.080 --> 01:15:00.360
was there anything unexpected?

01:15:00.800 --> 01:15:02.180
Is there an operator in there

01:15:02.180 --> 01:15:04.380
that the output is different than what you thought?

01:15:05.720 --> 01:15:07.820
All right, so about 10 minutes on this,

01:15:07.820 --> 01:15:09.800
and then we'll do our quick break.

01:15:10.380 --> 01:15:13.560
And then we'll come back from that and do a review.

01:15:14.280 --> 01:15:15.280
Any questions on that?

01:15:17.860 --> 01:15:19.560
All right, fantastic.

01:15:19.640 --> 01:15:21.160
Let's take a look at that.

01:15:21.180 --> 01:15:21.860
And we'll stop here.

01:15:21.960 --> 01:15:23.440
Once I remember that crazy sequence,

01:15:23.460 --> 01:15:24.860
Control-Shift-Alt-H.

01:15:50.480 --> 01:15:51.880
Okay.

01:16:21.020 --> 01:16:21.400
Whoa.

01:16:57.400 --> 01:16:57.840
Okay.

01:16:58.160 --> 01:17:00.020
It'll take about a minute or so here,

01:17:00.020 --> 01:17:03.380
and then we will take a quick break.

01:17:03.900 --> 01:17:06.940
Like most of you are already running it

01:17:06.940 --> 01:17:08.460
or looking at your results.

01:17:11.480 --> 01:17:12.540
Yes, that's happening.

01:17:14.720 --> 01:17:16.800
So we'll do a 15 minute break now.

01:17:17.100 --> 01:17:20.300
And then this is what, 11, 15 for y'all.

01:17:22.220 --> 01:17:24.340
Normally we would do 15 minute break.

01:17:24.680 --> 01:17:26.020
And then the middle of the day,

01:17:26.020 --> 01:17:28.140
a class would do like 60 minute break for lunch.

01:17:28.140 --> 01:17:31.120
Since we're kind of on different time for that.

01:17:31.140 --> 01:17:32.480
I don't know.

01:17:32.660 --> 01:17:33.540
We'll see how that works out.

01:17:33.580 --> 01:17:34.980
Cause you're getting a 15 minute now.

01:17:35.240 --> 01:17:38.180
And then the 60 minute break is gonna be

01:17:38.180 --> 01:17:40.180
kind of in your afternoon, I guess.

01:17:42.000 --> 01:17:42.880
But we'll try this.

01:17:42.980 --> 01:17:43.700
We'll see how it works.

01:17:43.920 --> 01:17:48.940
And then we'll do from now, 9, 10 until 9, 25.

01:17:49.980 --> 01:17:50.620
I'm sorry.

01:17:50.740 --> 01:17:51.880
We'll do a 15 minute break.

01:17:52.060 --> 01:17:54.300
So what, that's 11, 10 for you to 11, 25.

01:17:54.400 --> 01:17:55.520
And then we'll come back

01:17:55.520 --> 01:17:59.440
and we'll do a few more activities before our big break.

01:17:59.560 --> 01:18:00.100
Any questions?

01:18:01.940 --> 01:18:04.020
I'll see you back in about 15 minutes.

01:18:06.620 --> 01:18:07.400
Yeah, it's weird.

01:18:07.460 --> 01:18:10.300
So they're gonna get a 15 minute break.

01:18:11.820 --> 01:18:13.640
It's already 11 for them.

01:18:14.680 --> 01:18:18.640
Yeah, that's just a weird, weird time.

01:18:23.880 --> 01:18:27.300
25, we'll already do that.

01:18:33.360 --> 01:18:34.100
Any question?

01:18:34.880 --> 01:18:38.040
So that's nine to four.

01:18:38.220 --> 01:18:40.620
9 to 10, 10 to 11, 11 to 12, 11 to 12,

01:18:40.620 --> 01:18:42.760
1 to 2, 2 to 3, 2 to 4, 7 on.

01:18:59.040 --> 01:19:02.120
I totally knew something, I thought you were asking me.

01:19:07.280 --> 01:19:09.240
Oh, yeah.

01:19:17.740 --> 01:19:18.960
Welcome back.

01:19:19.940 --> 01:19:22.500
Let's take a look at some code here.

01:19:24.100 --> 01:19:24.740
Don't bother.

01:19:26.360 --> 01:19:27.680
Don't bother, you're fast.

01:19:32.120 --> 01:19:35.400
Do you write code quite a bit in your current role?

01:19:36.340 --> 01:19:36.640
No.

01:19:36.880 --> 01:19:37.200
No.

01:19:37.200 --> 01:19:38.320
Oh, okay, okay.

01:19:38.720 --> 01:19:39.440
I saw there was a-

01:19:40.540 --> 01:19:41.100
So, I'm sorry.

01:19:41.100 --> 01:19:42.460
Oh, no, good, no, I'm sorry.

01:19:42.800 --> 01:19:45.280
No, I'm just saying that I'm just starting

01:19:45.280 --> 01:19:48.320
to learn Python, I'm not very far into it.

01:19:51.420 --> 01:19:53.340
And I'm trying to keep up with you

01:19:53.340 --> 01:19:54.500
doing what you're doing.

01:19:54.660 --> 01:19:57.220
And it seems logical when I see it on your screen

01:19:57.220 --> 01:19:59.100
and then when I go into mine to do it,

01:19:59.160 --> 01:20:01.320
it's like, I don't know what the flip you did.

01:20:01.320 --> 01:20:08.540
Yeah, I understand that.

01:20:09.380 --> 01:20:13.980
So, I'm trying to keep up with,

01:20:13.980 --> 01:20:17.520
but it's confusing to me when I'm trying to do it

01:20:17.520 --> 01:20:20.180
on my own, it's just not working very well.

01:20:21.440 --> 01:20:23.820
I mean, if it helps to do it,

01:20:24.380 --> 01:20:26.440
you're welcome to code along with me,

01:20:26.460 --> 01:20:30.520
while I'm doing the code, if that helps.

01:20:31.080 --> 01:20:33.600
But what I'm gonna do and then when you do the activity

01:20:33.600 --> 01:20:35.480
is gonna be like slightly different code,

01:20:36.040 --> 01:20:37.840
but very similar ideas.

01:20:37.860 --> 01:20:39.440
So, I don't know if that helps,

01:20:39.480 --> 01:20:41.300
you're welcome to do that.

01:20:41.300 --> 01:20:43.700
Yeah, Kayleen, in college what we used to do

01:20:43.700 --> 01:20:45.200
is we used to pull up the same program

01:20:45.200 --> 01:20:47.640
the professor opened and then we just create a comment

01:20:47.640 --> 01:20:50.160
and note it while he was talking.

01:20:50.280 --> 01:20:52.760
So, I have notes from the same program,

01:20:53.200 --> 01:20:55.920
whenever he opens, I just put note comments in there.

01:20:55.940 --> 01:20:57.920
So, it helps for you to remember

01:20:57.920 --> 01:21:01.540
and follow along with what he's doing at the same time.

01:21:01.700 --> 01:21:03.640
Well, that's a great suggestion, Alain.

01:21:07.220 --> 01:21:08.980
And if I'm going too fast as well,

01:21:09.600 --> 01:21:11.340
there is a timetable,

01:21:11.360 --> 01:21:12.780
like a schedule that we're trying to meet,

01:21:13.500 --> 01:21:14.980
but if I'm going too fast,

01:21:15.380 --> 01:21:17.840
like feel free to call me out,

01:21:17.880 --> 01:21:19.220
like I can slow it down.

01:21:19.580 --> 01:21:21.260
I'm trying to juggle that balance

01:21:22.800 --> 01:21:24.580
between making the schedule

01:21:24.580 --> 01:21:27.320
but still make sure everybody comes along with me.

01:21:27.320 --> 01:21:28.620
Right, so.

01:21:28.620 --> 01:21:28.920
Yeah.

01:21:29.240 --> 01:21:31.760
I don't know, he was just very passionate.

01:21:32.040 --> 01:21:33.660
So, he kind of went off the subject

01:21:33.660 --> 01:21:35.360
and then we had to go back and try to catch up.

01:21:35.520 --> 01:21:38.640
It's like, okay, well, my notes.

01:21:41.100 --> 01:21:44.220
Well, hopefully we're not quite that,

01:21:44.220 --> 01:21:45.460
but we'll try to get there.

01:21:45.520 --> 01:21:46.440
Let's see here.

01:21:46.740 --> 01:21:48.580
Let me move this to the side.

01:21:49.660 --> 01:21:52.600
Oh, what's going on with my desktop here?

01:21:53.520 --> 01:21:55.140
Need to refresh the browser maybe?

01:21:55.300 --> 01:21:56.080
Okay, there we go.

01:21:56.080 --> 01:21:57.860
That was a little scary.

01:21:58.280 --> 01:21:58.860
All right.

01:22:00.400 --> 01:22:02.760
So, take a look at this operator's activity

01:22:02.760 --> 01:22:04.320
that we were just working on.

01:22:08.660 --> 01:22:10.900
Can't tell, is it opening it or not opening it?

01:22:13.040 --> 01:22:13.740
There we go.

01:22:13.960 --> 01:22:14.760
All right.

01:22:15.620 --> 01:22:16.360
Gonna have to remember that.

01:22:16.440 --> 01:22:18.560
I got to refresh my desktop once in a while there.

01:22:19.620 --> 01:22:21.820
So, the big takeaway on this one really is

01:22:21.820 --> 01:22:25.620
that the important thing to our programs is data.

01:22:25.620 --> 01:22:28.000
And we're gonna use variables to store that data.

01:22:28.660 --> 01:22:31.780
And with this activity, we're learning about ways

01:22:31.780 --> 01:22:34.220
that we can work with those variables,

01:22:34.380 --> 01:22:37.800
either change those variables or compare those variables.

01:22:38.520 --> 01:22:40.440
And so, that's really the focus on this.

01:22:41.000 --> 01:22:42.080
This isn't a math quiz.

01:22:43.640 --> 01:22:45.640
I don't care if you got the exact numbers right,

01:22:46.360 --> 01:22:49.440
but really just understanding what's available to you,

01:22:49.440 --> 01:22:51.980
all these different operators that allow you

01:22:51.980 --> 01:22:53.420
to work with your variables

01:22:53.420 --> 01:22:55.520
and do different comparisons with those.

01:22:57.440 --> 01:23:00.920
So, on the first one, the other thing I wanna call out,

01:23:00.920 --> 01:23:01.640
and this is a takeaway,

01:23:01.720 --> 01:23:03.880
let me zoom in on my desktop here real quick,

01:23:05.140 --> 01:23:08.080
is that, oh, it's so strange,

01:23:08.100 --> 01:23:09.480
it leaves the start menu open.

01:23:09.480 --> 01:23:10.060
There we go.

01:23:10.700 --> 01:23:11.140
Okay.

01:23:13.220 --> 01:23:15.540
Is that when we're writing the results of these out,

01:23:15.580 --> 01:23:17.860
you can see, we can write variables out,

01:23:17.860 --> 01:23:20.180
as well as we can actually write out

01:23:20.180 --> 01:23:21.940
those expressions as well.

01:23:21.940 --> 01:23:26.180
So, here, C Sharp is actually gonna do that addition first,

01:23:26.380 --> 01:23:27.940
and then it's the result of that

01:23:27.940 --> 01:23:29.120
that's gonna get written out.

01:23:29.540 --> 01:23:32.140
So, you have that kind of flexibility both ways

01:23:32.140 --> 01:23:32.920
to do those.

01:23:33.980 --> 01:23:35.120
So, hopefully, the plus,

01:23:35.300 --> 01:23:37.260
the addition one is fairly straightforward.

01:23:37.420 --> 01:23:39.700
It's just gonna add those together,

01:23:39.700 --> 01:23:42.080
and you're gonna get that result out as a value.

01:23:43.620 --> 01:23:45.160
And obviously, as I go through here,

01:23:45.180 --> 01:23:46.560
if you have any questions at all

01:23:46.560 --> 01:23:50.460
on any of these operators or what the result was,

01:23:50.460 --> 01:23:52.500
please feel free to ask me that.

01:24:02.400 --> 01:24:08.000
No, that's actually a great question.

01:24:08.080 --> 01:24:10.540
So, even though those data types are different,

01:24:10.600 --> 01:24:11.740
so if you hover over those,

01:24:11.960 --> 01:24:14.100
you can see this is a double because of the decimal,

01:24:15.080 --> 01:24:17.860
and then this is gonna be an integer.

01:24:18.740 --> 01:24:23.460
What'll happen is when you're passing the result of that

01:24:23.460 --> 01:24:25.300
to this console write line,

01:24:25.680 --> 01:24:29.280
C Sharp is actually gonna try to convert those if it can.

01:24:30.040 --> 01:24:33.240
So, it's gonna say, I've got this decimal value,

01:24:33.340 --> 01:24:35.220
and I've got this different data type.

01:24:35.980 --> 01:24:38.420
Is there a way that I can still add those together?

01:24:38.940 --> 01:24:40.520
And so, what it'll do, actually,

01:24:40.720 --> 01:24:45.240
is it'll treat this integer as though it was a double.

01:24:45.760 --> 01:24:49.620
So, it'll say, hey, I can make this a double,

01:24:50.060 --> 01:24:52.080
and then I can add these two together,

01:24:52.080 --> 01:24:53.780
and I can get a double result.

01:24:54.900 --> 01:24:56.040
So, that's a great question.

01:24:56.280 --> 01:24:58.280
Even though those data types are different,

01:24:59.700 --> 01:25:01.620
it'll actually still try to use those for you.

01:25:01.680 --> 01:25:02.620
Was that what your question was?

01:25:04.780 --> 01:25:05.180
Perfect.

01:25:05.540 --> 01:25:07.040
And the other thing to be aware of there

01:25:07.040 --> 01:25:08.280
is a lot of times,

01:25:08.520 --> 01:25:10.560
you'll get some kind of a warning message.

01:25:11.040 --> 01:25:12.860
So, just like we saw those squiggly lines,

01:25:12.920 --> 01:25:14.600
you'll get some kind of a warning message

01:25:14.600 --> 01:25:18.200
in Visual Studio anytime you're doing something

01:25:18.200 --> 01:25:20.940
where you're working with two different data types.

01:25:23.140 --> 01:25:25.200
Even if the result still works,

01:25:25.260 --> 01:25:26.420
which it does in this case,

01:25:26.600 --> 01:25:29.360
Visual Studio will usually warn you and say,

01:25:29.560 --> 01:25:32.600
hey, FYI, those are actually different data types,

01:25:32.600 --> 01:25:34.340
and I'm gonna convert those for you,

01:25:34.440 --> 01:25:35.480
but just be aware.

01:25:35.960 --> 01:25:37.900
So, this case, it doesn't, actually.

01:25:38.440 --> 01:25:40.300
So, that's a good call out.

01:25:40.700 --> 01:25:41.620
And in other examples,

01:25:41.620 --> 01:25:43.040
you can see if you hover over these,

01:25:43.040 --> 01:25:45.640
these are actually two integers it's adding, right?

01:25:45.640 --> 01:25:48.180
And then here, you're also just adding those two decimals.

01:25:48.520 --> 01:25:50.340
So, that one is the only different one there.

01:25:52.840 --> 01:25:54.900
Same idea when you're doing the subtraction.

01:25:55.380 --> 01:25:58.200
So, in this case, again,

01:25:58.320 --> 01:26:00.700
because we're doing different values.

01:26:01.060 --> 01:26:02.100
And so, you're gonna see here,

01:26:02.220 --> 01:26:04.080
it actually, this is an integer, right?

01:26:04.080 --> 01:26:04.820
This is a double.

01:26:05.260 --> 01:26:07.000
So, it's actually gonna do the same thing.

01:26:07.000 --> 01:26:08.060
It's actually gonna say,

01:26:08.560 --> 01:26:11.520
hey, can I take one of those values and convert it

01:26:11.520 --> 01:26:14.840
so that they're both doubles,

01:26:14.960 --> 01:26:17.480
and then I can do the math operation on those.

01:26:22.240 --> 01:26:23.980
Multiplication, again, very similar.

01:26:24.360 --> 01:26:25.840
So, if it can do the result,

01:26:25.900 --> 01:26:27.520
it'll do that, and you'll get the result.

01:26:28.300 --> 01:26:30.320
If it does have to do some kind of conversion,

01:26:30.520 --> 01:26:31.440
it will.

01:26:31.700 --> 01:26:34.380
In this case, is it converting here on line 26?

01:26:36.220 --> 01:26:37.520
If you-

01:26:37.520 --> 01:26:38.340
Yeah, if you look,

01:26:38.380 --> 01:26:40.700
these are actually both, both have decimals, right?

01:26:40.700 --> 01:26:43.000
So, it actually doesn't have to do any conversion there.

01:26:44.740 --> 01:26:45.400
What about this?

01:26:45.620 --> 01:26:48.520
So, line 31, we're doing the console, right?

01:26:48.560 --> 01:26:50.540
Line 13 divided by nine,

01:26:51.100 --> 01:26:53.180
and I'm getting the value of one.

01:26:54.040 --> 01:26:55.720
Is that what you would expect for that?

01:26:55.900 --> 01:26:59.220
So, because these are both integers, right,

01:26:59.220 --> 01:27:00.020
that you're putting in,

01:27:00.020 --> 01:27:02.360
you're actually gonna get an integer value out.

01:27:02.660 --> 01:27:04.560
And so, integer means whole number, right?

01:27:04.560 --> 01:27:07.000
And so, you're losing any decimal

01:27:07.000 --> 01:27:07.780
that you would have there.

01:27:07.780 --> 01:27:09.180
So, again, when you're working with numbers,

01:27:09.260 --> 01:27:10.620
that's probably the trickiest thing

01:27:10.620 --> 01:27:13.920
to remember is that the different data types do matter

01:27:14.540 --> 01:27:17.900
as far as the, how accurate or how precise

01:27:17.900 --> 01:27:20.440
that result that you're gonna get back is.

01:27:21.340 --> 01:27:22.420
You know, if this was dollars,

01:27:22.420 --> 01:27:24.280
I would be very, very concerned

01:27:24.280 --> 01:27:27.060
that I was losing the percentage, right?

01:27:28.920 --> 01:27:30.760
And then same idea for remainder.

01:27:31.140 --> 01:27:32.580
It's gonna scroll the screen a little bit there,

01:27:32.680 --> 01:27:33.280
apparently.

01:27:35.700 --> 01:27:38.300
I think tomorrow I'm gonna do the code demos

01:27:38.300 --> 01:27:40.240
off of my regular machine,

01:27:40.240 --> 01:27:41.760
just because I think it'll be a little easier

01:27:41.760 --> 01:27:42.900
to zoom in and out here.

01:27:44.500 --> 01:27:46.380
For the remainder operator,

01:27:47.080 --> 01:27:49.380
again, you're only gonna get what's left over.

01:27:49.860 --> 01:27:53.100
And so, since these are gonna be integers,

01:27:53.480 --> 01:27:55.280
we're not keeping those decimals.

01:27:55.860 --> 01:27:58.060
What's left over is really zero, right?

01:27:58.060 --> 01:27:59.800
So, you're getting zero.

01:28:00.700 --> 01:28:01.740
Well, in this case, it's even.

01:28:01.800 --> 01:28:03.560
It divides evenly, so you're getting the zero.

01:28:04.020 --> 01:28:06.880
Any questions at any of the comparison operators?

01:28:07.680 --> 01:28:08.100
I'm sorry.

01:28:09.300 --> 01:28:12.040
Any question at any of the mathematical operators?

01:28:13.120 --> 01:28:13.900
All right, logical ones.

01:28:13.920 --> 01:28:15.660
This is ones where sometimes things

01:28:15.660 --> 01:28:18.300
you can easily get tripped up, I feel like.

01:28:19.080 --> 01:28:23.060
So Boolean passed variable, we're declaring as false.

01:28:23.660 --> 01:28:26.860
And so, if I write out not passed,

01:28:28.100 --> 01:28:31.140
I'm actually gonna get true as the result from that.

01:28:32.100 --> 01:28:34.700
So, remember that exclamation point

01:28:34.700 --> 01:28:37.920
is gonna do the reverse of whatever the value is.

01:28:37.940 --> 01:28:40.000
So, this value is gonna be false.

01:28:40.860 --> 01:28:42.520
And so, the reverse of that,

01:28:42.560 --> 01:28:44.720
the not of that is gonna be true.

01:28:44.880 --> 01:28:46.460
And this is just another example, too,

01:28:46.540 --> 01:28:50.360
of where naming your variables something descriptive

01:28:50.360 --> 01:28:51.880
can help because,

01:28:52.100 --> 01:28:54.280
you know, here, if I've got this variable called passed,

01:28:55.800 --> 01:28:58.340
when I see this line on line 50,

01:28:58.560 --> 01:29:00.380
you can almost read it, right?

01:29:00.500 --> 01:29:03.000
If you read the exclamation point as not,

01:29:03.640 --> 01:29:06.280
you're saying not passed, right?

01:29:06.640 --> 01:29:09.100
So, making your variable names descriptive

01:29:09.100 --> 01:29:11.660
can actually sort of help you

01:29:12.560 --> 01:29:13.720
when you're trying to look at code

01:29:13.720 --> 01:29:15.260
and understand what that code is doing.

01:29:16.840 --> 01:29:19.920
Why is this pink or whatever?

01:29:20.180 --> 01:29:22.440
Why do you think this true is highlighted here?

01:29:25.840 --> 01:29:28.900
That's a Boolean value that's recognized by C-charm.

01:29:29.700 --> 01:29:31.440
Yeah, it's actually a key word, right?

01:29:31.440 --> 01:29:34.960
So, just be aware that there are certain words

01:29:34.960 --> 01:29:38.140
that C-sharp is using and it's expecting to use.

01:29:38.560 --> 01:29:40.360
And so, those are actually words

01:29:40.360 --> 01:29:42.020
that mean something to C-sharp.

01:29:42.420 --> 01:29:44.440
So, just be careful that, you know,

01:29:44.440 --> 01:29:46.280
as you're naming things, when you're naming it,

01:29:46.340 --> 01:29:47.360
be descriptive, right?

01:29:47.820 --> 01:29:50.040
You don't wanna name something the same

01:29:50.040 --> 01:29:52.160
that a C-sharp keyword is

01:29:52.160 --> 01:29:55.260
because that's gonna not do what you expect, right?

01:29:55.600 --> 01:29:57.980
So, in this example, we're just showing you, though,

01:29:57.980 --> 01:30:00.480
that you can use that keyword true.

01:30:01.440 --> 01:30:02.700
When you're doing your test.

01:30:03.300 --> 01:30:05.700
And you can also use the not operator

01:30:05.700 --> 01:30:06.940
on that keyword, right?

01:30:07.020 --> 01:30:08.700
So, not true is false.

01:30:11.860 --> 01:30:13.700
Hopefully, these are fairly straightforward.

01:30:13.860 --> 01:30:15.240
So, with the and,

01:30:15.380 --> 01:30:18.120
the ampersand is gonna be our logical and,

01:30:18.840 --> 01:30:20.460
both parts have to be true.

01:30:20.540 --> 01:30:22.300
So, since this is false,

01:30:23.460 --> 01:30:26.020
the result is always gonna be false.

01:30:27.900 --> 01:30:30.420
The tool tips are trying to help me out there

01:30:30.420 --> 01:30:31.320
by getting in the way.

01:30:32.320 --> 01:30:33.500
So, false and true.

01:30:33.620 --> 01:30:35.000
Both of them have to be true

01:30:35.000 --> 01:30:36.500
in order for the result to be true.

01:30:36.620 --> 01:30:38.560
So, in this case, the first one is false.

01:30:38.660 --> 01:30:39.920
We're gonna get false as the out.

01:30:41.620 --> 01:30:43.020
If they're both true,

01:30:43.120 --> 01:30:44.660
like they are here on line 58,

01:30:45.660 --> 01:30:47.380
then the result would be true, all right?

01:30:47.540 --> 01:30:49.400
Gonna keep scrolling this thing, apparently.

01:30:58.580 --> 01:31:02.000
Okay, same idea with our or, right?

01:31:02.020 --> 01:31:03.740
So, the pipe symbol is gonna be the or.

01:31:04.060 --> 01:31:05.400
So, you can true or true.

01:31:05.560 --> 01:31:07.080
If either one of them is true,

01:31:07.620 --> 01:31:08.840
then the output will be true.

01:31:09.880 --> 01:31:10.660
False or true.

01:31:10.780 --> 01:31:12.220
Again, if either one is true,

01:31:12.320 --> 01:31:13.760
you're gonna get a true as an out.

01:31:16.220 --> 01:31:18.060
And then, always keep in mind,

01:31:18.300 --> 01:31:19.380
and you'll see this very common,

01:31:19.380 --> 01:31:21.580
commonly that they'll use the short-circuit version.

01:31:21.860 --> 01:31:25.200
So, the double ampersand, the double and,

01:31:26.040 --> 01:31:28.380
is basically gonna try to short-circuit,

01:31:28.540 --> 01:31:30.440
try to be more efficient, right, if it can.

01:31:30.860 --> 01:31:33.820
So, here, as soon as C-sharp sees

01:31:33.820 --> 01:31:35.660
that this first part is false,

01:31:36.200 --> 01:31:38.580
it doesn't even have to look at the second part.

01:31:39.420 --> 01:31:40.700
Doesn't have to evaluate it.

01:31:40.920 --> 01:31:42.480
They both would have to be true

01:31:42.480 --> 01:31:44.000
in order for the result to be true.

01:31:44.320 --> 01:31:45.960
So, as soon as it sees the false

01:31:45.960 --> 01:31:48.120
in that first position, it's done.

01:31:48.120 --> 01:31:50.520
It doesn't even have to look at the rest of the code.

01:31:51.780 --> 01:31:54.120
All right, similarly, if the first one is true,

01:31:54.840 --> 01:31:56.000
it can't short-circuit.

01:31:56.060 --> 01:31:57.800
It actually has to look at the second part

01:31:57.800 --> 01:31:59.260
to make sure that it's also true.

01:31:59.420 --> 01:32:01.140
Any questions on that, that short-circuiting?

01:32:02.600 --> 01:32:04.660
So, it's just basically, if it can,

01:32:06.120 --> 01:32:06.840
do it quicker.

01:32:07.080 --> 01:32:09.000
If it doesn't have to look at the second one,

01:32:09.000 --> 01:32:09.840
it won't.

01:32:11.680 --> 01:32:14.240
But, if it doesn't have enough information,

01:32:14.320 --> 01:32:15.840
it actually has to look at both parts.

01:32:16.260 --> 01:32:17.600
All right, and you can see the same thing here

01:32:17.600 --> 01:32:19.780
with the double-pipe sign, the or.

01:32:21.060 --> 01:32:24.200
Just allows you to short-circuit if you can.

01:32:24.280 --> 01:32:25.400
All right, let's look at equality.

01:32:28.760 --> 01:32:31.560
All right, so remember, the single equal sign

01:32:31.560 --> 01:32:34.180
is gonna be, whoop.

01:32:35.900 --> 01:32:36.820
There we go.

01:32:37.600 --> 01:32:40.120
Single equal sign is gonna be our assignment, right?

01:32:40.120 --> 01:32:41.580
So, we're assigning a value.

01:32:41.940 --> 01:32:44.360
So, we're gonna use the double equals

01:32:45.300 --> 01:32:47.200
to check if something is equal.

01:32:48.040 --> 01:32:51.740
So, if those values are equal, that'll be true.

01:32:53.540 --> 01:32:54.100
Here,

01:32:55.420 --> 01:32:58.060
the values, uppercase and lowercase,

01:32:58.360 --> 01:33:01.040
are not the same in C-sharp.

01:33:02.040 --> 01:33:05.980
So, those were equal will be false for that,

01:33:06.040 --> 01:33:07.740
because those are not the same in C-sharp.

01:33:07.780 --> 01:33:09.960
You can also test the reverse of that, right?

01:33:10.060 --> 01:33:10.920
So, inequality.

01:33:11.140 --> 01:33:12.920
So, with the exclamation point,

01:33:12.940 --> 01:33:14.460
we can check not equals

01:33:15.020 --> 01:33:18.220
to see if the values of those are not the same.

01:33:21.920 --> 01:33:23.400
All right, same thing we did in the demo,

01:33:23.540 --> 01:33:24.420
we're on the strings.

01:33:25.400 --> 01:33:28.280
They're actually the same because the value is the same.

01:33:28.620 --> 01:33:30.840
Here is a curveball we threw you, right?

01:33:31.120 --> 01:33:33.900
So, there's a data type we're using called object,

01:33:34.600 --> 01:33:37.400
and even though the values are the same on those,

01:33:38.880 --> 01:33:41.000
those are, in fact, not equal,

01:33:41.000 --> 01:33:45.480
because this equality for data type of object

01:33:46.160 --> 01:33:49.020
is actually looking to see if the object,

01:33:49.180 --> 01:33:52.340
the variable is the same, not the value.

01:33:52.780 --> 01:33:54.960
So, this is kind of a curveball to throw at you there.

01:33:55.840 --> 01:33:57.620
So, normally, in most scenarios,

01:33:57.700 --> 01:33:59.180
when you're checking that equality,

01:33:59.340 --> 01:34:00.680
it's looking at the value,

01:34:01.080 --> 01:34:02.920
but be aware that for object,

01:34:02.960 --> 01:34:05.100
and we'll show you some other scenarios,

01:34:06.180 --> 01:34:09.620
that when you're checking equality for those objects,

01:34:10.260 --> 01:34:11.700
that it's actually looking to see

01:34:11.700 --> 01:34:13.940
if the variable is the same.

01:34:14.080 --> 01:34:15.840
Even though the value is the same,

01:34:16.500 --> 01:34:17.820
it's a different variable,

01:34:17.960 --> 01:34:19.940
and so it's telling you it's not the same variable.

01:34:24.300 --> 01:34:26.580
Now, let's do some comparisons as well.

01:34:27.900 --> 01:34:30.720
Let's scroll again, let me pre-scroll here.

01:34:33.700 --> 01:34:35.140
Excuse me, enough, there we go.

01:34:35.680 --> 01:34:38.220
So, the less than, we're checking to see

01:34:38.220 --> 01:34:41.420
if this value less than this value, right?

01:34:41.420 --> 01:34:43.120
So, we're able to do those comparisons.

01:34:44.740 --> 01:34:46.480
Similarly, the greater than, right?

01:34:46.480 --> 01:34:48.320
So, is this value on the left side

01:34:48.320 --> 01:34:50.340
greater than the value on the right side?

01:34:52.940 --> 01:34:54.880
And then, you also have the ability

01:34:54.880 --> 01:34:56.180
to do less than or equal to.

01:34:56.400 --> 01:34:59.000
Why is this less than or equals to?

01:34:59.100 --> 01:35:02.180
So, 7.0 less than or equal to 9.1.

01:35:02.760 --> 01:35:06.020
Why would we do that versus just less than 9.1?

01:35:10.840 --> 01:35:12.220
What's the difference there?

01:35:12.580 --> 01:35:14.820
What is the equals doing for me there?

01:35:17.240 --> 01:35:18.060
It's including.

01:35:18.760 --> 01:35:20.080
I'm sorry, go ahead.

01:35:22.240 --> 01:35:25.380
Yeah, it's matching exactly to the 9.1.

01:35:25.940 --> 01:35:27.700
It's exactly, you said it's including it.

01:35:28.240 --> 01:35:30.400
So, if you're just checking less than,

01:35:30.980 --> 01:35:32.900
you're not including that 9.1,

01:35:32.900 --> 01:35:36.200
so it's only things that are less than that value.

01:35:36.900 --> 01:35:38.200
Sometimes you wanna make sure

01:35:38.200 --> 01:35:40.600
that that value is also included, right?

01:35:40.660 --> 01:35:42.920
So, you're doing less than or equal to,

01:35:43.340 --> 01:35:45.040
you're gonna include 9.1

01:35:45.040 --> 01:35:47.280
and all the values less than that.

01:35:47.500 --> 01:35:50.640
So, sometimes it's important that you include

01:35:51.320 --> 01:35:54.080
that boundary, whatever that boundary value is.

01:35:54.700 --> 01:35:59.120
For example, if I said everything less than six foot

01:35:59.640 --> 01:36:01.380
and everything greater than six foot,

01:36:01.620 --> 01:36:04.440
I would be missing anything that was six foot, right?

01:36:04.860 --> 01:36:07.160
So, by saying less than equals to,

01:36:07.160 --> 01:36:09.760
I can say everything that's less than or equal to six foot

01:36:10.400 --> 01:36:12.020
and then everything greater than six foot.

01:36:12.140 --> 01:36:14.520
And so, I'm not gonna miss that six foot value.

01:36:15.200 --> 01:36:16.880
Any questions at all, anything there

01:36:16.880 --> 01:36:19.940
before we take a look at using these operators

01:36:19.940 --> 01:36:20.980
in our variables?

01:36:22.000 --> 01:36:23.000
I have a question.

01:36:23.120 --> 01:36:26.740
When do we use objects, the variable?

01:36:27.540 --> 01:36:29.100
Oh, actually, I'll show you.

01:36:29.300 --> 01:36:32.520
In C Sharp, actually, everything really is an object

01:36:32.520 --> 01:36:35.260
and we're gonna start creating some of our own.

01:36:35.900 --> 01:36:39.000
I believe that's gonna be the first thing tomorrow.

01:36:40.620 --> 01:36:41.780
So, let me just check really quick.

01:36:41.840 --> 01:36:43.040
I think that's the first thing.

01:36:43.040 --> 01:36:45.080
Yeah, we're gonna do that fairly early tomorrow.

01:36:47.260 --> 01:36:49.600
So, yeah, C Sharp, actually,

01:36:50.160 --> 01:36:52.660
if you look at these other values we're working with,

01:36:53.520 --> 01:36:55.040
actually, everything is an object.

01:36:55.180 --> 01:36:56.740
So, integers, strings,

01:36:56.760 --> 01:36:59.700
those are all really objects underneath.

01:37:00.300 --> 01:37:02.960
But we'll actually look at working with objects

01:37:02.960 --> 01:37:04.120
and stuff first thing tomorrow.

01:37:06.000 --> 01:37:06.940
Hey, great question.

01:37:07.640 --> 01:37:11.580
All right, let's take a look at how do we use,

01:37:11.600 --> 01:37:13.700
now that we've got data that we can store

01:37:14.880 --> 01:37:17.940
and now that we've got ways that we can work with that,

01:37:18.120 --> 01:37:24.600
those variables, let's take a look at using those.

01:37:42.180 --> 01:37:44.260
Yeah, I think, Lillian, you're the one that said this earlier.

01:37:44.440 --> 01:37:45.440
As we're going through this,

01:37:45.520 --> 01:37:48.000
if you want to open the solve with me

01:37:48.000 --> 01:37:49.420
and add comments in there as you go,

01:37:49.440 --> 01:37:50.420
that's a great suggestion.

01:37:54.660 --> 01:37:55.880
Yep, doing it right now.

01:37:57.820 --> 01:37:59.000
Yeah, all the files in here,

01:37:59.000 --> 01:38:00.580
you'll be able to get those files

01:38:00.580 --> 01:38:03.860
at the end of training so that you can have those

01:38:03.860 --> 01:38:05.160
as references, right?

01:38:05.160 --> 01:38:05.240
So, yeah, I think that's a great suggestion.

01:38:06.360 --> 01:38:08.140
So, let's take a look.

01:38:09.700 --> 01:38:11.860
And I will zoom in on that real quick.

01:38:12.620 --> 01:38:14.800
So, the important thing is we've got data,

01:38:14.820 --> 01:38:15.980
we're able to store in variables,

01:38:16.260 --> 01:38:17.220
different types of data,

01:38:17.220 --> 01:38:20.240
and now we have operators that allow us to work with,

01:38:20.240 --> 01:38:24.860
do comparisons or do operations on that data,

01:38:25.000 --> 01:38:25.660
on those variables.

01:38:26.080 --> 01:38:28.780
And so, let's look at why that's gonna be useful for us.

01:38:29.840 --> 01:38:33.360
So, let me, why is it not going, here we go.

01:38:34.680 --> 01:38:38.420
So, here we've got a variable called water temp in Celsius

01:38:39.540 --> 01:38:40.840
that's of type double,

01:38:41.400 --> 01:38:43.280
and so we're gonna store value in there.

01:38:43.280 --> 01:38:46.580
We're gonna store this 37.5 value in there.

01:38:47.860 --> 01:38:50.520
And again, this is what all of your code is gonna do.

01:38:50.520 --> 01:38:52.500
You're gonna have data that you want to track

01:38:52.500 --> 01:38:54.680
that you're interested in keeping track of,

01:38:55.160 --> 01:38:57.020
and you're gonna want to do something with that.

01:38:57.040 --> 01:38:59.220
So, let's take a look at what we can do with that.

01:38:59.980 --> 01:39:02.680
One of the first things we can do is we can do

01:39:02.680 --> 01:39:04.180
what we call conditionals.

01:39:04.180 --> 01:39:07.240
We can decide whether certain code runs

01:39:07.880 --> 01:39:10.560
based on the value that we put in those variables.

01:39:11.280 --> 01:39:13.640
So, here I've got this water temp in Celsius,

01:39:14.520 --> 01:39:17.980
and I've got this value, 37.5 assigned to it,

01:39:18.660 --> 01:39:21.580
and I wanna, based on the value of that variable,

01:39:21.620 --> 01:39:22.540
I wanna do something.

01:39:22.660 --> 01:39:24.320
So, I'm gonna check and see

01:39:24.960 --> 01:39:29.640
if the value of that variable is greater than 37,

01:39:29.740 --> 01:39:30.860
I wanna do something.

01:39:31.680 --> 01:39:35.960
So, in C-sharp, we have the if statement, right?

01:39:35.960 --> 01:39:37.040
So, this if keyword,

01:39:38.460 --> 01:39:40.560
and then you can see I have parentheses here.

01:39:40.560 --> 01:39:42.040
So, there's the open parentheses,

01:39:43.280 --> 01:39:45.200
and then way over here on the right,

01:39:45.980 --> 01:39:47.280
there's a closed parentheses.

01:39:48.220 --> 01:39:50.720
And so, what I can do is I can have

01:39:50.720 --> 01:39:53.380
some kind of condition that I wanna check

01:39:53.380 --> 01:39:55.140
inside those parentheses.

01:39:56.100 --> 01:39:58.340
So, C-sharp is gonna take a look at that.

01:39:58.360 --> 01:40:00.140
It'll look at the value of that variable,

01:40:00.900 --> 01:40:03.560
it'll determine is that greater than 37?

01:40:04.440 --> 01:40:08.380
And if that's true, if that condition is true,

01:40:08.920 --> 01:40:10.940
then you're gonna see on my if statement,

01:40:11.140 --> 01:40:12.120
I've got curly braces.

01:40:12.420 --> 01:40:14.060
There's an opening curly brace,

01:40:14.980 --> 01:40:16.620
and then down here on line 14,

01:40:16.660 --> 01:40:18.160
there's a closed curly brace.

01:40:18.780 --> 01:40:22.660
And so, it will decide to run this code

01:40:23.420 --> 01:40:25.300
that I have inside those curly braces.

01:40:26.680 --> 01:40:29.980
So, this console right line, bath is ready,

01:40:31.080 --> 01:40:33.560
that code will only get run

01:40:34.820 --> 01:40:37.600
if this condition is true.

01:40:40.220 --> 01:40:43.020
So, what we're able to do is we're able to take

01:40:43.020 --> 01:40:47.360
and decide what code we're gonna have get executed or run

01:40:48.140 --> 01:40:50.520
based on the values that we have in our variables.

01:40:51.080 --> 01:40:52.840
And so, we're able to check that value

01:40:52.840 --> 01:40:53.880
using the if statement.

01:40:54.480 --> 01:40:57.740
So, the if statement has the if keyword,

01:40:58.700 --> 01:41:00.800
it has some kind of condition,

01:41:00.980 --> 01:41:03.280
and this condition is anything that's in these parentheses.

01:41:03.820 --> 01:41:06.360
So, that could be like really short or really long

01:41:06.360 --> 01:41:07.180
or really crazy,

01:41:07.900 --> 01:41:10.320
but whatever's in those is gonna be the condition

01:41:10.320 --> 01:41:10.980
that'll check.

01:41:11.420 --> 01:41:12.620
And then based on that,

01:41:14.520 --> 01:41:16.920
the if statement will have what we call the body

01:41:16.920 --> 01:41:17.860
of the if statement.

01:41:18.480 --> 01:41:22.420
Anything that's in the curly braces after the if

01:41:22.420 --> 01:41:24.360
is gonna be the body of this.

01:41:25.040 --> 01:41:29.380
And so, that code that's in the body of the if there

01:41:29.380 --> 01:41:31.840
on line 13 is only gonna get run

01:41:32.380 --> 01:41:34.160
if that condition is true.

01:41:36.140 --> 01:41:36.960
Why does that matter?

01:41:37.300 --> 01:41:39.740
Why would I want to run some code

01:41:39.740 --> 01:41:41.260
and not run other code

01:41:42.660 --> 01:41:44.540
based on the value of variables?

01:41:45.520 --> 01:41:46.960
Is there a value that I would get

01:41:46.960 --> 01:41:48.180
or a benefit I would get from that?

01:41:48.220 --> 01:41:51.540
Is it to help stop the whole program from being ran?

01:41:54.800 --> 01:41:55.700
Kind of.

01:41:55.920 --> 01:41:57.240
So, what you're really trying to do there

01:41:57.240 --> 01:41:58.440
is a lot of times,

01:41:59.300 --> 01:42:02.800
there's things that you wanna make decisions, right?

01:42:03.140 --> 01:42:04.900
So, for example, in this case,

01:42:05.900 --> 01:42:07.000
I might wanna know,

01:42:07.280 --> 01:42:09.700
hey, is this water ready?

01:42:09.820 --> 01:42:10.580
Is it warm enough?

01:42:10.800 --> 01:42:13.460
If it's not, then maybe I need to do something else.

01:42:13.500 --> 01:42:14.980
Maybe I need to keep heating it

01:42:14.980 --> 01:42:17.000
or there might be some alternative.

01:42:17.460 --> 01:42:19.840
So really, what we're doing with conditionals

01:42:19.840 --> 01:42:21.620
is we're making some kind of decision.

01:42:22.140 --> 01:42:24.400
So, we're getting the ability for our code

01:42:25.060 --> 01:42:26.700
to do different things

01:42:26.700 --> 01:42:29.160
depending upon the value of our variables.

01:42:31.300 --> 01:42:34.000
It almost seems like if you passed in that variable,

01:42:34.120 --> 01:42:35.640
it kind of would make more sense, so.

01:42:36.380 --> 01:42:38.760
Oh, to the fact that we're kind of just setting it?

01:42:39.120 --> 01:42:39.860
Yeah. Yeah.

01:42:39.920 --> 01:42:41.220
Yeah, that's true.

01:42:41.500 --> 01:42:42.940
So, pretend right here

01:42:42.940 --> 01:42:45.120
that this isn't just like we're just assigning it.

01:42:45.260 --> 01:42:47.780
Maybe that value is coming from like a thermometer

01:42:47.780 --> 01:42:49.240
or something like it's getting red.

01:42:51.140 --> 01:42:52.980
That's a great call out, thank you.

01:42:55.000 --> 01:42:56.940
But the key value we're getting with these,

01:42:57.140 --> 01:42:59.140
the conditionals, particularly the if statement,

01:42:59.420 --> 01:43:01.360
is that we're able to do different things.

01:43:01.580 --> 01:43:02.660
We're making decisions

01:43:03.140 --> 01:43:05.720
based on the value that we have for our variables.

01:43:07.020 --> 01:43:09.000
So sometimes, in this example,

01:43:09.100 --> 01:43:10.700
we're just doing a check that says,

01:43:10.900 --> 01:43:12.220
you know, there's one thing.

01:43:12.260 --> 01:43:13.620
We only wanna do this thing

01:43:13.620 --> 01:43:15.740
if a certain condition is met.

01:43:16.960 --> 01:43:19.640
Sometimes we wanna do a little bit more involved, right?

01:43:19.640 --> 01:43:21.160
So for this example,

01:43:21.520 --> 01:43:24.540
we're actually checking two conditions, right?

01:43:24.560 --> 01:43:26.020
So here, we're gonna say

01:43:26.020 --> 01:43:28.200
the water temperature has to be greater

01:43:28.200 --> 01:43:29.520
than a certain value,

01:43:30.360 --> 01:43:33.840
and it also has to be less than a certain value.

01:43:34.900 --> 01:43:38.140
And only if this entire block here,

01:43:38.200 --> 01:43:43.460
this entire if condition is true,

01:43:45.040 --> 01:43:47.460
will we run the code inside that if block, right?

01:43:47.460 --> 01:43:48.920
So again, keep in mind,

01:43:49.420 --> 01:43:52.040
you know, we saw on that first, on line 11 there,

01:43:52.040 --> 01:43:54.000
it can be a very short, simple condition,

01:43:54.660 --> 01:43:57.080
can be very long condition,

01:43:57.300 --> 01:44:00.520
but it's gonna evaluate everything that's in there

01:44:01.060 --> 01:44:03.820
to determine, ultimately, is it true or false,

01:44:05.180 --> 01:44:07.620
and that'll decide whether that code runs or not.

01:44:07.820 --> 01:44:09.360
Why would we do something like this

01:44:09.360 --> 01:44:11.360
where we're checking these two conditions

01:44:11.360 --> 01:44:12.880
versus just the one condition?

01:44:15.540 --> 01:44:19.860
One example for, that might be relevant for our stuff is,

01:44:20.060 --> 01:44:21.960
say we have a CNC instant quote,

01:44:22.260 --> 01:44:24.940
or part that went through a CNC instant analysis.

01:44:25.820 --> 01:44:27.880
We might check, is it a CNC quote,

01:44:28.140 --> 01:44:29.640
and then also did it successfully

01:44:29.640 --> 01:44:31.120
go through instant analysis.

01:44:33.940 --> 01:44:36.160
And that combination of one condition.

01:44:37.160 --> 01:44:38.600
Yeah, great example.

01:44:38.800 --> 01:44:41.100
So what Maria was saying there is a perfect example.

01:44:43.340 --> 01:44:44.800
Typically, we're gonna look

01:44:44.800 --> 01:44:46.640
at sort of multiple conditions, right?

01:44:46.640 --> 01:44:48.460
There has to be more than one thing

01:44:48.460 --> 01:44:49.560
to decide what we're doing.

01:44:50.240 --> 01:44:51.880
So, you know, the first thing might be,

01:44:52.160 --> 01:44:53.760
hey, is it not this certain type?

01:44:54.180 --> 01:44:57.300
If it's not, then my code isn't designed to handle that,

01:44:57.400 --> 01:44:58.560
right, so then I would have to give you

01:44:58.560 --> 01:44:59.460
some kind of message.

01:45:00.120 --> 01:45:01.620
Just because it is that type,

01:45:02.120 --> 01:45:04.020
I have to see, did it pass, right?

01:45:04.020 --> 01:45:05.420
So I have to check something else.

01:45:05.800 --> 01:45:07.460
So you're able with the if statements

01:45:07.460 --> 01:45:10.100
to check more than one thing

01:45:10.900 --> 01:45:14.520
and ultimately, everything that's between those parentheses

01:45:15.060 --> 01:45:17.000
will be what you're checking, right?

01:45:17.000 --> 01:45:19.600
So all of this information at the end of the day

01:45:19.600 --> 01:45:23.860
has to result in true in order for that code to get run.

01:45:26.520 --> 01:45:27.360
That was a great example.

01:45:28.560 --> 01:45:29.940
So let's take a look now.

01:45:31.140 --> 01:45:34.600
Sometimes we want, this is controlling what happens

01:45:34.600 --> 01:45:36.640
when that condition is met, when it's true.

01:45:36.640 --> 01:45:39.920
Sometimes we wanna do something when it's not true, right?

01:45:40.140 --> 01:45:42.020
So we wanna say, okay, for example,

01:45:42.820 --> 01:45:47.100
if the water temperature is greater than 99.9 degrees,

01:45:47.620 --> 01:45:50.300
then we're gonna say that the water is boiling, right?

01:45:51.600 --> 01:45:54.320
So if this condition is true on line 21,

01:45:55.100 --> 01:45:58.320
the code here on line 23 will get executed.

01:45:59.780 --> 01:46:02.240
If this condition is not true though,

01:46:02.860 --> 01:46:06.160
it'll actually go to this else keyword

01:46:06.640 --> 01:46:11.940
and this else keyword will match everything that's not true.

01:46:12.520 --> 01:46:15.920
And so if it is true, it does whatever is on line 23.

01:46:17.100 --> 01:46:19.160
If this condition is not true,

01:46:20.180 --> 01:46:23.020
then it'll do this code here on line 27.

01:46:23.480 --> 01:46:26.900
So sometimes it's important to check something

01:46:27.440 --> 01:46:29.580
and actually have two different outcomes.

01:46:30.440 --> 01:46:32.080
If it's true, I'll do one thing.

01:46:32.120 --> 01:46:34.120
If it's not true, I'll do something else.

01:46:35.640 --> 01:46:38.080
So the else keyword,

01:46:38.600 --> 01:46:41.620
you can see it doesn't have any condition, right?

01:46:42.440 --> 01:46:45.120
It's the result of it checks the if condition.

01:46:45.200 --> 01:46:48.740
And if this is not true, it won't run this code,

01:46:48.760 --> 01:46:50.000
but it will look and see,

01:46:50.100 --> 01:46:51.760
is there something else I should be doing?

01:46:51.940 --> 01:46:53.260
Any questions about that?

01:46:54.340 --> 01:46:56.700
So in the first example, a couple of examples here,

01:46:56.700 --> 01:46:58.440
we were showing, we didn't have an else.

01:46:58.440 --> 01:47:02.260
What happens here if this condition is not true

01:47:02.260 --> 01:47:03.460
on line 16?

01:47:03.460 --> 01:47:04.800
What's gonna happen?

01:47:06.320 --> 01:47:07.520
If this condition is true,

01:47:07.680 --> 01:47:09.720
it would run this code on line 18, right?

01:47:09.720 --> 01:47:12.080
But if this condition on line 16 is not true,

01:47:12.160 --> 01:47:14.260
what's gonna happen here, do you think?

01:47:14.940 --> 01:47:16.480
It goes to the next if statement.

01:47:17.380 --> 01:47:18.040
Yeah, absolutely.

01:47:18.140 --> 01:47:19.460
So it looks at this condition.

01:47:19.640 --> 01:47:20.660
If it's not true,

01:47:20.800 --> 01:47:23.860
it skips the body of that if statement, right?

01:47:24.180 --> 01:47:25.520
And it looks, says, what's next?

01:47:25.700 --> 01:47:26.760
What can I do next?

01:47:26.980 --> 01:47:28.580
And it goes down here to line 21.

01:47:29.880 --> 01:47:31.340
So sometimes that's what you want.

01:47:31.400 --> 01:47:32.800
Sometimes you wanna check something

01:47:32.800 --> 01:47:36.540
and you only wanted to do something if it's true.

01:47:37.220 --> 01:47:38.920
Sometimes you actually wanna be able to handle

01:47:38.920 --> 01:47:40.900
that situation and do something different.

01:47:41.220 --> 01:47:43.620
So the else is gonna allow us to do that.

01:47:43.640 --> 01:47:46.480
So here, it's gonna check this condition.

01:47:47.360 --> 01:47:49.820
If it's true, it'll do the code on line 23.

01:47:50.860 --> 01:47:52.480
And if it's not true, right?

01:47:52.480 --> 01:47:54.600
It'll skip the body of that if,

01:47:55.260 --> 01:47:56.820
and it'll say, oh wait, there's an else.

01:47:57.680 --> 01:47:58.780
Let me run that code.

01:48:01.940 --> 01:48:06.840
Right, so again, a very, very common scenario in your code

01:48:06.840 --> 01:48:09.160
is you're checking some condition

01:48:09.160 --> 01:48:11.100
and you're making a decision.

01:48:11.980 --> 01:48:14.220
If it's this, I'm gonna do one thing.

01:48:14.220 --> 01:48:16.300
If it's false, I'm gonna do something else.

01:48:16.300 --> 01:48:18.120
That's a very, very common pattern.

01:48:19.440 --> 01:48:21.780
And so if, and the else keyword

01:48:21.780 --> 01:48:23.460
allows you to handle that.

01:48:23.980 --> 01:48:24.800
Here's my check.

01:48:24.900 --> 01:48:26.660
I'll do this code if it's true, else.

01:48:27.180 --> 01:48:28.760
If it's not true, I'll do this other code.

01:48:28.760 --> 01:48:33.320
Okay, sometimes there may be multiple things

01:48:33.320 --> 01:48:34.200
that you wanna check.

01:48:35.140 --> 01:48:37.440
Unfortunately, let me get a move this here, let's see.

01:48:40.260 --> 01:48:41.980
We got zoom, there we go.

01:48:43.360 --> 01:48:44.380
Okay, nope, not enough.

01:48:45.920 --> 01:48:47.060
I gotta figure out the shortcut,

01:48:47.100 --> 01:48:48.860
whatever it is to hide the video menu,

01:48:48.940 --> 01:48:49.680
apparently now.

01:48:50.780 --> 01:48:52.720
Let's see, okay.

01:48:53.660 --> 01:48:56.860
So now I've got simple if else, right?

01:48:56.860 --> 01:48:59.080
So it does one thing or it does another.

01:49:00.160 --> 01:49:01.260
Let's take a look down.

01:49:01.400 --> 01:49:03.500
Maybe there's multiple things that I wanna check.

01:49:04.760 --> 01:49:06.300
So here I'm gonna check and see

01:49:06.300 --> 01:49:08.980
is the water less than 78 degrees?

01:49:09.660 --> 01:49:11.900
If that's true, then I'll display this message.

01:49:11.940 --> 01:49:13.120
That's too cold for swimming.

01:49:14.820 --> 01:49:19.440
If this is not true, it's gonna skip that function

01:49:19.440 --> 01:49:21.060
and it's gonna find this else.

01:49:22.080 --> 01:49:24.620
And my else, I'm actually gonna have another condition.

01:49:24.620 --> 01:49:29.120
So here it'll say, okay, it wasn't less than 78.

01:49:29.620 --> 01:49:31.320
Is it less than 82?

01:49:33.160 --> 01:49:37.680
If that's true, it would say just right for swimming.

01:49:38.300 --> 01:49:39.760
If this is not true,

01:49:39.920 --> 01:49:42.640
it's gonna skip that body of that function

01:49:43.220 --> 01:49:44.880
and it's gonna go do this else.

01:49:45.220 --> 01:49:47.160
There's no condition on that else, right?

01:49:47.160 --> 01:49:48.660
So it's just gonna match that

01:49:48.660 --> 01:49:50.640
and it'll say it's too warm for swimming.

01:49:50.740 --> 01:49:53.960
And so here, what we're doing is basically

01:49:54.520 --> 01:49:56.900
using two if-elses, right?

01:49:57.060 --> 01:49:59.440
So here's the if-else

01:49:59.440 --> 01:50:02.940
and then we get another if-else, right?

01:50:03.260 --> 01:50:06.900
So we're able to actually combine

01:50:06.900 --> 01:50:10.080
and have more than one if-else.

01:50:10.920 --> 01:50:12.820
Why would I wanna do that again?

01:50:13.040 --> 01:50:15.160
What would be the benefit that I'm getting

01:50:15.160 --> 01:50:17.500
from having sort of multiple if-elses?

01:50:20.000 --> 01:50:21.940
Do you want something to happen

01:50:21.940 --> 01:50:23.600
if none of those conditions are met?

01:50:24.100 --> 01:50:26.360
So that's, you check methodically

01:50:26.360 --> 01:50:28.320
for different conditions and then none of those are met,

01:50:28.480 --> 01:50:29.580
you've got kind of a default.

01:50:30.860 --> 01:50:32.700
Absolutely, that's what the else is doing for me.

01:50:32.840 --> 01:50:33.920
So with the nested if-else,

01:50:34.160 --> 01:50:36.060
sometimes, just like you said in the beginning of that,

01:50:36.080 --> 01:50:38.880
sometimes I wanna check multiple conditions.

01:50:39.420 --> 01:50:42.420
So I wanna say, if this is true,

01:50:42.440 --> 01:50:43.340
that I'll do something.

01:50:43.460 --> 01:50:45.240
But if this other condition is true,

01:50:45.260 --> 01:50:46.020
then I'll do something.

01:50:46.020 --> 01:50:48.440
And I can have as many of those as I want.

01:50:49.180 --> 01:50:51.780
And then my final else is gonna say,

01:50:51.820 --> 01:50:54.100
well, if it doesn't match any of this other stuff,

01:50:54.540 --> 01:50:57.480
then do this instead, right?

01:50:57.840 --> 01:50:58.220
Jane.

01:50:58.740 --> 01:50:59.040
Yes.

01:51:00.980 --> 01:51:03.380
So the 82.1 Celsius,

01:51:03.720 --> 01:51:04.900
if it's less than that,

01:51:04.980 --> 01:51:05.860
it's just right for me.

01:51:06.100 --> 01:51:09.180
But if it's below 78, it's too cold.

01:51:10.220 --> 01:51:12.600
So does that mean it's looking at the 78,

01:51:12.700 --> 01:51:15.000
it's comparing between the 82 and the 78?

01:51:15.800 --> 01:51:16.680
So how these work,

01:51:16.720 --> 01:51:17.760
that's a great question, by the way.

01:51:17.780 --> 01:51:21.560
How these work is the first condition that's true,

01:51:21.940 --> 01:51:23.060
it'll do, right?

01:51:23.300 --> 01:51:25.960
So here, let's assume that the water temperature

01:51:25.960 --> 01:51:27.560
is 79, right?

01:51:27.920 --> 01:51:31.960
It'll say, okay, is that less than 78?

01:51:32.240 --> 01:51:32.640
No.

01:51:33.300 --> 01:51:35.140
So it's not gonna do this.

01:51:35.160 --> 01:51:36.480
It'll ignore whatever's here.

01:51:37.420 --> 01:51:39.000
Then it'll come down to the next one

01:51:39.000 --> 01:51:40.840
and it'll say, okay, what about this condition?

01:51:41.800 --> 01:51:43.360
Is it less than 82?

01:51:44.020 --> 01:51:45.460
It is, right?

01:51:45.760 --> 01:51:47.880
So then I would get this block of code right here,

01:51:47.980 --> 01:51:49.940
this online 36, that would run for me.

01:51:50.420 --> 01:51:53.700
So it's gonna compare those conditions in order

01:51:54.200 --> 01:51:56.360
until it finds the first one that's true

01:51:57.040 --> 01:51:58.100
and it'll do that.

01:51:58.920 --> 01:52:00.100
And then if it doesn't,

01:52:00.200 --> 01:52:01.200
just like Lisa was saying,

01:52:01.240 --> 01:52:03.300
if it doesn't find any of these conditions

01:52:03.300 --> 01:52:04.000
that are true,

01:52:04.360 --> 01:52:07.040
else will basically match anything else.

01:52:07.100 --> 01:52:08.000
Is that what you're asking?

01:52:08.380 --> 01:52:10.560
I wanna make sure I answered the question you were asking.

01:52:11.920 --> 01:52:16.980
Well, I guess I was just because there's no difference

01:52:16.980 --> 01:52:19.520
between 78 and 82.

01:52:21.560 --> 01:52:25.280
I mean, the water temp could be below 82,

01:52:25.340 --> 01:52:26.840
but it's not giving the minimum.

01:52:28.280 --> 01:52:30.480
So the minimum is actually gonna get checked here.

01:52:31.100 --> 01:52:31.880
So the minimum is-

01:52:31.880 --> 01:52:32.920
That's what I was, yeah.

01:52:32.940 --> 01:52:34.900
So you didn't answer my question then, I guess.

01:52:34.920 --> 01:52:36.140
I just wanted to clarify.

01:52:36.300 --> 01:52:38.840
So it is comparing those two, right?

01:52:39.040 --> 01:52:39.420
Okay.

01:52:39.980 --> 01:52:41.360
Yeah, and to your point,

01:52:41.360 --> 01:52:42.740
it's gonna do those in order, right?

01:52:42.740 --> 01:52:44.880
So it's gonna start at the very first one

01:52:44.880 --> 01:52:46.120
and it checks that condition.

01:52:46.380 --> 01:52:48.520
And so that's what's setting the minimum, right?

01:52:48.520 --> 01:52:51.000
Line 30 is setting that minimum 78.

01:52:51.320 --> 01:52:53.660
And then if it's below that,

01:52:54.080 --> 01:52:55.500
then we're gonna say it's too cold.

01:52:56.320 --> 01:52:57.740
And then once it's checked that minimum,

01:52:57.840 --> 01:52:59.740
it's gonna say, okay, well, it's above the minimum.

01:53:00.540 --> 01:53:04.020
Now let me check, is it above the maximum, right?

01:53:04.020 --> 01:53:07.100
So if it's below that maximum,

01:53:07.260 --> 01:53:08.500
then we're saying it's just right.

01:53:09.380 --> 01:53:11.800
Otherwise, we're gonna say it's too warm.

01:53:13.120 --> 01:53:14.580
Yeah, great question.

01:53:16.340 --> 01:53:18.600
And that's really all we're doing with if statements,

01:53:18.700 --> 01:53:19.240
if else.

01:53:19.500 --> 01:53:23.680
We're basically gonna have some kind of condition, right?

01:53:23.740 --> 01:53:26.660
And again, that could be a very long, crazy condition.

01:53:27.300 --> 01:53:28.860
Anything that's between those parentheses.

01:53:29.100 --> 01:53:31.080
And whatever the result of that is,

01:53:31.580 --> 01:53:33.140
is gonna allow us to determine

01:53:33.140 --> 01:53:36.560
which code runs as a result.

01:53:36.560 --> 01:53:38.740
If it's true, we will run this code.

01:53:39.120 --> 01:53:41.060
If it's not true, we can check again,

01:53:41.200 --> 01:53:42.380
or we can run some different.

01:53:42.500 --> 01:53:44.660
Any questions on that before we try an activity with that?

01:53:44.740 --> 01:53:45.680
Let's take a look.

01:53:46.660 --> 01:53:48.440
So this is gonna be,

01:53:51.880 --> 01:53:53.760
it's gonna be in your activities,

01:53:54.000 --> 01:53:56.200
and we're gonna do conditionals.

01:53:59.460 --> 01:54:01.260
And if we look at our starter code.

01:54:03.640 --> 01:54:05.820
Oh, switch the preview on me.

01:54:05.820 --> 01:54:06.420
There we go.

01:54:07.520 --> 01:54:09.060
So what we're doing here is,

01:54:09.060 --> 01:54:11.120
we're gonna open that conditional solution.

01:54:11.700 --> 01:54:13.200
And then we wanna write a code

01:54:13.200 --> 01:54:15.920
that checks the value of status variable.

01:54:16.940 --> 01:54:18.620
And depending upon the value of this,

01:54:18.660 --> 01:54:20.200
we're gonna display different messages.

01:54:21.220 --> 01:54:23.680
So if that status is red,

01:54:23.820 --> 01:54:25.100
we're gonna display danger.

01:54:26.480 --> 01:54:28.740
If it's orange warning, yellow warning,

01:54:29.260 --> 01:54:31.240
green normal, blue normal,

01:54:31.240 --> 01:54:32.000
blue info.

01:54:32.500 --> 01:54:34.160
And then if the value of the status

01:54:34.160 --> 01:54:35.880
doesn't match any of these,

01:54:37.160 --> 01:54:39.060
then we're actually gonna display this message,

01:54:39.200 --> 01:54:40.220
unknown status.

01:54:40.280 --> 01:54:42.600
So what we'll have you do there is write the code

01:54:42.600 --> 01:54:44.060
that will determine that.

01:54:44.500 --> 01:54:45.960
And then we're gonna have you try

01:54:45.960 --> 01:54:48.500
assigning different values to that status variable

01:54:48.500 --> 01:54:50.860
and make sure that that correct message gets displayed.

01:54:52.600 --> 01:54:54.300
And if we take a look at the code,

01:54:54.540 --> 01:54:56.040
let me hop over there really quickly.

01:55:07.260 --> 01:55:08.260
That's not too bad.

01:55:08.400 --> 01:55:09.580
Once I figure out the lag,

01:55:09.600 --> 01:55:11.460
I can kind of adjust for it.

01:55:12.080 --> 01:55:14.460
That's before I was like over clicking everything,

01:55:14.480 --> 01:55:15.280
I think.

01:55:18.580 --> 01:55:20.480
So if you take a look at this conditional solution,

01:55:20.520 --> 01:55:23.380
this is the starter code that you'll have there.

01:55:28.220 --> 01:55:30.220
All right, so as that opens up for us.

01:55:30.820 --> 01:55:31.220
So let's go ahead and do that.

01:55:36.280 --> 01:55:36.720
All right.

01:55:36.720 --> 01:55:37.980
So here's what you'll have.

01:55:38.300 --> 01:55:41.520
We basically are setting that variable already status.

01:55:42.860 --> 01:55:45.340
We're making a string and we're giving it a value.

01:55:45.860 --> 01:55:46.700
And then we're gonna have you

01:55:46.700 --> 01:55:48.420
write some tests in here, right?

01:55:48.700 --> 01:55:49.620
So we'll be writing,

01:55:50.100 --> 01:55:52.060
well not, you shouldn't use the word test.

01:55:52.260 --> 01:55:53.340
We'll write some conditionals.

01:55:53.420 --> 01:55:54.840
We're gonna learn to write tests later.

01:55:55.520 --> 01:55:57.000
But we're gonna write some checks in here

01:55:57.000 --> 01:55:58.240
with if statements.

01:55:58.240 --> 01:56:01.980
And we're gonna compare the value of this status variable

01:56:01.980 --> 01:56:05.640
and decide different messages to display based on it.

01:56:05.760 --> 01:56:06.120
Fantastic.

01:56:06.380 --> 01:56:09.080
Let's take, again, we'll try about 10 on this one

01:56:09.080 --> 01:56:10.260
and we'll see where we come out.

01:56:10.280 --> 01:56:12.540
So we'll go from now for about 10 minutes.

01:56:13.780 --> 01:56:16.040
And then we'll take a look at the code.

01:56:17.560 --> 01:56:18.020
Yes.

01:56:28.240 --> 01:56:30.260
Is that what I thought you'd do?

01:56:30.820 --> 01:56:34.420
No, so I included Visual Studio code

01:56:34.420 --> 01:56:35.580
because I thought it might be easier

01:56:35.580 --> 01:56:38.000
to see sort of the folders and the whatever.

01:56:38.700 --> 01:56:41.280
But I'm actually opening it in Visual Studio.

01:56:41.340 --> 01:56:43.280
So I actually go here to the folder

01:56:44.220 --> 01:56:46.680
and I'm double clicking it here in that folder.

01:56:46.740 --> 01:56:47.640
Are you able to see my screen?

01:56:47.760 --> 01:56:48.720
I feel like I'm not sharing.

01:56:50.360 --> 01:56:52.040
I just realized I'm not sharing.

01:56:53.780 --> 01:56:55.060
Pretend I was sharing my screen.

01:56:56.340 --> 01:56:56.820
Gotcha.

01:56:56.820 --> 01:56:59.540
Yeah, so I'm just opening it from the folder right here.

01:57:01.640 --> 01:57:04.240
You actually can open these from Visual Studio code,

01:57:04.900 --> 01:57:08.540
but it's a little bit trickier to run them that way

01:57:08.540 --> 01:57:10.000
so I don't wanna go that route.

01:57:10.520 --> 01:57:11.920
I think that's what I'm running into.

01:57:12.200 --> 01:57:16.700
I did an open file and I started updating it.

01:57:16.760 --> 01:57:18.080
But when I run the program,

01:57:18.160 --> 01:57:19.660
it runs the previous program.

01:57:20.840 --> 01:57:23.560
Yeah, I think if you just open it from the Explorer,

01:57:23.680 --> 01:57:24.680
just double click there

01:57:24.680 --> 01:57:27.000
and then run it that way, it should work for you.

01:57:27.920 --> 01:57:28.320
Okay, thanks.

01:57:28.740 --> 01:57:29.340
No, great question.

01:57:29.620 --> 01:57:30.300
Was there a chat?

01:57:30.480 --> 01:57:32.460
I see I missed a couple of questions in chat.

01:57:34.160 --> 01:57:36.560
No, I was just saying the dark mode

01:57:36.560 --> 01:57:38.880
was kind of hard for me to find the cursor

01:57:38.880 --> 01:57:40.200
so I just switched it into light mode

01:57:40.200 --> 01:57:42.220
and put that in the chat for other folks.

01:57:42.520 --> 01:57:43.460
That would be helpful for them.

01:57:43.680 --> 01:57:44.780
Oh, perfect, yeah.

01:57:45.060 --> 01:57:45.740
It's so funny.

01:57:47.020 --> 01:57:48.580
I get mixed feedback either way.

01:57:48.640 --> 01:57:50.560
If I do it light mode, people complain.

01:57:50.620 --> 01:57:52.300
If you do it dark mode, people complain.

01:57:54.320 --> 01:57:57.820
Yeah, my setup is a little weird here

01:57:57.820 --> 01:57:59.460
because it's kind of bright

01:57:59.460 --> 01:58:01.780
and the cursor was just not sticking out for me.

01:58:02.000 --> 01:58:04.140
I don't know if that is for anybody else.

01:58:04.400 --> 01:58:05.180
No, that's super helpful.

01:58:05.280 --> 01:58:06.460
Well, thank you for that.

01:58:08.000 --> 01:58:09.820
Yeah, the chat too, just FYI.

01:58:10.580 --> 01:58:11.840
I have the toolbar hidden

01:58:11.840 --> 01:58:13.620
because it keeps getting in the way.

01:58:13.940 --> 01:58:15.680
So if you do put something in the chat,

01:58:15.720 --> 01:58:16.840
I'm not gonna see it right away.

01:58:16.880 --> 01:58:17.700
Just FYI.

01:58:49.480 --> 01:58:52.280
All right.

01:59:15.880 --> 01:59:17.280
Okay.

01:59:24.040 --> 01:59:25.440
Okay.

01:59:58.360 --> 02:00:01.520
Okay, a couple more minutes and we'll take a look.

02:00:04.160 --> 02:00:05.900
Obviously, if you have any blockers or questions

02:00:05.900 --> 02:00:08.020
as we go, feel free to ask those.

02:00:22.880 --> 02:00:24.500
Let me share my screen.

02:00:24.660 --> 02:00:26.180
We'll take a look here.

02:00:26.980 --> 02:00:29.160
All right, so we have this status variable.

02:00:29.420 --> 02:00:30.780
Let me zoom in on that.

02:00:33.820 --> 02:00:40.540
We have this, why is zoom not like that?

02:00:40.540 --> 02:00:41.900
What's going on with that?

02:00:50.220 --> 02:00:51.780
Okay, there we go.

02:00:52.520 --> 02:00:54.060
We have the status variable.

02:00:54.420 --> 02:00:55.880
We've signed this value red to it.

02:00:55.900 --> 02:00:59.600
So we need to write some code in here to check

02:01:00.660 --> 02:01:01.500
those values.

02:01:01.960 --> 02:01:03.920
So anytime we wanna check the value of something,

02:01:03.940 --> 02:01:06.300
we're gonna use an if statement to do that.

02:01:07.240 --> 02:01:08.380
Is everyone able to see my screen?

02:01:08.600 --> 02:01:10.380
Is it good size?

02:01:10.500 --> 02:01:11.200
Okay, perfect.

02:01:11.900 --> 02:01:15.420
So if will be the keyword we're gonna use for that.

02:01:16.540 --> 02:01:18.240
And then I don't know if you notice as I'm typing,

02:01:18.400 --> 02:01:19.820
but Visual Studio is doing the same thing

02:01:19.820 --> 02:01:20.560
for you as well.

02:01:20.560 --> 02:01:23.720
It's giving you lots of prompts on different suggestions.

02:01:24.480 --> 02:01:26.840
Some of these are gonna be a little not

02:01:26.840 --> 02:01:28.020
what you're looking for, right?

02:01:28.480 --> 02:01:30.400
But it's actually smart enough,

02:01:30.480 --> 02:01:31.700
the more code you write,

02:01:31.840 --> 02:01:33.720
especially if it's in the same project,

02:01:34.300 --> 02:01:36.920
it'll actually learn from your coding

02:01:37.440 --> 02:01:39.460
as well as learning from other examples.

02:01:40.100 --> 02:01:41.940
And so some of the prompts will get better

02:01:41.940 --> 02:01:44.120
and better actually over time as you use it.

02:01:45.760 --> 02:01:47.660
Here, we're gonna wanna check the status.

02:01:47.820 --> 02:01:49.480
So if I start typing status,

02:01:50.060 --> 02:01:52.640
I'm gonna get the option there for the status variable.

02:01:54.200 --> 02:01:58.680
And then I wanna check to see if that's equal to red,

02:01:59.040 --> 02:02:00.140
then we're gonna do something.

02:02:01.820 --> 02:02:04.040
So that's gonna be my whole condition status,

02:02:04.080 --> 02:02:05.760
and I'll check that if that equals red.

02:02:06.880 --> 02:02:09.880
And then I'm gonna have to have some curly braces.

02:02:12.100 --> 02:02:14.440
You'll notice in Visual Studio,

02:02:15.400 --> 02:02:16.660
some of the languages you work in

02:02:16.660 --> 02:02:18.420
will be a little bit more specific

02:02:18.420 --> 02:02:20.020
or picky about the white space.

02:02:20.420 --> 02:02:22.000
Visual Studio, I could actually do this

02:02:22.000 --> 02:02:23.140
on this line right here.

02:02:23.160 --> 02:02:26.060
I could do my check and do my code right in here.

02:02:26.880 --> 02:02:31.620
It's really all about where's the semicolon at

02:02:31.620 --> 02:02:32.840
and where are the curly braces.

02:02:33.540 --> 02:02:36.000
It doesn't really care about the white space at all.

02:02:36.700 --> 02:02:38.840
So I could do my console write line

02:02:38.840 --> 02:02:42.140
and then do something like danger

02:02:43.360 --> 02:02:44.820
right here in the line,

02:02:45.420 --> 02:02:47.220
and then I'll put my semicolon in there.

02:02:47.220 --> 02:02:49.960
And that'll actually work just fine.

02:02:51.380 --> 02:02:52.980
Some languages you'll see,

02:02:53.040 --> 02:02:54.480
like if you're familiar with JavaScript,

02:02:54.700 --> 02:02:56.360
they'll tend to do something like this.

02:02:56.380 --> 02:02:59.900
They'll put the curly braces on the following line.

02:03:02.000 --> 02:03:04.620
That'll work just fine in C Sharp, it doesn't care.

02:03:06.140 --> 02:03:10.080
C Sharp, typically though you'll see like this

02:03:10.080 --> 02:03:13.140
with curly brace, then whatever code you're gonna do

02:03:13.980 --> 02:03:15.080
and then the curly brace.

02:03:15.080 --> 02:03:17.300
I'm just letting you know in terms of

02:03:17.300 --> 02:03:19.840
the C Sharp language itself, it really doesn't care.

02:03:19.980 --> 02:03:21.180
As long as the code works,

02:03:21.940 --> 02:03:23.980
it's not really concerned about the white space.

02:03:24.180 --> 02:03:25.260
So just FYI.

02:03:26.500 --> 02:03:30.480
So I'm checking to see if the status there is red,

02:03:30.940 --> 02:03:32.380
then we're gonna go ahead and run

02:03:32.380 --> 02:03:33.780
any code that's in there.

02:03:35.640 --> 02:03:37.600
Can I have more than one line of code

02:03:37.600 --> 02:03:38.920
inside that if block?

02:03:40.500 --> 02:03:41.200
Yeah, absolutely.

02:03:41.560 --> 02:03:43.420
I could have multiple console writes.

02:03:43.460 --> 02:03:44.940
I could be doing lots of other things.

02:03:44.940 --> 02:03:48.660
So this code block here for the if statement

02:03:49.220 --> 02:03:50.840
can be as large as it needs to be.

02:03:51.360 --> 02:03:53.620
You can have multiple lines in there easily.

02:03:54.400 --> 02:03:56.060
So in these simple examples we're showing,

02:03:56.180 --> 02:03:57.680
we're just trying to kind of call out

02:03:58.720 --> 02:04:01.820
how things work at the simplest level we can

02:04:01.820 --> 02:04:04.700
and then you'll see in later examples

02:04:04.700 --> 02:04:06.980
there can be a lot more stuff going on inside here.

02:04:08.040 --> 02:04:10.360
Oh, to Maria's point too,

02:04:10.840 --> 02:04:13.460
if you don't like the theme of this,

02:04:13.460 --> 02:04:15.620
if it's difficult to read, et cetera,

02:04:16.540 --> 02:04:18.780
if you go to the tools menu in Visual Studio,

02:04:19.720 --> 02:04:22.640
you click tools and then click theme.

02:04:23.680 --> 02:04:24.820
You're gonna see there's actually

02:04:24.820 --> 02:04:26.460
a couple of themes that are here.

02:04:26.780 --> 02:04:28.900
This is the one that we're using right now.

02:04:29.260 --> 02:04:31.780
You can completely change the look of this.

02:04:32.020 --> 02:04:33.660
So if I hit blue, for example,

02:04:35.560 --> 02:04:39.760
it'll change the look of the entire application, right?

02:04:40.560 --> 02:04:43.260
So now I've got blue borders and things,

02:04:43.260 --> 02:04:45.120
my comments are in green.

02:04:46.280 --> 02:04:49.460
So just FYI, if you're gonna be spending a ton of time

02:04:49.460 --> 02:04:51.920
using this tool, which you likely are,

02:04:52.900 --> 02:04:55.480
find this setup that works the best for you, right?

02:04:56.020 --> 02:04:58.180
And that's one of the advantages of using tools

02:04:58.180 --> 02:05:01.400
like Visual Studio is that the tools are really there

02:05:01.400 --> 02:05:03.740
to help you facilitate what you're doing.

02:05:05.060 --> 02:05:07.560
So yeah, make that environment comfortable,

02:05:08.900 --> 02:05:11.840
take advantage of all the things that it offers you.

02:05:13.880 --> 02:05:15.740
So I'm gonna switch it back,

02:05:16.980 --> 02:05:18.400
but be aware that you can do that.

02:05:18.540 --> 02:05:20.840
You can do something similar in Visual Studio Code

02:05:20.840 --> 02:05:22.980
if you want to, I can show you about that later,

02:05:23.000 --> 02:05:24.900
but just be aware that's an option.

02:05:26.120 --> 02:05:29.000
And then I'm basically gonna do just a set of these,

02:05:29.140 --> 02:05:30.540
right, so I need to do a bunch of checks.

02:05:31.200 --> 02:05:32.780
So I need to check if it's red,

02:05:34.980 --> 02:05:38.300
if it's, what was it, danger was the other one.

02:05:46.340 --> 02:05:49.000
Oh, actually, it's checking a certain status, right?

02:05:49.000 --> 02:05:52.560
It's checking if it's orange, it's gonna be warning.

02:06:03.660 --> 02:06:06.060
Now I could do these all as individual statements,

02:06:06.340 --> 02:06:07.940
like if, if, if, but I'll show you

02:06:07.940 --> 02:06:10.200
there's a better way to do that, right?

02:06:10.200 --> 02:06:12.400
Let's take a look at the solved version of this.

02:06:18.420 --> 02:06:20.620
So here in the next Windows Explorer,

02:06:20.640 --> 02:06:24.440
I'm gonna go to the conditionals activity,

02:06:25.280 --> 02:06:27.200
and then I'll go to the solved version.

02:06:39.180 --> 02:06:41.560
Give that a second to open up there, okay.

02:06:42.720 --> 02:06:43.240
So I'm gonna go to the solved version,

02:06:43.240 --> 02:06:44.480
and I'm gonna go to the solved version, okay.

02:06:47.900 --> 02:06:50.460
All right, now if I take a look at the solved version,

02:06:52.560 --> 02:06:54.640
we'll see we're checking that status is red,

02:06:54.920 --> 02:06:56.660
we'll console write line that message,

02:06:57.060 --> 02:06:59.120
whoop, why does it do that every time, there we go.

02:06:59.680 --> 02:07:02.680
Write that message, and then we're gonna do an if,

02:07:03.400 --> 02:07:04.680
else if here on line 15,

02:07:04.780 --> 02:07:07.000
so else, we'll check a different status.

02:07:07.840 --> 02:07:10.040
If that's true, we're gonna write warning.

02:07:10.660 --> 02:07:12.420
If that's not true, we're just gonna keep

02:07:12.420 --> 02:07:15.260
checking these different conditions

02:07:15.260 --> 02:07:16.540
as we go down through here.

02:07:16.860 --> 02:07:18.540
So to your viewpoint earlier,

02:07:19.360 --> 02:07:22.200
it's gonna look at each of those conditions in order,

02:07:22.700 --> 02:07:24.740
and the first one that it finds that matches

02:07:25.520 --> 02:07:26.440
will get executed.

02:07:26.540 --> 02:07:28.100
And then if none of these match,

02:07:28.860 --> 02:07:30.380
it'll always match this else.

02:07:30.440 --> 02:07:31.880
So it'll find this else,

02:07:32.320 --> 02:07:35.540
and then it'll run that message there.

02:07:37.080 --> 02:07:38.680
Any questions at all on this?

02:07:38.800 --> 02:07:40.560
Did anyone run into any issues

02:07:40.560 --> 02:07:42.520
when they were writing code for that?

02:07:45.000 --> 02:07:47.360
Okay, what do you notice on here?

02:07:47.520 --> 02:07:49.160
There's something interesting about this.

02:07:49.600 --> 02:07:53.780
Couple of these actually have the same message, right?

02:07:54.440 --> 02:07:57.800
So orange and yellow are both outputting the same message.

02:07:59.120 --> 02:08:01.020
So that's one thing that's a little strange.

02:08:01.080 --> 02:08:04.700
So I've got this set of conditions that I'm checking.

02:08:06.200 --> 02:08:08.500
The other thing is that once,

02:08:09.240 --> 02:08:12.220
with the if else, if I'm just checking sort of one if else,

02:08:12.440 --> 02:08:15.180
one condition, it's a little bit simpler.

02:08:15.420 --> 02:08:17.200
When I start doing multiples like this,

02:08:17.200 --> 02:08:18.800
it kind of gets a little out of hand.

02:08:20.560 --> 02:08:23.520
So let's take a look at another thing

02:08:23.520 --> 02:08:24.920
that C-Sharp provides us,

02:08:25.180 --> 02:08:28.340
that when we're checking multiple conditions like that,

02:08:29.840 --> 02:08:31.340
there's another way we can do that

02:08:31.340 --> 02:08:33.120
that might be a little bit more straightforward.

02:08:35.260 --> 02:08:38.460
So let's talk about using switches.

02:08:44.180 --> 02:08:46.960
So the value you're getting with the conditionals

02:08:46.960 --> 02:08:50.660
is that you're able to only run code

02:08:50.660 --> 02:08:52.220
based on a certain condition.

02:08:53.060 --> 02:08:54.900
And the advantage you're getting from that really

02:08:54.900 --> 02:08:57.520
is that it allows you to respond differently.

02:08:57.760 --> 02:08:59.160
Your code can respond differently

02:08:59.160 --> 02:09:01.600
to different types of data, right?

02:09:01.600 --> 02:09:03.460
So that's the advantage that you're getting

02:09:03.460 --> 02:09:06.040
by being able to check conditions

02:09:06.040 --> 02:09:08.620
and then run different code based on those.

02:09:10.880 --> 02:09:13.060
Very, very often, you're gonna be checking

02:09:13.060 --> 02:09:14.460
sort of a single check.

02:09:14.500 --> 02:09:16.380
Does it meet this or does it not, right?

02:09:16.380 --> 02:09:17.180
Sort of an if else.

02:09:17.900 --> 02:09:20.260
But when you are checking multiple conditions,

02:09:20.640 --> 02:09:23.540
C-Sharp also has another keyword

02:09:24.460 --> 02:09:26.200
that we'll take a look at.

02:09:26.760 --> 02:09:28.140
Let me zoom in there.

02:09:31.740 --> 02:09:34.380
So C-Sharp obviously has if-else.

02:09:37.180 --> 02:09:39.780
And so we could check all those conditions,

02:09:39.920 --> 02:09:42.060
red, orange, yellow, et cetera.

02:09:43.020 --> 02:09:44.580
But anytime we're doing this,

02:09:44.840 --> 02:09:46.980
only one of these conditions is gonna be true.

02:09:47.740 --> 02:09:50.120
So it's only gonna run one of these lines of code

02:09:50.120 --> 02:09:52.560
and then it will skip the rest of the lines, right?

02:09:52.980 --> 02:09:54.320
So in that scenario,

02:09:54.420 --> 02:09:58.120
there's actually a more straightforward way in C-Sharp.

02:09:58.120 --> 02:10:01.280
To do this, and let's take a look at what that is.

02:10:07.300 --> 02:10:11.900
So C-Sharp also has the switch keyword.

02:10:13.260 --> 02:10:15.360
And what the switch operator will do,

02:10:15.840 --> 02:10:18.680
it's gonna check the value one time.

02:10:19.000 --> 02:10:21.400
So it's gonna take a look right here at the status.

02:10:21.740 --> 02:10:23.260
So just like with our if, right?

02:10:23.260 --> 02:10:24.720
With our if, we had that condition

02:10:24.720 --> 02:10:25.620
that we were gonna check.

02:10:26.420 --> 02:10:29.520
Here, switch is gonna do something similar,

02:10:29.560 --> 02:10:31.340
only what switch is gonna do right here

02:10:31.340 --> 02:10:32.660
is check the value.

02:10:33.180 --> 02:10:35.440
What is the value of that variable?

02:10:36.200 --> 02:10:39.700
And then switch will allow us to have a series of cases

02:10:40.720 --> 02:10:42.340
that match that value.

02:10:42.580 --> 02:10:46.260
So it'll determine there on line 42, what is the value?

02:10:46.680 --> 02:10:48.860
And then it starts looking through the cases

02:10:49.500 --> 02:10:53.740
and it finds the first case that matches that value.

02:10:54.840 --> 02:10:58.020
So if that value of the status variable is red,

02:10:58.600 --> 02:11:01.620
here on line 44, it would say, oh, that matches this case.

02:11:02.640 --> 02:11:04.800
And then you'll see after the case,

02:11:05.000 --> 02:11:07.200
so the case is gonna have the case keyword,

02:11:07.740 --> 02:11:09.120
the value that it matches,

02:11:09.200 --> 02:11:12.040
and then it has a colon at the end of that line.

02:11:13.980 --> 02:11:15.840
And then just like with the if statement,

02:11:15.900 --> 02:11:17.580
there's gonna be a block of code

02:11:17.580 --> 02:11:18.980
that will run if that's true.

02:11:19.480 --> 02:11:22.100
So in this case, that would be here on line 45,

02:11:22.100 --> 02:11:23.840
it will run that block of code,

02:11:24.060 --> 02:11:25.300
that line of code I should say.

02:11:26.260 --> 02:11:30.660
And then a case is gonna have a break statement

02:11:31.260 --> 02:11:35.080
that says, okay, I'm done, now move on.

02:11:36.780 --> 02:11:39.140
So switch, you're gonna see switch keyword.

02:11:40.100 --> 02:11:42.060
It'll have the value of this variable

02:11:42.060 --> 02:11:42.920
that's gonna check.

02:11:44.120 --> 02:11:45.260
Then it'll have a body,

02:11:45.380 --> 02:11:46.960
so this switch statement has a body here

02:11:46.960 --> 02:11:51.060
from line 43 all the way down to line 64.

02:11:52.100 --> 02:11:53.920
And the body of a switch statement

02:11:53.920 --> 02:11:56.380
is gonna just be a series of cases

02:11:56.980 --> 02:11:58.740
that it's gonna try to match.

02:12:01.900 --> 02:12:03.260
Any questions on that first part?

02:12:03.500 --> 02:12:06.440
So switch statement, it's gonna look at the value,

02:12:07.380 --> 02:12:11.500
whatever value you provide here in the parentheses,

02:12:12.300 --> 02:12:14.680
and then it'll try to match that value

02:12:15.300 --> 02:12:16.840
to one of the cases.

02:12:16.880 --> 02:12:18.360
It'll try to find the first case

02:12:18.360 --> 02:12:19.660
that matches that value.

02:12:21.120 --> 02:12:22.640
Any questions on that part?

02:12:22.960 --> 02:12:24.900
Okay, so just like with the if else,

02:12:25.140 --> 02:12:27.660
if it doesn't match any of these cases,

02:12:28.600 --> 02:12:30.640
there's actually a default case.

02:12:31.000 --> 02:12:34.380
So here on line 61, default is sort of like the else.

02:12:35.540 --> 02:12:38.360
And this will match, if none of the other cases match,

02:12:38.380 --> 02:12:39.680
it'll match this case.

02:12:41.640 --> 02:12:43.440
So it finds a case that matches,

02:12:43.560 --> 02:12:44.520
it runs that code,

02:12:44.540 --> 02:12:46.520
and then as soon as it hits the break statement,

02:12:47.240 --> 02:12:48.640
it exits out of the switch.

02:12:51.100 --> 02:12:53.980
So the difference here that you're getting is

02:12:53.980 --> 02:12:56.380
because really with those nested if else's,

02:12:56.380 --> 02:12:58.460
you're checking multiple conditions

02:12:58.460 --> 02:13:00.200
against the same value.

02:13:00.700 --> 02:13:01.940
Sometimes the switch statement

02:13:01.940 --> 02:13:03.580
is a little bit more straightforward

02:13:03.580 --> 02:13:05.680
that this is what I'm doing.

02:13:05.800 --> 02:13:09.320
I'm looking at this value and based on this,

02:13:09.700 --> 02:13:10.840
I'm gonna do something.

02:13:11.080 --> 02:13:12.900
And I'm just gonna look at the case statements.

02:13:12.920 --> 02:13:16.160
So it can be a little bit cleaner in terms of code.

02:13:16.620 --> 02:13:17.820
The other thing is here,

02:13:17.820 --> 02:13:20.140
if you look at line 48 and 49,

02:13:21.060 --> 02:13:25.280
if I have more than one case that does the same thing,

02:13:25.600 --> 02:13:26.560
so in this example,

02:13:26.580 --> 02:13:29.320
orange and yellow are both printing out the same message,

02:13:29.980 --> 02:13:32.260
I could have multiple case statements

02:13:33.460 --> 02:13:37.000
that match the same block of code that will be run.

02:13:39.300 --> 02:13:41.980
So I'm just gonna stack those case statements.

02:13:42.240 --> 02:13:45.420
So case orange colon, case yellow colon,

02:13:45.980 --> 02:13:48.160
if it matches either one of those cases,

02:13:48.360 --> 02:13:51.900
it's gonna run that same block of code on line 50 there.

02:13:54.960 --> 02:13:56.300
I don't think there's something similar

02:13:56.300 --> 02:13:57.820
to the switch in Python, right?

02:13:58.080 --> 02:13:59.620
Is this new for everyone?

02:14:01.140 --> 02:14:02.580
I've definitely used it before.

02:14:02.620 --> 02:14:04.420
I don't know if it was Python or someone else.

02:14:05.040 --> 02:14:06.760
Yeah, other languages support it.

02:14:06.880 --> 02:14:09.020
I don't remember if Python does or not.

02:14:09.920 --> 02:14:12.740
So again, you're perfectly welcome

02:14:12.740 --> 02:14:13.860
to use the Bell statements.

02:14:13.860 --> 02:14:16.340
Sometimes though, when you have that sort of nested,

02:14:16.580 --> 02:14:18.220
if else, if else, if else,

02:14:18.700 --> 02:14:20.940
a switch statement can be a little bit more obvious

02:14:20.940 --> 02:14:22.320
about what you're trying to do.

02:14:24.420 --> 02:14:26.180
And it's a little bit more clear

02:14:26.180 --> 02:14:27.500
than what your intention is, right?

02:14:27.580 --> 02:14:30.140
So switch is saying, look at the value of this

02:14:30.140 --> 02:14:32.380
and then match it and do something.

02:14:34.340 --> 02:14:35.460
So it's another alternative

02:14:35.460 --> 02:14:37.360
that you'll have in your tool.

02:14:37.420 --> 02:14:38.460
Let's try this out.

02:14:38.740 --> 02:14:40.740
We're gonna try writing some if statements,

02:14:41.020 --> 02:14:41.760
the nested if statements,

02:14:41.760 --> 02:14:44.840
and then we'll write the switch version of that

02:14:44.840 --> 02:14:47.280
and kind of give you a way

02:14:47.280 --> 02:14:49.480
to highlight the differences between those.

02:14:49.740 --> 02:14:51.200
So if you take a look

02:14:53.820 --> 02:14:57.040
here in our switches activity.

02:15:05.220 --> 02:15:06.840
So we're gonna have you take a look

02:15:06.840 --> 02:15:09.280
at the switches solution from the starter folder.

02:15:09.960 --> 02:15:11.880
We're gonna try, we're gonna do the same thing.

02:15:11.980 --> 02:15:13.040
We'll just do it two different ways.

02:15:13.400 --> 02:15:15.320
So what we wanna do is we wanna determine

02:15:15.320 --> 02:15:16.940
and display the day of the week.

02:15:17.820 --> 02:15:19.060
And we'll do that two ways.

02:15:19.120 --> 02:15:19.860
We'll do it first

02:15:19.860 --> 02:15:21.940
by writing some nested if else statements.

02:15:22.720 --> 02:15:24.220
So we'll take a look at the value

02:15:24.220 --> 02:15:25.660
of the day number variable.

02:15:26.140 --> 02:15:28.220
And then we're gonna write out a message that says,

02:15:28.240 --> 02:15:31.240
oh, day one is Sunday, day two is Monday,

02:15:31.400 --> 02:15:32.140
that type of thing.

02:15:33.200 --> 02:15:35.400
Then we'll take that same logic

02:15:35.400 --> 02:15:37.020
and we'll do that as a switch statement.

02:15:37.320 --> 02:15:38.400
So you can kind of compare

02:15:38.400 --> 02:15:39.720
the difference between the two.

02:15:41.040 --> 02:15:42.720
So let's take a look at what we're getting

02:15:42.720 --> 02:15:44.660
for starter code there.

02:15:49.020 --> 02:15:51.000
So you're gonna see that our first starter code,

02:15:51.720 --> 02:15:53.540
we're gonna get that value will be declared

02:15:53.540 --> 02:15:55.060
for us, that variable day number.

02:15:56.440 --> 02:15:58.920
And then we're gonna do it first with if else statements.

02:15:58.980 --> 02:16:00.560
So we're gonna have to write some if else.

02:16:00.900 --> 02:16:04.540
If day number equals this, then display this day.

02:16:06.060 --> 02:16:08.660
And then we'll do that same exercise,

02:16:08.680 --> 02:16:10.760
but we'll use a switch statement instead for that.

02:16:12.600 --> 02:16:16.460
For this one, you can assume day one is Sunday

02:16:16.460 --> 02:16:18.140
or Monday, it doesn't matter either way.

02:16:18.280 --> 02:16:19.580
As long as you handle the question

02:16:19.580 --> 02:16:20.540
that comes up sometimes.

02:16:21.500 --> 02:16:24.780
And we'll spend about 10 on this one as well.

02:16:25.040 --> 02:16:29.220
So from now, 12, was that 12.30?

02:16:29.320 --> 02:16:32.160
Yeah, 12.30 for you guys, 12.40.

02:16:34.540 --> 02:16:36.240
So was there a question in the chat?

02:16:43.360 --> 02:16:44.080
Yeah, absolutely.

02:16:44.200 --> 02:16:47.060
You're a keyboard shortcut person like myself.

02:16:48.900 --> 02:16:51.020
Maria's got a great tip in the chat there for you.

02:17:18.020 --> 02:17:19.420
Okay.

02:17:47.900 --> 02:17:49.300
Okay.

02:18:17.860 --> 02:18:20.640
So we'll take a look.

02:18:33.220 --> 02:18:34.520
A tricky part with this is just the way

02:18:34.520 --> 02:18:36.280
you just remember all the curly braces, right?

02:18:36.640 --> 02:18:38.960
Curly braces and where you put those.

02:18:39.200 --> 02:18:40.240
Let's take a look.

02:18:46.680 --> 02:18:48.600
All right, so should be able to see my screen.

02:18:48.980 --> 02:18:54.260
So I'm just opening up the activities 10 and the assault.

02:18:55.020 --> 02:18:56.580
Just click on that solution.

02:18:57.480 --> 02:18:58.880
So let's take a look.

02:19:04.540 --> 02:19:07.120
Open that up and then I'll just zoom in on that.

02:19:10.940 --> 02:19:13.760
So we've got this date number variable,

02:19:14.200 --> 02:19:15.600
the sign from an integer,

02:19:15.720 --> 02:19:17.460
which is assigning it a value.

02:19:20.340 --> 02:19:21.960
Why does it continue to open that up?

02:19:21.960 --> 02:19:22.760
There we go.

02:19:23.480 --> 02:19:25.500
And then we're just gonna do a series of checks.

02:19:26.340 --> 02:19:27.420
So the important thing is remember,

02:19:27.560 --> 02:19:29.700
on your if statement, you're gonna have that keyword.

02:19:30.660 --> 02:19:32.620
Then you'll have your parentheses around

02:19:32.620 --> 02:19:34.600
the conditions that you're checking there.

02:19:35.960 --> 02:19:37.780
And then the if statement has the body

02:19:37.780 --> 02:19:39.920
that's gonna be inside those curly braces.

02:19:40.000 --> 02:19:44.900
So here on line 14 and 16 will be that opening

02:19:44.900 --> 02:19:46.240
and closing curly brace.

02:19:46.840 --> 02:19:48.540
So it just has that keyword if,

02:19:49.600 --> 02:19:51.660
in parentheses is what you're checking.

02:19:52.780 --> 02:19:54.440
And then you have your curly braces

02:19:54.440 --> 02:19:56.580
that are gonna be the body that'll get run.

02:19:56.580 --> 02:19:58.660
That's the code that'll get executed if that's true.

02:19:58.740 --> 02:19:59.920
And so when you're nesting those,

02:20:00.040 --> 02:20:00.860
then the same thing.

02:20:01.500 --> 02:20:03.260
You can tell right away if they're not

02:20:03.260 --> 02:20:04.940
sort of nested correctly or something,

02:20:04.940 --> 02:20:06.560
you'll start getting those red squigglies.

02:20:07.580 --> 02:20:09.420
The challenge can be sometimes,

02:20:09.980 --> 02:20:11.780
it might be a squiggly or a brace

02:20:11.780 --> 02:20:14.160
or something you missed early on

02:20:14.160 --> 02:20:16.720
that's causing an error sort of later in your code.

02:20:17.840 --> 02:20:20.980
So one way that you can find those

02:20:20.980 --> 02:20:22.140
a little bit more straightforward.

02:20:22.700 --> 02:20:25.020
If you'll notice, Visual Studio is doing this thing

02:20:25.020 --> 02:20:27.200
where it's sort of giving the arrows to collapse.

02:20:28.440 --> 02:20:30.600
It does that by looking at your code

02:20:30.600 --> 02:20:32.020
and finding those curly braces.

02:20:32.740 --> 02:20:35.020
So if you start collapsing these things

02:20:35.680 --> 02:20:38.000
and you find either one that doesn't collapse,

02:20:38.400 --> 02:20:41.040
doesn't have the little arrow on the side there

02:20:41.040 --> 02:20:43.880
or is not collapsing the way you're expecting,

02:20:44.300 --> 02:20:46.640
that can be kind of where the problem is.

02:20:46.720 --> 02:20:50.000
Maybe it'll help you hone in on what's going on there.

02:20:54.440 --> 02:20:55.960
So really what we're calling out here,

02:20:55.980 --> 02:20:57.420
just kind of giving you some more practice

02:20:57.420 --> 02:20:58.540
doing conditionals.

02:20:58.540 --> 02:21:01.700
And again, you can check either way.

02:21:01.800 --> 02:21:03.280
Either way is perfectly valid code.

02:21:03.940 --> 02:21:06.440
But sometimes depending upon the amount of code

02:21:06.440 --> 02:21:08.900
that you're running based on those different conditions,

02:21:10.120 --> 02:21:11.260
a switch statement might be

02:21:11.260 --> 02:21:12.400
a little bit more straightforward.

02:21:12.640 --> 02:21:14.020
It might be a little bit more readable,

02:21:14.220 --> 02:21:16.600
especially when you have multiple statements involved.

02:21:17.480 --> 02:21:19.960
And that's kind of the big takeaway from this

02:21:19.960 --> 02:21:21.740
is that you do have that available to you.

02:21:21.980 --> 02:21:23.800
Any questions on this activity itself?

02:21:23.940 --> 02:21:26.140
So there's our version with the if statements

02:21:26.940 --> 02:21:30.640
and then the switch statement you'll see once I move.

02:21:31.800 --> 02:21:34.060
So I fight with my good buddy Zoom here.

02:21:34.060 --> 02:21:34.900
There we go.

02:21:35.840 --> 02:21:37.660
And move some of those out of the way.

02:21:39.100 --> 02:21:40.840
You'll see a switch statement, very similar.

02:21:41.660 --> 02:21:43.300
We're just checking the value

02:21:43.300 --> 02:21:44.880
and then we're gonna compare that

02:21:44.880 --> 02:21:46.040
to our case statements

02:21:46.540 --> 02:21:48.700
to find the one that matches there.

02:21:52.040 --> 02:21:53.380
Any questions at all on that?

02:21:54.020 --> 02:21:57.780
Any thoughts on switch statement versus if-else?

02:22:00.540 --> 02:22:04.780
I wonder if you didn't put the break on each case

02:22:04.780 --> 02:22:07.180
that just keep on going?

02:22:08.100 --> 02:22:08.960
You should try that, actually.

02:22:09.420 --> 02:22:11.820
So in this version of C-sharp,

02:22:12.500 --> 02:22:14.880
it behaves a little bit differently than it used to.

02:22:15.280 --> 02:22:15.780
Did you try it?

02:22:15.860 --> 02:22:18.080
No, I saw that going too many, actually.

02:22:18.500 --> 02:22:21.460
So on the other screen, but I tried now.

02:22:22.900 --> 02:22:25.100
Yeah, so here, if I, for example,

02:22:25.700 --> 02:22:28.180
you're saying basically if I just comment this out, right?

02:22:28.280 --> 02:22:29.840
So if I pick all these little break statements

02:22:30.420 --> 02:22:32.800
and I just comment that out,

02:22:32.800 --> 02:22:33.980
what's gonna happen, right?

02:22:36.600 --> 02:22:38.820
Yeah, so in this version,

02:22:39.360 --> 02:22:41.780
I'm actually getting this little error message

02:22:41.780 --> 02:22:44.420
that says they can't go from one case to another.

02:22:45.520 --> 02:22:47.560
So it's actually telling me it's required

02:22:47.560 --> 02:22:48.840
that I have to put it in there.

02:22:52.760 --> 02:22:54.940
So in some versions of C-sharp,

02:22:55.300 --> 02:22:56.500
what would happen there,

02:22:56.840 --> 02:23:00.020
there was a weird behavior where if you didn't put that

02:23:00.020 --> 02:23:01.800
break, it actually would fall through.

02:23:01.860 --> 02:23:06.820
So it would keep running code until it found a break

02:23:06.820 --> 02:23:08.360
or until it dropped out of here.

02:23:09.400 --> 02:23:11.840
And people were actually taking advantage

02:23:11.840 --> 02:23:13.360
of that behavior, using that.

02:23:13.820 --> 02:23:14.720
And as a result,

02:23:14.760 --> 02:23:16.900
they were getting some weird behavior in their code.

02:23:18.060 --> 02:23:19.440
So yeah, the break is,

02:23:19.560 --> 02:23:21.000
you're gonna see if you try to remove it,

02:23:21.000 --> 02:23:22.560
you're getting that message that's required.

02:23:23.120 --> 02:23:27.360
And that's just letting you sort of explicitly know,

02:23:28.040 --> 02:23:30.760
only run this code until you get to this point

02:23:30.760 --> 02:23:32.120
and then you're out of that case.

02:23:32.660 --> 02:23:33.620
Great question though.

02:23:35.520 --> 02:23:36.800
And again, it's really a matter of preference.

02:23:37.220 --> 02:23:39.000
So you're just getting different ways

02:23:39.000 --> 02:23:40.320
to do sort of the same thing.

02:23:40.340 --> 02:23:43.520
And you'll see as we work with Visual Studio and C-sharp,

02:23:43.740 --> 02:23:45.760
that that's gonna be the scenario quite a bit

02:23:45.760 --> 02:23:47.860
where you'll have more than one way to do something.

02:23:48.380 --> 02:23:49.780
And I would just recommend,

02:23:49.780 --> 02:23:51.220
do the way that you understand,

02:23:51.340 --> 02:23:52.680
the way that makes sense to you.

02:23:53.400 --> 02:23:55.740
If your code runs and you get the result

02:23:55.740 --> 02:23:57.500
that you're expecting and it's readable,

02:23:58.240 --> 02:23:59.760
that's far more important

02:23:59.760 --> 02:24:01.960
than writing sort of slick code, right?

02:24:02.860 --> 02:24:04.980
Sometimes people will spend a lot of time

02:24:04.980 --> 02:24:09.820
trying to write the most perfect line of code ever,

02:24:10.640 --> 02:24:12.260
especially when you're learning a language.

02:24:12.460 --> 02:24:13.720
I think it's far more important

02:24:13.720 --> 02:24:15.560
to understand what the code is doing

02:24:15.560 --> 02:24:16.900
and have code that works.

02:24:17.460 --> 02:24:19.880
And then as part of your learning as a developer,

02:24:19.880 --> 02:24:23.760
you can always come back and improve your code, right?

02:24:24.120 --> 02:24:26.040
But the most important thing is making sure

02:24:26.040 --> 02:24:27.060
that you understand it

02:24:27.060 --> 02:24:29.300
and writing readable code the first time.

02:24:31.720 --> 02:24:33.540
Okay, so let's see.

02:24:34.960 --> 02:24:37.680
Normally we would do a review on this activity

02:24:37.680 --> 02:24:39.980
and then we would do our 60 minute break.

02:24:40.660 --> 02:24:42.500
So that's gonna be,

02:24:43.880 --> 02:24:46.080
it's like quarter to one for you.

02:24:47.380 --> 02:24:50.120
Do you wanna take your lunch break now then, I guess?

02:24:50.820 --> 02:24:52.320
And we'll come back after that?

02:24:55.740 --> 02:24:56.160
Sounds good?

02:24:56.360 --> 02:24:57.300
Like yes or no?

02:24:57.400 --> 02:24:58.300
Like give me a yay or nay?

02:25:00.200 --> 02:25:02.780
All right, so it's a little bit,

02:25:02.860 --> 02:25:06.780
it's like 15 till, so we'll do 45 after.

02:25:07.060 --> 02:25:11.120
So we'll do until, what would that be?

02:25:11.940 --> 02:25:12.760
145 your time?

02:25:14.500 --> 02:25:14.940
Okay.

02:25:16.040 --> 02:25:16.560
Yeah, let's do that.

02:25:16.560 --> 02:25:17.960
Yeah, we'll come back at 145

02:25:17.960 --> 02:25:21.760
and then we have most of the fundamentals already.

02:25:21.860 --> 02:25:24.060
So basically after we come back,

02:25:24.060 --> 02:25:26.540
we're gonna talk about looping,

02:25:26.600 --> 02:25:27.980
we're gonna talk about arrays

02:25:27.980 --> 02:25:29.720
and then we're gonna do some activities

02:25:29.720 --> 02:25:30.960
using all this cool knowledge

02:25:30.960 --> 02:25:32.900
that we've been working on.

02:25:33.400 --> 02:25:34.480
So yeah, we'll take a break now.

02:25:34.540 --> 02:25:37.920
I'll see you at 145 and we'll pick it up with loops.

02:25:40.740 --> 02:25:41.160
Thanks.

02:25:47.480 --> 02:25:50.320
That's the 12.5.

02:25:51.860 --> 02:25:52.480
That's one.

02:25:53.420 --> 02:25:55.180
And then one.

02:25:57.620 --> 02:25:59.020
145.

02:25:59.820 --> 02:26:01.640
That'll be activities.

02:26:26.640 --> 02:26:28.040
Okay.

02:26:49.580 --> 02:26:50.980
Okay.

02:27:26.080 --> 02:27:29.620
Oh, damn it.

02:28:07.720 --> 02:28:09.120
Okay.

02:28:27.520 --> 02:28:31.040
One, two, three, four, five, six, seven, eight, nine,

02:28:31.440 --> 02:28:33.200
10, 11, 12.

02:28:34.060 --> 02:28:35.340
Oh, oh, oh.

02:28:38.640 --> 02:28:39.460
Oh.

02:28:43.720 --> 02:28:44.460
Oh.

02:28:45.940 --> 02:28:46.680
Oh.

02:28:49.060 --> 02:28:49.180
Oh.

02:28:50.180 --> 02:28:50.460
Oh.

02:28:50.460 --> 02:28:53.280
10, 10, 10, 10, 10, 10, 10, 10.

02:29:03.360 --> 02:29:08.320
145, six, seven, eight, nine, 10, 11, 12.

02:29:17.160 --> 02:29:22.600
One, two, three, four, five, six, seven, eight, nine,

02:29:22.900 --> 02:29:25.220
10, 11, 12.

02:29:26.500 --> 02:29:36.060
One, two, three, four, five, six, seven, eight, nine,

02:29:37.420 --> 02:29:38.760
Oh, no.

02:29:51.900 --> 02:29:52.540
Oh.

02:29:52.540 --> 02:29:59.020
One, two, three, four, five, six, seven, eight, nine,

02:29:59.420 --> 02:30:01.020
10, 11, 12.

02:30:09.460 --> 02:30:12.420
One, two, three, four, five, six, seven, eight, nine,

02:30:13.000 --> 02:30:14.120
10, 11, 12.

02:30:16.620 --> 02:30:21.160
Four, five, six, seven, eight, nine, 10, 11, 12.

02:30:45.260 --> 02:30:46.660
Oh.

02:31:10.240 --> 02:31:11.640
Oh.

02:31:42.720 --> 02:31:43.420
Oh.

02:31:44.600 --> 02:31:48.420
145, seven, eight, nine, 10, 11, 12.

02:31:56.320 --> 02:31:57.720
Oh.

02:31:58.340 --> 02:31:58.360
Oh.

02:32:34.180 --> 02:32:35.580
Oh.

02:32:45.740 --> 02:32:46.100
Ah.

02:33:01.320 --> 02:33:02.720
Ah.

02:33:02.720 --> 02:33:04.600
What is it all about?

02:33:06.720 --> 02:33:06.940
Ah.

02:33:08.720 --> 02:33:08.800
Ah.

02:33:09.820 --> 02:33:10.420
Ah.

02:33:11.560 --> 02:33:12.240
Ah.

02:33:28.620 --> 02:33:29.540
Ah.

02:33:36.820 --> 02:33:38.660
Welcome back.

02:33:38.800 --> 02:33:41.780
Let me just refresh my machine here.

02:33:43.060 --> 02:33:43.900
All right, perfect.

02:33:45.580 --> 02:33:47.180
All right, so before the break,

02:33:47.320 --> 02:33:49.300
we were talking about conditionals

02:33:49.300 --> 02:33:50.540
and some ways to check those,

02:33:50.580 --> 02:33:51.680
and then we saw switches,

02:33:51.840 --> 02:33:54.400
how they kind of give us an alternative to those.

02:33:55.720 --> 02:33:59.140
Now let's take a look at loops.

02:34:02.040 --> 02:34:03.740
So I'm gonna go here.

02:34:15.380 --> 02:34:17.720
So just like conditionals are pretty common,

02:34:17.800 --> 02:34:21.300
it gives us a way to check our data,

02:34:21.400 --> 02:34:22.600
check the values of that,

02:34:22.600 --> 02:34:25.620
and then make some kind of a decision based on that.

02:34:26.460 --> 02:34:29.680
Another very common thing that we wanna do in our code

02:34:30.280 --> 02:34:32.200
is to be able to repeat code.

02:34:32.660 --> 02:34:32.680
Perfect.

02:34:35.960 --> 02:34:39.040
And loops will allow us to do that.

02:34:39.040 --> 02:34:40.780
So let's take a look at C Sharp.

02:34:40.840 --> 02:34:41.340
How do we do loops?

02:34:45.920 --> 02:34:48.580
Okay, and I will move this.

02:34:54.520 --> 02:34:55.060
There we go.

02:34:56.540 --> 02:34:57.680
So let's take a look at some loops

02:34:57.680 --> 02:34:59.000
and some common ways to do this.

02:34:59.040 --> 02:35:00.780
So a loop is literally just something

02:35:00.780 --> 02:35:02.560
where we wanna have repeat code.

02:35:02.640 --> 02:35:04.600
We have code that we wanna repeat,

02:35:05.180 --> 02:35:07.260
and we could just write that code again

02:35:07.260 --> 02:35:08.100
and again and again.

02:35:08.920 --> 02:35:09.800
But with a loop,

02:35:10.040 --> 02:35:12.020
we're able to take a block of code

02:35:12.020 --> 02:35:13.140
that we wanna repeat,

02:35:13.660 --> 02:35:16.340
and then we can tell it how many times to repeat.

02:35:18.280 --> 02:35:20.980
So for example, here on line 11,

02:35:21.580 --> 02:35:22.360
can you see my screen?

02:35:22.460 --> 02:35:22.960
Is it sharing?

02:35:23.120 --> 02:35:24.160
Yeah, it looks like it is.

02:35:25.040 --> 02:35:26.260
So on line 11 here,

02:35:26.500 --> 02:35:31.040
we're gonna use the for keyword to do a loop.

02:35:31.860 --> 02:35:34.680
And so what we wanna do is the body of this,

02:35:34.700 --> 02:35:36.160
the line 12 to 13,

02:35:36.400 --> 02:35:39.540
this code that's in the body here on line 13,

02:35:40.220 --> 02:35:43.580
we wanna repeat that code a certain number of times.

02:35:45.300 --> 02:35:46.620
Now, this is kind of a silly example.

02:35:46.740 --> 02:35:47.440
A real world,

02:35:47.680 --> 02:35:50.340
we'll show you some much more realistic examples,

02:35:50.380 --> 02:35:52.880
but for demo purposes here,

02:35:53.060 --> 02:35:54.680
we're just gonna print out some numbers.

02:35:56.340 --> 02:35:57.480
But the key takeaway is that

02:35:57.480 --> 02:35:59.000
if you have code that you wanna repeat,

02:35:59.480 --> 02:36:01.040
a loop will let you do that.

02:36:01.460 --> 02:36:02.200
And specifically,

02:36:02.260 --> 02:36:03.780
we'll look at a couple of kinds of loops.

02:36:03.780 --> 02:36:05.380
So we'll start out with the for loop.

02:36:06.100 --> 02:36:08.720
So the for keyword.

02:36:09.880 --> 02:36:11.820
And then very similar to what we saw

02:36:11.820 --> 02:36:13.520
with the if statement,

02:36:14.080 --> 02:36:17.740
there's gonna be some set of conditions

02:36:18.420 --> 02:36:20.420
about how do we repeat this code.

02:36:22.700 --> 02:36:24.620
So you can see here inside the parentheses,

02:36:25.260 --> 02:36:27.480
I'm gonna have some conditions that tell me

02:36:27.480 --> 02:36:29.700
how many times I should repeat this loop.

02:36:31.880 --> 02:36:33.680
And you're gonna notice too,

02:36:33.680 --> 02:36:35.560
there's some semicolons in here.

02:36:35.640 --> 02:36:40.780
So remember, semicolons are actually end a line of code.

02:36:40.800 --> 02:36:43.400
So what we have in this for loop condition

02:36:44.000 --> 02:36:45.900
is actually three parts.

02:36:46.620 --> 02:36:50.640
So there's this first part here, int i equals zero.

02:36:51.700 --> 02:36:55.540
There's the second part, i is less than four.

02:36:55.680 --> 02:36:58.820
And then there's this third part, i plus plus.

02:36:59.540 --> 02:37:00.460
So with a loop,

02:37:00.480 --> 02:37:02.780
we're gonna have three things that we need to do.

02:37:03.300 --> 02:37:05.500
We're gonna have some kind of a starting condition.

02:37:06.380 --> 02:37:07.840
In this case, we're gonna start out

02:37:07.840 --> 02:37:10.780
by setting this variable i to the value zero.

02:37:10.940 --> 02:37:13.500
So that's kind of initializing or starting our loop.

02:37:14.820 --> 02:37:16.240
The second thing that's gonna happen

02:37:16.240 --> 02:37:17.980
is there's gonna be a check.

02:37:18.080 --> 02:37:21.080
So just like an if statement has a condition that checks,

02:37:21.680 --> 02:37:25.660
the loop, the second part of the for here

02:37:26.340 --> 02:37:30.000
is gonna be what condition do we check

02:37:30.000 --> 02:37:32.540
to decide if we continue to repeat this code

02:37:32.540 --> 02:37:33.660
or continue to loop.

02:37:34.600 --> 02:37:37.540
So here we're gonna say, is i less than four?

02:37:38.920 --> 02:37:41.140
So since i is zero right now,

02:37:41.740 --> 02:37:43.240
that means that we're gonna repeat the code.

02:37:43.300 --> 02:37:47.560
So as long as this condition is true here on line 11,

02:37:47.700 --> 02:37:50.000
then we're gonna run whatever is in the body

02:37:50.000 --> 02:37:50.660
of this loop.

02:37:50.960 --> 02:37:53.600
So we'll run this console statement here.

02:37:54.500 --> 02:37:57.220
And then we're gonna keep checking this condition.

02:37:57.280 --> 02:37:58.580
So we'll run this code

02:37:58.580 --> 02:38:00.480
and we'll come back and check this.

02:38:00.980 --> 02:38:02.620
And every time this is true,

02:38:02.720 --> 02:38:04.460
we're gonna keep repeating this code.

02:38:07.700 --> 02:38:09.240
So the last thing we need to do

02:38:09.240 --> 02:38:13.260
is we need to have some way to move this thing along

02:38:13.260 --> 02:38:15.900
so that we know how many times to loop.

02:38:16.700 --> 02:38:18.300
So the last part of this,

02:38:19.780 --> 02:38:22.820
we're gonna run every time the loop runs, right?

02:38:22.820 --> 02:38:24.740
So we'll start out i is zero.

02:38:26.280 --> 02:38:27.700
We check this condition.

02:38:27.700 --> 02:38:29.120
If it's less than four,

02:38:29.440 --> 02:38:31.900
we do whatever is in this body of the loop.

02:38:33.440 --> 02:38:36.780
And then we, i++.

02:38:36.960 --> 02:38:38.520
What do you think that i++ is doing?

02:38:41.000 --> 02:38:43.560
Yeah, it's basically a shorthand, right?

02:38:43.620 --> 02:38:45.520
So it's basically a shorthand for this,

02:38:45.540 --> 02:38:46.980
if you wanna think about it like this.

02:38:47.280 --> 02:38:52.480
It's basically the same as saying i equals i plus one.

02:38:53.840 --> 02:38:55.920
And so this is a shortcut that just says,

02:38:55.920 --> 02:38:59.520
make i, the value of i, increase by one.

02:39:00.280 --> 02:39:02.920
So since this is such a common thing to do,

02:39:03.220 --> 02:39:05.240
we actually have a little operator,

02:39:06.240 --> 02:39:08.920
the increment operator, that will do that automatically.

02:39:09.020 --> 02:39:13.000
So this i++ is really just kind of a shorthand for,

02:39:13.280 --> 02:39:16.260
take the value of i, add one to it,

02:39:16.660 --> 02:39:18.600
and then assign it back to i.

02:39:20.620 --> 02:39:21.740
A little bit of a lag there,

02:39:21.840 --> 02:39:23.560
so hopefully I don't over type, there we go.

02:39:25.360 --> 02:39:27.180
So what we're doing then is we're saying,

02:39:27.480 --> 02:39:28.960
if i is less than four, it's zero,

02:39:29.540 --> 02:39:31.100
go ahead and add one to that.

02:39:31.600 --> 02:39:33.100
And then we check the condition again.

02:39:33.960 --> 02:39:35.900
So one, is one less than four?

02:39:36.580 --> 02:39:39.200
Yes, so we'll run the body of this loop.

02:39:40.320 --> 02:39:41.880
And then we'll keep doing this,

02:39:41.880 --> 02:39:42.960
we'll keep repeating this.

02:39:43.160 --> 02:39:46.000
So we'll add one to i, now i is two.

02:39:46.680 --> 02:39:47.820
We'll check the condition.

02:39:48.460 --> 02:39:50.900
And as soon as this condition is no longer true,

02:39:52.180 --> 02:39:55.380
then we'll finish this loop, we'll come out of this code.

02:39:57.120 --> 02:40:00.120
And so loop has a, the four keyword

02:40:00.120 --> 02:40:03.240
is what's telling us to do some looping.

02:40:03.900 --> 02:40:07.540
Whatever is in the body of that loop, right here,

02:40:07.720 --> 02:40:10.500
so the curly braces between lines 12 and 14,

02:40:10.960 --> 02:40:13.360
that's the code that's gonna get repeated every time.

02:40:14.220 --> 02:40:16.800
And then we have three parts here to our loop.

02:40:17.320 --> 02:40:18.960
We have the starting condition,

02:40:20.100 --> 02:40:23.380
the second part is this check, i less than four.

02:40:24.560 --> 02:40:26.720
As long as that check is true, we're gonna keep looping.

02:40:27.940 --> 02:40:31.380
And then every time we loop, at the end of that,

02:40:31.480 --> 02:40:35.900
we'll go ahead and change the value of i.

02:40:37.580 --> 02:40:39.720
So how many times will this loop run?

02:40:39.740 --> 02:40:40.440
Four times?

02:40:41.240 --> 02:40:41.760
Four times.

02:40:41.980 --> 02:40:43.520
Right, so it starts out at zero,

02:40:43.920 --> 02:40:46.700
and then it goes to one, and then two, and then three.

02:40:46.700 --> 02:40:50.120
As soon as the value of i becomes four,

02:40:50.260 --> 02:40:51.960
four is no longer less than four,

02:40:52.120 --> 02:40:53.820
and it'll drop out of here.

02:40:55.060 --> 02:40:57.060
And so each time it's gonna write what?

02:40:57.060 --> 02:40:58.240
Just the value of i.

02:40:58.660 --> 02:41:00.820
So it's basically gonna write out zero,

02:41:01.360 --> 02:41:04.260
and then one, and then two, three,

02:41:04.380 --> 02:41:05.480
and then the loop will stop.

02:41:06.860 --> 02:41:10.460
So again, a really silly reason to use a loop, right?

02:41:10.460 --> 02:41:13.140
Typically, you're gonna be doing something more valuable

02:41:13.140 --> 02:41:14.880
in here than just writing out a number.

02:41:16.260 --> 02:41:19.020
But any time you have code that you need to repeat,

02:41:19.940 --> 02:41:20.940
you'll be able to do that.

02:41:21.100 --> 02:41:21.940
What might be an example?

02:41:22.200 --> 02:41:24.600
What kind of code would you maybe wanna repeat

02:41:25.240 --> 02:41:26.500
based on your variables?

02:41:28.160 --> 02:41:31.640
Well, for example, let's say we wanted to

02:41:31.640 --> 02:41:32.220
print out the names.

02:41:32.700 --> 02:41:33.700
Oh, did someone have an answer?

02:41:35.160 --> 02:41:36.320
I was just gonna say,

02:41:36.420 --> 02:41:38.420
just thinking about some of the work that we do,

02:41:38.680 --> 02:41:40.240
like you have some JSON output,

02:41:40.340 --> 02:41:43.400
and you know that you've got several key values

02:41:43.400 --> 02:41:45.460
that are saying you loop on those key values

02:41:45.460 --> 02:41:46.960
and do some work for that.

02:41:47.900 --> 02:41:49.000
Fantastic, great example.

02:41:49.540 --> 02:41:51.800
So basically, any time you have a set of data,

02:41:51.860 --> 02:41:54.020
so I was gonna say, as an example,

02:41:54.080 --> 02:41:54.920
if you have students

02:41:54.920 --> 02:41:57.520
and you wanna print out the student's first names,

02:41:58.380 --> 02:42:00.300
you would have to repeat that same code.

02:42:00.820 --> 02:42:02.600
You'd have to say for every student,

02:42:03.680 --> 02:42:04.560
write out the first name.

02:42:04.660 --> 02:42:06.400
For the next student, write out the first name.

02:42:06.760 --> 02:42:07.980
So there's lots of cases

02:42:07.980 --> 02:42:11.600
where you're gonna be able to reuse or repeat.

02:42:12.120 --> 02:42:14.860
And especially when you're working with sets of data,

02:42:15.340 --> 02:42:17.060
you wanna do the same thing

02:42:17.060 --> 02:42:20.060
to every piece of data in that set.

02:42:20.660 --> 02:42:21.520
Is there something in the chat?

02:42:21.720 --> 02:42:22.800
Let's see here.

02:42:23.800 --> 02:42:25.040
Oh, yeah, perfect example, right?

02:42:25.080 --> 02:42:27.240
Complete each task in an activity, exactly.

02:42:28.740 --> 02:42:30.680
And we'll talk right after loops actually

02:42:30.680 --> 02:42:32.720
about working with sets of data.

02:42:32.780 --> 02:42:34.160
So we'll kind of lead into that.

02:42:34.460 --> 02:42:36.400
We're gonna need to be able to loop to work with those.

02:42:36.460 --> 02:42:38.120
And so that's gonna kind of lead us right into

02:42:38.120 --> 02:42:39.480
talking about sets of data.

02:42:40.160 --> 02:42:42.860
So in this example, I've got a for loop.

02:42:43.420 --> 02:42:46.380
Again, starting condition, some kind of a check.

02:42:47.260 --> 02:42:50.280
And then the last part of this

02:42:50.280 --> 02:42:52.200
is what sort of moves the loop forward,

02:42:52.440 --> 02:42:53.560
keeps the loop moving.

02:42:55.300 --> 02:42:57.060
And for loops are really useful

02:42:58.440 --> 02:43:00.120
to be able to do that, right?

02:43:00.120 --> 02:43:01.860
To be able to repeat those DevLocker code.

02:43:03.420 --> 02:43:05.340
Let's take a look at another kind of loop.

02:43:06.600 --> 02:43:07.640
So here's a loop

02:43:08.160 --> 02:43:10.500
and we use this keyword, while.

02:43:11.600 --> 02:43:12.780
So you're gonna notice here,

02:43:12.780 --> 02:43:14.800
it's a little bit different with the while loop.

02:43:15.880 --> 02:43:18.540
I'm actually setting some value here

02:43:18.540 --> 02:43:21.140
of assigning the value of variable before that loop.

02:43:22.060 --> 02:43:24.880
And then in the while loop,

02:43:25.280 --> 02:43:27.620
all I'm doing there is checking the condition.

02:43:28.080 --> 02:43:31.000
So on line 25, it's just simply checking that condition.

02:43:31.480 --> 02:43:33.520
And as long as that condition's true,

02:43:34.040 --> 02:43:35.680
it's gonna just continue to loop.

02:43:37.000 --> 02:43:39.760
And so same idea, just with a for loop,

02:43:39.840 --> 02:43:43.820
it's gonna repeat whatever is in the body of that loop.

02:43:45.780 --> 02:43:47.480
So what's the difference, do you think,

02:43:47.580 --> 02:43:48.580
between a for and while?

02:43:48.660 --> 02:43:51.460
Why would I use a for loop versus a while?

02:43:51.520 --> 02:43:52.960
If they both repeat code,

02:43:54.260 --> 02:43:56.180
what would be the difference between those two,

02:43:56.220 --> 02:43:56.700
do you think?

02:43:58.700 --> 02:44:01.620
For loop is for when you know exactly

02:44:01.620 --> 02:44:04.540
how many times you wanna repeat it.

02:44:05.100 --> 02:44:06.760
I think the other one is, I'm not sure.

02:44:07.680 --> 02:44:08.680
Yeah, absolutely.

02:44:08.820 --> 02:44:12.540
So with a for loop, right as part of the loop itself,

02:44:12.600 --> 02:44:13.860
when I'm setting that up,

02:44:14.280 --> 02:44:16.060
I'm setting basically a start,

02:44:16.700 --> 02:44:18.820
I'm setting the end condition.

02:44:19.220 --> 02:44:22.980
And so I know upfront how many times this is gonna loop.

02:44:24.160 --> 02:44:27.400
In this example here, you can figure that out as well,

02:44:27.680 --> 02:44:29.100
but I'll show you,

02:44:29.240 --> 02:44:30.560
there's a more real world example here.

02:44:30.900 --> 02:44:32.920
The difference is just what Dustin was saying.

02:44:32.920 --> 02:44:37.260
So with a while loop, I'm just checking some condition.

02:44:37.380 --> 02:44:40.040
And as long as that condition continues to be true,

02:44:40.540 --> 02:44:41.700
I'm gonna keep looping.

02:44:42.020 --> 02:44:44.920
So that could be one time, that could be 20 times.

02:44:45.980 --> 02:44:48.500
It depends on what that condition is that I'm checking.

02:44:50.000 --> 02:44:52.660
So a while loop is a little bit more open-ended

02:44:52.660 --> 02:44:54.920
where you don't know upfront

02:44:54.920 --> 02:44:56.760
how many times you wanna loop.

02:44:57.180 --> 02:44:59.280
You're basically gonna continue looping

02:44:59.280 --> 02:45:00.980
as long as that condition is true.

02:45:01.620 --> 02:45:02.900
Now, the other thing you're gonna notice too,

02:45:02.900 --> 02:45:06.900
in a while loop, something has to change this condition.

02:45:06.940 --> 02:45:08.800
This condition has to change in some way.

02:45:09.540 --> 02:45:13.120
So here it's inside the loop on line 28,

02:45:13.260 --> 02:45:15.860
we're actually gonna move the value of K,

02:45:16.020 --> 02:45:17.360
increment the value of K.

02:45:18.380 --> 02:45:20.940
But normally real world, if you think of the example,

02:45:21.020 --> 02:45:22.540
I think Lisa gave this example earlier

02:45:22.540 --> 02:45:23.680
about checking the temperature.

02:45:24.860 --> 02:45:25.800
So if, for example,

02:45:25.860 --> 02:45:28.160
we were saying looping based on the temperature,

02:45:29.420 --> 02:45:31.840
it might be something external to this code

02:45:31.840 --> 02:45:33.560
that's actually changing the temperature.

02:45:33.660 --> 02:45:35.400
And all we're gonna do in here is just check.

02:45:35.480 --> 02:45:38.820
And as long as that temperature is over a certain value

02:45:38.820 --> 02:45:40.200
or less than a certain value,

02:45:40.460 --> 02:45:42.180
we're gonna continue to do something

02:45:42.180 --> 02:45:43.980
until that condition changes.

02:45:44.820 --> 02:45:47.400
So that's the flexibility you're getting with a while loop

02:45:47.400 --> 02:45:52.060
is that you can loop as many times as you need to

02:45:52.060 --> 02:45:54.000
until that condition changes.

02:45:56.520 --> 02:45:57.440
Very good.

02:45:57.880 --> 02:46:00.040
All right, so the final one we'll take a look at.

02:46:00.040 --> 02:46:05.940
Sometimes, let me draw the screen down just a little bit here.

02:46:07.940 --> 02:46:09.560
So with my while loop,

02:46:09.980 --> 02:46:14.900
what if this initial value of this was five?

02:46:16.280 --> 02:46:19.460
How many times is the code inside that loop gonna run?

02:46:20.420 --> 02:46:21.340
Never, right?

02:46:21.340 --> 02:46:23.860
Because the very first time that we check that condition,

02:46:24.660 --> 02:46:25.880
it's not true.

02:46:25.880 --> 02:46:29.800
And so it simply moves past that loop, right?

02:46:30.140 --> 02:46:33.480
So there's certain cases where you do want that code

02:46:33.480 --> 02:46:35.720
in that loop to run at least one time.

02:46:37.160 --> 02:46:40.160
And so in that case, there's a variation of while

02:46:41.320 --> 02:46:43.100
that you're gonna see called do while.

02:46:43.840 --> 02:46:47.300
And so here, similar to the while loop,

02:46:47.300 --> 02:46:49.600
we're gonna set some kind of data up, right?

02:46:49.980 --> 02:46:54.060
And then the do keyword says do whatever is

02:46:54.060 --> 02:46:59.520
in that code block and then check the condition, right?

02:46:59.740 --> 02:47:01.860
So the only difference here really is

02:47:01.860 --> 02:47:03.740
that with the normal while,

02:47:03.880 --> 02:47:05.680
we're checking the condition upfront.

02:47:06.520 --> 02:47:07.780
And in a do while,

02:47:08.200 --> 02:47:10.940
we're checking the condition after we run.

02:47:11.840 --> 02:47:13.300
And again, the real reason,

02:47:13.380 --> 02:47:15.240
the real advantage of doing that is that

02:47:15.240 --> 02:47:17.640
if there's code that you want to guarantee runs

02:47:17.640 --> 02:47:19.020
at least one time,

02:47:20.580 --> 02:47:22.320
the do while loop will let you do that.

02:47:22.320 --> 02:47:25.120
So this code will run at least once,

02:47:25.700 --> 02:47:28.500
then check the condition to decide if it needs to continue.

02:47:30.460 --> 02:47:34.060
Any questions at all on those three different ways

02:47:34.060 --> 02:47:34.700
that we can loop?

02:47:35.080 --> 02:47:37.780
When is the best scenario to do a do while loop?

02:47:38.420 --> 02:47:42.200
It's just to check the data if it's good or just?

02:47:42.680 --> 02:47:43.200
Exactly.

02:47:43.340 --> 02:47:46.900
So for example, say I wanted to display a message

02:47:46.900 --> 02:47:51.360
to the user that said, enter your last name.

02:47:52.320 --> 02:47:54.760
And then I'm gonna check that last name

02:47:54.760 --> 02:47:56.860
and if it's a certain last name,

02:47:56.880 --> 02:47:58.500
then I'll do a certain code.

02:47:59.320 --> 02:48:00.820
If I did a while loop,

02:48:01.760 --> 02:48:03.780
I would never prompt them, right?

02:48:03.780 --> 02:48:05.460
They would never see the message, for example.

02:48:05.960 --> 02:48:08.100
So this would say like check the value,

02:48:08.120 --> 02:48:09.920
but it wouldn't never display the message.

02:48:10.520 --> 02:48:11.700
Whereas in a do while,

02:48:11.940 --> 02:48:15.060
I could write out the message, enter your name, right?

02:48:15.480 --> 02:48:16.500
Then I could check it

02:48:16.500 --> 02:48:18.200
and as long as it's something I could decide

02:48:18.200 --> 02:48:19.840
whether I was gonna repeat or not.

02:48:21.220 --> 02:48:24.940
So anytime you need to do some work always,

02:48:25.940 --> 02:48:27.320
that's when you would use a do while.

02:48:27.440 --> 02:48:29.220
Another example might be,

02:48:29.700 --> 02:48:31.060
say you're working with a program

02:48:31.060 --> 02:48:34.300
and you have to enter a menu item, right?

02:48:34.540 --> 02:48:36.520
One does something, two does something,

02:48:36.660 --> 02:48:39.240
and then you can enter a queue to quit, for example.

02:48:40.040 --> 02:48:41.840
A do while would be perfect for that

02:48:41.840 --> 02:48:44.560
because I could say, enter your command.

02:48:45.000 --> 02:48:47.560
And then as long as that command doesn't equal queue,

02:48:47.560 --> 02:48:50.540
I would just continue looping and letting you do.

02:48:51.280 --> 02:48:52.720
Those examples make sense?

02:48:52.800 --> 02:48:54.100
Oh, there's a message in the chat, let's see.

02:48:54.160 --> 02:48:54.920
Yeah, exactly.

02:48:55.240 --> 02:48:56.940
So Maria's got one that's more relevant

02:48:56.940 --> 02:48:58.380
to your actual work.

02:48:58.960 --> 02:48:59.900
But same idea, right?

02:49:00.440 --> 02:49:01.320
You're with a do while,

02:49:01.380 --> 02:49:03.040
you're at least running that code

02:49:03.040 --> 02:49:05.460
to prompt the user at least one time.

02:49:05.880 --> 02:49:08.360
And then depending upon what the user enters

02:49:08.360 --> 02:49:09.380
or what the data is,

02:49:09.400 --> 02:49:12.720
you're deciding whether I need to keep prompting that user.

02:49:12.800 --> 02:49:13.920
So with a for loop,

02:49:14.420 --> 02:49:17.900
if I know upfront the number of items

02:49:17.900 --> 02:49:19.400
that I'm working with,

02:49:19.880 --> 02:49:22.020
for loop is gonna allow me to work with that.

02:49:22.140 --> 02:49:22.980
It's gonna allow me to loop

02:49:22.980 --> 02:49:24.820
a certain specific number of times,

02:49:25.020 --> 02:49:27.340
and I kind of know upfront what that is.

02:49:27.620 --> 02:49:29.960
While loop, I'm able to loop

02:49:29.960 --> 02:49:33.140
as long as some condition is true, right?

02:49:33.140 --> 02:49:34.880
So I don't necessarily know

02:49:34.880 --> 02:49:36.380
is that loop gonna run one time?

02:49:36.460 --> 02:49:37.620
Is it gonna run 10 times?

02:49:37.900 --> 02:49:39.340
It depends on the data, right?

02:49:39.340 --> 02:49:40.760
So if my data coming in,

02:49:41.040 --> 02:49:43.560
if I'm saying keep checking these records

02:49:43.560 --> 02:49:45.220
until you find a match.

02:49:45.860 --> 02:49:47.380
I don't know if that's gonna find a match

02:49:47.380 --> 02:49:48.560
on the first time it runs

02:49:48.560 --> 02:49:50.560
or the fifth time it runs, right?

02:49:50.600 --> 02:49:52.820
So with a while, you've got that flexibility.

02:49:53.380 --> 02:49:55.320
And then again, do while,

02:49:55.420 --> 02:49:57.760
the only reason you would use that versus a while

02:49:57.760 --> 02:49:59.220
is if you have that code

02:49:59.220 --> 02:50:01.380
that you want to run at least one time,

02:50:01.620 --> 02:50:03.480
and then you may need to run it more times.

02:50:03.660 --> 02:50:05.200
Great questions and great example too.

02:50:06.360 --> 02:50:07.800
Any other questions about that

02:50:07.800 --> 02:50:08.960
before we take a look at some code?

02:50:10.620 --> 02:50:12.300
Yeah, let's take a look here.

02:50:14.840 --> 02:50:19.800
And this will be in our loops activity.

02:50:30.340 --> 02:50:32.220
And so here we're gonna do something kind of similar

02:50:32.220 --> 02:50:33.200
what we did in the other one

02:50:33.200 --> 02:50:34.820
where we're gonna take a look at the code

02:50:34.820 --> 02:50:36.180
and sort of figure out

02:50:36.180 --> 02:50:38.220
what we think is gonna print out from that.

02:50:38.580 --> 02:50:40.380
So there's gonna be some comments in there,

02:50:41.200 --> 02:50:42.840
and we'll show you some examples

02:50:42.840 --> 02:50:43.920
of some different loops.

02:50:44.580 --> 02:50:46.420
And your goal is to take a look,

02:50:47.560 --> 02:50:49.620
pretend you're the computer, right?

02:50:49.620 --> 02:50:51.300
And figure out what you think the output

02:50:51.300 --> 02:50:52.440
is gonna be for those.

02:50:52.900 --> 02:50:55.120
And then go ahead and build it and run it

02:50:55.120 --> 02:50:56.160
and kind of compare that.

02:50:56.160 --> 02:50:58.260
And then we'll come back and review that after.

02:50:58.520 --> 02:51:00.880
Tom, is it, let's see, three after.

02:51:01.080 --> 02:51:04.000
So we'll do this till about 13 after,

02:51:04.020 --> 02:51:05.180
and then we'll come back and take a look.

02:51:06.140 --> 02:51:07.920
And this is gonna be your loops activity,

02:51:07.920 --> 02:51:08.840
like activity 12.

02:51:28.120 --> 02:51:29.520
Okay.

02:51:53.320 --> 02:51:56.140
And so remember this one, the goal of it is to take a look

02:51:56.140 --> 02:51:57.500
and understand what the code's doing.

02:51:57.540 --> 02:51:59.620
You don't actually have to write any code for this one.

02:52:00.360 --> 02:52:01.800
Just put some comments in about

02:52:01.800 --> 02:52:03.400
what you think the output will be,

02:52:03.520 --> 02:52:05.340
and then run it.

02:52:11.320 --> 02:52:12.380
And then we'll come back and review that.

02:52:12.380 --> 02:52:12.620
And then we'll come back and review that.

02:52:12.620 --> 02:52:12.640
And then we'll come back and review that.

02:52:14.740 --> 02:52:17.200
Looks like most of you are pretty close on this one.

02:52:17.680 --> 02:52:19.440
So I don't think we're gonna need the full time.

02:52:20.000 --> 02:52:21.660
I mean, obviously, if you do, let me know.

02:52:22.200 --> 02:52:24.220
But I'm just hopping around a little bit.

02:52:24.340 --> 02:52:27.620
Looked like everybody was knocking this one out.

02:52:30.220 --> 02:52:34.860
So let's take a look at the output.

02:52:34.980 --> 02:52:36.600
Then we can talk through it a little bit there.

02:52:36.720 --> 02:52:38.240
Let me just share my screen.

02:52:40.920 --> 02:52:43.780
I'm gonna go ahead and close out of this.

02:53:19.160 --> 02:53:20.840
Okay, now I'll get that code open,

02:53:21.020 --> 02:53:22.880
and we'll look at what's happening here.

02:53:27.940 --> 02:53:36.620
Okay, so here, line nine, I've got this for loop.

02:53:37.280 --> 02:53:38.220
And it's gonna look like this.

02:53:38.220 --> 02:53:39.400
It's gonna start out at zero.

02:53:39.620 --> 02:53:41.340
So it'll set this value of i,

02:53:41.540 --> 02:53:42.660
and start that out at zero.

02:53:43.380 --> 02:53:45.580
And then as long as i is less than three,

02:53:45.720 --> 02:53:46.800
it'll continue to loop.

02:53:48.620 --> 02:53:50.580
And then every time it loops at the end,

02:53:51.380 --> 02:53:53.140
it'll increment the value of i,

02:53:53.240 --> 02:53:55.060
or add one to the value of i.

02:53:56.040 --> 02:53:58.340
And then it'll go ahead and run this code

02:53:58.340 --> 02:53:59.280
in this loop here.

02:54:00.580 --> 02:54:01.420
So what is the actual,

02:54:01.440 --> 02:54:03.280
what's the output from this look like?

02:54:03.580 --> 02:54:04.660
Zero, one, two.

02:54:06.420 --> 02:54:08.540
Yeah, and why is it just doing it

02:54:08.540 --> 02:54:10.040
in a straight line like that?

02:54:10.040 --> 02:54:12.160
Why isn't it doing those on separate lines?

02:54:13.960 --> 02:54:15.880
You used write instead of write line.

02:54:16.800 --> 02:54:19.400
Yeah, so here, we kind of trick you a little bit,

02:54:19.460 --> 02:54:21.560
or try to, by throwing write line.

02:54:21.700 --> 02:54:24.660
And so write line basically will write out the value

02:54:24.660 --> 02:54:25.960
of whatever you tell it,

02:54:25.980 --> 02:54:28.620
and then it automatically does a new line

02:54:28.620 --> 02:54:29.640
at the end of that.

02:54:30.220 --> 02:54:31.240
And so in this case,

02:54:31.260 --> 02:54:34.140
by just doing the write version of that,

02:54:35.020 --> 02:54:37.100
it actually is just going to continue

02:54:37.100 --> 02:54:38.880
doing it on the same line

02:54:39.440 --> 02:54:41.420
until it runs into a new line.

02:54:42.260 --> 02:54:43.900
And we're looping the three times, right?

02:54:43.920 --> 02:54:45.300
So the first time it's zero,

02:54:45.520 --> 02:54:47.020
and it'll roll right out to zero,

02:54:47.060 --> 02:54:48.520
and then it'll keep checking,

02:54:48.640 --> 02:54:50.300
okay, that's still less than it,

02:54:50.320 --> 02:54:52.360
so it'll write out the value one,

02:54:53.260 --> 02:54:54.640
still less, two,

02:54:54.760 --> 02:54:56.120
and then once it hits three,

02:54:56.220 --> 02:54:57.940
it'll stop that loop.

02:54:58.560 --> 02:55:00.040
And so you'll get that first value.

02:55:01.540 --> 02:55:02.780
Any questions at all on that?

02:55:02.780 --> 02:55:05.840
The three parts about the looping,

02:55:05.880 --> 02:55:09.120
you've got that start condition, semicolon,

02:55:09.220 --> 02:55:11.300
and then you've got whatever you're checking there

02:55:11.300 --> 02:55:13.440
to know whether to loop or not,

02:55:13.700 --> 02:55:14.640
and a semicolon,

02:55:14.660 --> 02:55:16.060
and then the final part of that

02:55:16.060 --> 02:55:17.420
is what's moving the loop.

02:55:17.600 --> 02:55:18.680
Okay, let's look at,

02:55:19.680 --> 02:55:21.680
oh, get rid of that silly window there.

02:55:21.980 --> 02:55:24.260
Let's look at the while loop then.

02:55:24.580 --> 02:55:27.740
So here, very similar to the example I was demoing.

02:55:28.120 --> 02:55:29.700
So we're going to have the while,

02:55:30.440 --> 02:55:32.360
whoop, it's not reading my mouse, there we go.

02:55:32.360 --> 02:55:33.860
It's going to have the while,

02:55:34.540 --> 02:55:36.560
we'll start this value out at zero,

02:55:36.960 --> 02:55:37.860
and we'll just check,

02:55:37.860 --> 02:55:39.540
as long as that's less than five,

02:55:39.640 --> 02:55:41.760
we'll continue to write that message out.

02:55:43.120 --> 02:55:45.420
And then remember with the while loop,

02:55:45.620 --> 02:55:47.900
we're only checking that condition,

02:55:47.980 --> 02:55:50.540
so something inside that loop

02:55:50.540 --> 02:55:52.520
has to change that condition.

02:55:53.620 --> 02:55:56.720
What would happen if I didn't have line 22 in here,

02:55:56.760 --> 02:56:00.140
if I didn't have this K plus plus line in here?

02:56:03.700 --> 02:56:05.340
It'll completely implement it.

02:56:05.340 --> 02:56:06.720
Yeah, it'll just run forever

02:56:06.720 --> 02:56:08.700
until your power runs out

02:56:08.700 --> 02:56:10.960
or the computer turns off, right?

02:56:11.840 --> 02:56:14.180
Yeah, it'll just continue to run.

02:56:15.780 --> 02:56:17.100
So yeah, so it's very important,

02:56:17.180 --> 02:56:18.440
unless that's what you're intending

02:56:18.440 --> 02:56:20.000
for your code to do,

02:56:20.060 --> 02:56:21.300
just repeat forever.

02:56:22.100 --> 02:56:24.100
Make sure that whatever you're checking there

02:56:24.100 --> 02:56:26.060
is going to change somewhere inside that loop.

02:56:28.180 --> 02:56:29.820
So here, we're going to just check and see,

02:56:29.840 --> 02:56:31.040
as long as it's less than five,

02:56:31.100 --> 02:56:31.940
we'll continue to loop,

02:56:31.940 --> 02:56:32.940
and then same idea,

02:56:33.040 --> 02:56:34.760
we'll just write the value of that out.

02:56:35.740 --> 02:56:36.680
So the output for that,

02:56:36.880 --> 02:56:39.840
it'll loop five times, right?

02:56:39.840 --> 02:56:42.920
But it'll write zero, one, two, three, and four.

02:56:43.040 --> 02:56:44.600
So here on line 29,

02:56:44.760 --> 02:56:47.240
we tried again to kind of throw you off a little bit,

02:56:47.380 --> 02:56:49.340
see if you understand what's happening there.

02:56:49.800 --> 02:56:51.060
So you'll notice this time,

02:56:51.100 --> 02:56:52.120
it's a little bit different.

02:56:53.280 --> 02:56:54.880
What's the end part here?

02:56:55.580 --> 02:56:56.700
What's our line 29?

02:56:56.800 --> 02:56:59.880
What's the end part of our loop doing there?

02:57:01.740 --> 02:57:02.440
Increasing one.

02:57:03.060 --> 02:57:04.800
Yeah, so you're doing the reverse, right?

02:57:04.860 --> 02:57:07.260
So in this case, we're starting at three,

02:57:07.340 --> 02:57:10.480
and then every time we're checking to see,

02:57:10.520 --> 02:57:12.380
and if it's still greater than negative one,

02:57:12.400 --> 02:57:15.140
we're actually going to subtract one from it every time.

02:57:16.540 --> 02:57:17.460
So just be aware,

02:57:18.660 --> 02:57:19.940
typically when you see these loops,

02:57:20.120 --> 02:57:21.220
we're usually counting up.

02:57:21.660 --> 02:57:23.700
We're doing the I plus plus, we're counting up.

02:57:24.100 --> 02:57:26.080
But just be aware, you don't have to,

02:57:26.180 --> 02:57:27.700
it doesn't matter which order you go in.

02:57:28.260 --> 02:57:31.320
Sometimes it's actually useful to start at the last thing

02:57:31.320 --> 02:57:33.000
and work your way back.

02:57:33.380 --> 02:57:36.220
And so you can very easily do that in a for loop

02:57:36.860 --> 02:57:40.960
by using a negative and counting backwards, right?

02:57:40.960 --> 02:57:42.780
So just be aware, that's a possibility.

02:57:43.400 --> 02:57:44.540
You know, the typical scenario,

02:57:44.760 --> 02:57:46.720
you'll typically start at the first thing

02:57:46.720 --> 02:57:48.780
and count from there or work from there,

02:57:48.780 --> 02:57:53.520
but you can work from the opposite direction, right?

02:57:56.180 --> 02:57:59.340
And then here's a more, as I've said,

02:57:59.420 --> 02:58:00.940
a little bit more realistic example

02:58:00.940 --> 02:58:03.680
of why you might use a while loop.

02:58:03.700 --> 02:58:06.700
Let me just scroll down a little bit.

02:58:10.580 --> 02:58:14.620
So here, we're starting that string value out

02:58:14.620 --> 02:58:16.360
as empty, right?

02:58:16.540 --> 02:58:18.160
So quotes with nothing in that.

02:58:18.760 --> 02:58:21.320
And then we're actually going to, at least one time,

02:58:21.400 --> 02:58:22.980
we want to message the user,

02:58:22.980 --> 02:58:25.300
you know, to have them enter a command

02:58:25.300 --> 02:58:27.920
and we'll tell them that they have to enter Q to quit.

02:58:29.040 --> 02:58:31.100
And so inside that loop,

02:58:31.660 --> 02:58:34.940
you're going to see that we're also doing on line 43.

02:58:35.140 --> 02:58:37.240
What is this actually doing, line 43?

02:58:39.040 --> 02:58:41.720
Yeah, so just like we're able to write to the console,

02:58:42.080 --> 02:58:44.880
we're actually able to read from the console as well.

02:58:44.940 --> 02:58:47.520
And so here, it's going to take whatever you've entered

02:58:47.520 --> 02:58:50.080
and assign it into that variable M,

02:58:50.900 --> 02:58:52.720
and then we'll check each time

02:58:52.720 --> 02:58:55.160
and we'll say, hey, as long as M is in Q,

02:58:55.940 --> 02:58:57.260
the user wants to keep going.

02:58:58.180 --> 02:58:59.680
And so we'll just continue the loop

02:58:59.680 --> 02:59:01.960
and we'll prompt the user each time

02:59:02.740 --> 02:59:05.080
until they enter Q, we'll just continue to do

02:59:05.080 --> 02:59:06.940
whatever work we're going to do inside that loop.

02:59:07.080 --> 02:59:09.240
Any questions at all on any of those examples?

02:59:13.820 --> 02:59:15.780
So real world inside this loop,

02:59:15.800 --> 02:59:16.800
what will we probably do?

02:59:16.800 --> 02:59:19.080
We would say, you know, enter a command, right?

02:59:19.440 --> 02:59:20.980
And so after we read that in,

02:59:20.980 --> 02:59:23.840
we would probably have a switch statement or a case statement.

02:59:23.940 --> 02:59:26.980
We would say, if they entered A, do this code.

02:59:27.020 --> 02:59:28.860
If they entered B, do this code.

02:59:29.760 --> 02:59:31.620
And as long as they didn't enter Q,

02:59:32.160 --> 02:59:34.040
we would do whatever they told us to do

02:59:34.040 --> 02:59:35.480
and then we would prompt them again.

02:59:35.700 --> 02:59:36.980
Enter the next command.

02:59:38.560 --> 02:59:40.480
So this is a more real world example

02:59:40.480 --> 02:59:43.180
of why you might want to do the do while.

02:59:45.100 --> 02:59:46.080
Hey, Shane. Yes.

02:59:47.940 --> 02:59:49.580
There's that warning,

02:59:49.880 --> 02:59:52.240
if that's what you want to call it online,

02:59:52.500 --> 02:59:55.080
your line 39 for 3 a.m.

02:59:56.360 --> 02:59:57.940
So the way I'm understanding that

02:59:57.940 --> 03:00:01.220
is that you really didn't have to define it empty.

03:00:01.600 --> 03:00:02.820
You could have just said 3 a.m.

03:00:02.920 --> 03:00:03.700
Yeah, absolutely.

03:00:04.120 --> 03:00:05.580
And you'll see here too,

03:00:05.640 --> 03:00:07.180
a lot of times if you get those messages,

03:00:07.860 --> 03:00:10.120
this little show potential fix option,

03:00:10.480 --> 03:00:12.380
if you click that, it would say like,

03:00:12.380 --> 03:00:14.840
hey, here's what it would look like if we removed that.

03:00:15.700 --> 03:00:17.960
And it'll actually fix the code for you.

03:00:20.200 --> 03:00:21.180
Yeah, great question.

03:00:22.060 --> 03:00:25.660
So to Lisa's point, sometimes you'll get errors, right?

03:00:25.660 --> 03:00:27.200
So you'll get like the red squigglies

03:00:27.200 --> 03:00:29.520
or your code won't build that type of thing.

03:00:30.260 --> 03:00:33.960
But Visual Studio also can look at your code overall

03:00:33.960 --> 03:00:36.260
and you'll see that it'll make suggestions like that.

03:00:36.260 --> 03:00:38.100
It'll say, hey, there's really no reason

03:00:38.100 --> 03:00:39.340
to assign a value here

03:00:39.340 --> 03:00:41.320
because you're going to check it anyways

03:00:41.320 --> 03:00:42.840
and you're not doing anything with it

03:00:42.840 --> 03:00:43.680
until you check it.

03:00:44.400 --> 03:00:47.700
So it's actually just saying your code will run,

03:00:47.740 --> 03:00:49.360
but here's a tip.

03:00:49.720 --> 03:00:52.700
You can actually avoid having to even assign a value

03:00:52.700 --> 03:00:53.200
to that.

03:00:53.500 --> 03:00:55.000
And in some cases, as you just saw,

03:00:55.040 --> 03:00:58.600
it'll actually offer an auto fix for you, right?

03:00:58.600 --> 03:01:00.920
Or offer a suggestion, a great call out.

03:01:02.040 --> 03:01:03.460
And you'll notice that as we go through there,

03:01:03.460 --> 03:01:05.260
there'll be these little tips and suggestions.

03:01:07.220 --> 03:01:09.080
Any other questions about the code,

03:01:09.220 --> 03:01:11.280
about loops, why we would do those

03:01:11.280 --> 03:01:13.640
or how we create those loops?

03:01:14.180 --> 03:01:16.620
Okay, so now we've learned

03:01:16.620 --> 03:01:20.040
sort of all the fundamental operators that are available

03:01:20.040 --> 03:01:22.680
to us and the ability to loop

03:01:22.680 --> 03:01:24.560
and the ability to check conditions.

03:01:24.980 --> 03:01:27.020
So this is kind of the tools that we'll need.

03:01:27.460 --> 03:01:29.100
The one piece we haven't talked about yet,

03:01:29.200 --> 03:01:30.280
we'll talk about right now.

03:01:30.300 --> 03:01:33.660
So let's take a look at what if I want to work

03:01:33.660 --> 03:01:35.100
with sets of data.

03:01:43.880 --> 03:01:46.060
A set is actually a thing in Python, right?

03:01:46.240 --> 03:01:47.700
I need to stop calling it that

03:01:47.700 --> 03:01:51.120
so that I don't confuse you with the Python lingo.

03:01:52.380 --> 03:01:53.440
We do have sets.

03:01:54.100 --> 03:01:56.720
I think we mostly get these in our framework

03:01:56.720 --> 03:02:00.320
or use like lists rather than sets.

03:02:00.680 --> 03:02:04.480
Okay, I just don't want to confuse the terminology

03:02:04.480 --> 03:02:06.840
too much because I'm using it just generically

03:02:06.840 --> 03:02:08.420
as if you have multiple things.

03:02:08.860 --> 03:02:11.060
So I'll try to...

03:02:12.300 --> 03:02:14.280
I'll try to avoid calling it something

03:02:14.280 --> 03:02:17.040
that might be something else in Python.

03:02:18.840 --> 03:02:20.980
Let's go ahead and take a look.

03:02:21.880 --> 03:02:23.620
So all the variables we've seen so far

03:02:23.620 --> 03:02:25.120
have been single values.

03:02:25.760 --> 03:02:27.760
And so the variable we're giving it a name

03:02:28.580 --> 03:02:30.020
and we're telling you what type of data

03:02:30.020 --> 03:02:31.120
we're going to store in there.

03:02:31.240 --> 03:02:34.420
And then we're able to put a single value in there.

03:02:35.400 --> 03:02:38.640
And sometimes you'll see it's very useful

03:02:38.640 --> 03:02:41.040
to work with related data.

03:02:41.700 --> 03:02:43.140
And so as an example,

03:02:43.720 --> 03:02:46.480
I have this variable here called even numbers

03:02:47.120 --> 03:02:50.080
and I would actually like to store multiple values

03:02:50.080 --> 03:02:51.480
in that variable, right?

03:02:51.520 --> 03:02:53.100
So not just one even number.

03:02:53.560 --> 03:02:55.220
As I find even numbers,

03:02:55.220 --> 03:02:58.240
I want to store them in this single variable

03:02:58.240 --> 03:03:02.460
so that I can work with them as a related group of data.

03:03:03.500 --> 03:03:04.600
So you're going to see,

03:03:04.660 --> 03:03:06.500
I still have to give it a name, right?

03:03:06.500 --> 03:03:07.140
Even numbers.

03:03:07.660 --> 03:03:10.540
I'm still declaring the type of data that I want to store.

03:03:10.660 --> 03:03:12.540
So I'm going to only store integers.

03:03:13.100 --> 03:03:14.420
So you still see the INT.

03:03:15.160 --> 03:03:16.720
But what you'll notice differently here

03:03:16.720 --> 03:03:19.700
is these brackets after that.

03:03:21.900 --> 03:03:23.820
So what I'm indicating with the brackets

03:03:23.820 --> 03:03:26.060
is I'm actually telling C-sharp,

03:03:26.400 --> 03:03:29.680
I'm going to store integer type data in this variable

03:03:29.680 --> 03:03:33.580
but I want to store multiple values in here.

03:03:34.180 --> 03:03:37.280
And so the brackets is how I'm indicating the C-sharp.

03:03:37.320 --> 03:03:39.320
There's going to be multiple values

03:03:39.320 --> 03:03:40.640
in this single variable.

03:03:41.740 --> 03:03:43.580
So that's the first thing that's going to be different.

03:03:44.320 --> 03:03:45.940
The second thing is going to be,

03:03:46.380 --> 03:03:50.660
how do I actually declare how many,

03:03:51.540 --> 03:03:53.220
how much data I'm going to store in there?

03:03:53.700 --> 03:03:55.300
So the second part of this you're going to see,

03:03:55.440 --> 03:03:57.600
we're going to assign to this

03:03:58.960 --> 03:04:00.680
and you're going to see this piece here,

03:04:00.720 --> 03:04:02.280
this new int five.

03:04:02.940 --> 03:04:06.440
So what I'm doing here is I need to say,

03:04:07.080 --> 03:04:08.480
I need so much space.

03:04:09.060 --> 03:04:12.640
Here's how many values I want to store in that variable.

03:04:13.600 --> 03:04:15.500
When I was storing just one value,

03:04:16.200 --> 03:04:18.340
C-sharp knows how big an integer is

03:04:18.340 --> 03:04:20.180
and knows how much space to set aside.

03:04:20.580 --> 03:04:22.100
And so I don't have to really tell it

03:04:22.100 --> 03:04:23.060
any more information.

03:04:23.740 --> 03:04:25.620
Here, I need to tell C-sharp

03:04:25.620 --> 03:04:27.880
how many values I'm going to store in there.

03:04:27.900 --> 03:04:31.180
So what I'll do is I have to use the new keyword

03:04:32.280 --> 03:04:35.300
so anytime I'm going to put values in an array,

03:04:35.440 --> 03:04:36.480
I have to use the new keyword.

03:04:37.420 --> 03:04:39.240
And new is basically telling C-sharp,

03:04:39.520 --> 03:04:41.700
hey, get ready to set aside some space for me.

03:04:42.600 --> 03:04:45.100
I have to tell it what type, right?

03:04:45.220 --> 03:04:49.380
So int, and then you're going to see here,

03:04:49.380 --> 03:04:52.680
I have to provide a value, a number saying,

03:04:52.940 --> 03:04:55.600
how many values do I want to store in here?

03:04:55.960 --> 03:04:57.960
So here I'm setting aside space

03:04:58.640 --> 03:05:01.760
to store five integer values.

03:05:03.940 --> 03:05:07.560
All right, so the big difference you're seeing here

03:05:07.560 --> 03:05:09.920
is that if I'm doing multiple values,

03:05:10.340 --> 03:05:12.160
I'm going to use the brackets to indicate

03:05:12.160 --> 03:05:13.660
that I'm using multiple values.

03:05:14.180 --> 03:05:16.000
I still have to set the data type.

03:05:16.160 --> 03:05:17.300
Still have to give it a name.

03:05:18.380 --> 03:05:20.680
And then I need to actually tell C-sharp

03:05:20.680 --> 03:05:23.100
to go ahead and set aside that space for me.

03:05:23.380 --> 03:05:25.540
And that's what this right side of this is doing.

03:05:25.620 --> 03:05:30.100
So this new int is saying I need some new space.

03:05:30.820 --> 03:05:33.080
I'm going to store integer data in there.

03:05:33.480 --> 03:05:37.340
And I want to be able to store up to five values in there.

03:05:38.300 --> 03:05:39.380
Any questions on that part

03:05:39.380 --> 03:05:41.860
before we take a look at how to use the data

03:05:41.860 --> 03:05:42.860
or put data in there?

03:05:43.720 --> 03:05:46.200
Is that five in the brackets there,

03:05:46.280 --> 03:05:47.760
is that different than the elements?

03:05:48.180 --> 03:05:52.620
Is that, like I see underneath that is element zero,

03:05:52.620 --> 03:05:56.580
O equals two, O is four, but it turns to zero.

03:05:57.840 --> 03:06:01.540
Is the new int four to include zero?

03:06:01.880 --> 03:06:02.820
Yeah, that's a great question.

03:06:03.580 --> 03:06:05.660
I'll go into that more as I talk about the next part.

03:06:05.860 --> 03:06:07.660
But yeah, so what the number you put in here is,

03:06:07.920 --> 03:06:10.760
is you're saying how many values or how many elements

03:06:10.760 --> 03:06:11.940
am I going to set aside?

03:06:12.540 --> 03:06:15.260
So in this case, I want to have five spaces

03:06:16.000 --> 03:06:18.100
or be able to store five values

03:06:18.100 --> 03:06:19.880
in my even numbers variable.

03:06:20.220 --> 03:06:22.020
And so that's what the five indicates here.

03:06:22.040 --> 03:06:24.760
If I wanted to store nine numbers,

03:06:25.180 --> 03:06:26.340
I would make that a nine.

03:06:26.340 --> 03:06:28.340
Oops, you got rid of the closing bracket.

03:06:29.660 --> 03:06:30.700
If I want to store 10.

03:06:31.780 --> 03:06:33.640
So the value you're putting in there

03:06:33.640 --> 03:06:37.540
is literally how many elements or how many values

03:06:37.540 --> 03:06:39.500
do I want to be able to store in this variable?

03:06:43.620 --> 03:06:44.300
Yeah, no, great question.

03:06:44.440 --> 03:06:45.360
Was that your question?

03:06:47.660 --> 03:06:50.080
Okay, and the other thing to keep in mind

03:06:50.080 --> 03:06:51.500
is that in C-sharp,

03:06:51.740 --> 03:06:55.400
some languages when you're working with multiple values,

03:06:55.900 --> 03:06:57.840
you don't really have to tell it how many

03:06:57.840 --> 03:07:00.160
and you can sort of just keep adding stuff

03:07:00.160 --> 03:07:01.180
or removing stuff.

03:07:02.080 --> 03:07:04.760
C-sharp does have that, but it's a little bit different.

03:07:04.880 --> 03:07:05.880
I'll show you that later.

03:07:06.700 --> 03:07:09.160
So with arrays, what we're calling this

03:07:09.160 --> 03:07:10.300
when you're using the brackets,

03:07:10.480 --> 03:07:13.600
with arrays, they're fixed size.

03:07:13.620 --> 03:07:14.920
You have to stay upfront.

03:07:15.960 --> 03:07:17.240
How much is this going to hold?

03:07:18.680 --> 03:07:21.460
And adding and removing them is,

03:07:22.060 --> 03:07:23.920
you're not able to add and remove.

03:07:23.920 --> 03:07:26.700
You can change the values that are assigned in there,

03:07:26.920 --> 03:07:28.420
but you're not able to create new spaces

03:07:28.420 --> 03:07:30.000
or remove spaces, right?

03:07:30.500 --> 03:07:32.800
So right up front, you have to know

03:07:32.800 --> 03:07:36.160
how much data am I going to use in storing this thing?

03:07:36.500 --> 03:07:38.580
And you have to declare that right up front.

03:07:39.300 --> 03:07:41.300
This is going to be integer data

03:07:41.300 --> 03:07:43.580
and I'm going to be able to hold five values.

03:07:45.420 --> 03:07:47.520
Why do we need to declare it twice?

03:07:49.200 --> 03:07:51.740
Why do you need to do the int part

03:07:51.740 --> 03:07:53.020
and then this part over here?

03:07:53.780 --> 03:07:53.960
Yeah.

03:07:54.940 --> 03:07:56.400
Because it's really two different things.

03:07:56.680 --> 03:07:59.900
You're basically, this is where you're telling it

03:07:59.900 --> 03:08:01.600
what it is and then the other side

03:08:01.600 --> 03:08:02.900
of the right side of this equals

03:08:02.900 --> 03:08:04.520
is where you're actually telling you

03:08:04.520 --> 03:08:05.680
to set aside the space.

03:08:06.240 --> 03:08:09.040
Remember earlier when, was it Dustin?

03:08:09.120 --> 03:08:10.380
Were you the one that asked about var?

03:08:14.680 --> 03:08:19.940
You actually could do, you could actually do var here

03:08:21.940 --> 03:08:24.200
and then C-sharp would take a look

03:08:24.200 --> 03:08:25.440
at what you're putting in there

03:08:25.440 --> 03:08:28.220
and it would actually make this a number array,

03:08:28.840 --> 03:08:29.620
an integer array.

03:08:34.200 --> 03:08:36.700
So this is sort of the, you have to be explicit

03:08:36.700 --> 03:08:38.260
and basically spell it out

03:08:38.260 --> 03:08:39.840
because it's really doing two things.

03:08:40.220 --> 03:08:42.080
This is saying what kind of data

03:08:42.080 --> 03:08:43.220
are you going to put in there?

03:08:43.420 --> 03:08:45.620
And then the second part is actually going to create

03:08:45.620 --> 03:08:47.080
the space for that data.

03:08:48.820 --> 03:08:51.120
I think that's what you're asking me, is that?

03:08:53.880 --> 03:08:54.320
Okay.

03:08:56.480 --> 03:08:58.120
So those are the two parts of it.

03:08:58.180 --> 03:09:00.220
You have to sort of declare up front what it is

03:09:00.220 --> 03:09:01.360
and then set aside the space.

03:09:01.940 --> 03:09:03.420
Now, once I've set this up,

03:09:03.560 --> 03:09:05.260
remember with my variables before,

03:09:05.260 --> 03:09:07.060
I was able to just use that variable name,

03:09:07.240 --> 03:09:07.800
even numbers.

03:09:08.460 --> 03:09:10.800
Now, because I have multiple values in there,

03:09:10.840 --> 03:09:13.300
I have to have some way to tell C-sharp

03:09:13.300 --> 03:09:15.640
which value am I talking about?

03:09:16.520 --> 03:09:21.280
So I set aside space for five values in here

03:09:23.080 --> 03:09:28.000
and C-sharp is going to start counting at zero, right?

03:09:28.080 --> 03:09:30.020
So even though I've set aside five spaces,

03:09:30.860 --> 03:09:34.240
that first space is going to be actually called space zero,

03:09:34.660 --> 03:09:36.860
then space one, then space two.

03:09:37.600 --> 03:09:39.400
So there's five spaces,

03:09:39.400 --> 03:09:42.300
but they number from starting at zero.

03:09:43.060 --> 03:09:44.260
So that can be kind of tricky

03:09:44.260 --> 03:09:46.960
if you're expecting that it's going to go from one to five.

03:09:48.120 --> 03:09:49.700
They count from zero to four.

03:09:50.960 --> 03:09:53.140
And then you see that just like when I declared it,

03:09:53.140 --> 03:09:54.460
I had to use those brackets.

03:09:55.300 --> 03:09:59.260
So when I want to refer to which value in that variable,

03:09:59.600 --> 03:10:01.200
I have to use those brackets

03:10:01.780 --> 03:10:05.460
and then I have to use a number that we call the index.

03:10:06.200 --> 03:10:09.620
And that tells us which value that I'm referring to.

03:10:11.940 --> 03:10:13.160
All right, so I know that was a lot.

03:10:13.160 --> 03:10:16.080
Are there any questions about that piece of it?

03:10:16.560 --> 03:10:17.780
I was going to ask Lillian

03:10:17.780 --> 03:10:19.020
and she didn't mind going on mute.

03:10:19.200 --> 03:10:20.560
I'm hearing her keyboard more.

03:10:20.560 --> 03:10:21.220
Oh, typing.

03:10:22.660 --> 03:10:23.400
That's okay.

03:10:26.340 --> 03:10:27.040
Not a problem.

03:10:29.320 --> 03:10:31.900
So this variable can hold multiple values.

03:10:31.940 --> 03:10:34.980
So we're going to use this number we'll call the index

03:10:34.980 --> 03:10:38.040
and that tells C-sharp which of those values

03:10:38.040 --> 03:10:39.220
are you talking about?

03:10:39.220 --> 03:10:43.220
So even numbers zero refers to the first value

03:10:43.220 --> 03:10:44.300
that we store in there.

03:10:44.740 --> 03:10:46.940
Even numbers one refers to the second value.

03:10:47.340 --> 03:10:49.740
So here what we're doing is we're saying assign

03:10:50.500 --> 03:10:52.740
that first value, we'll assign two

03:10:52.740 --> 03:10:56.280
and then the second value we're going to assign four,

03:10:56.480 --> 03:10:57.780
et cetera, right?

03:10:58.380 --> 03:11:02.800
So I declare it to be able to hold five integer values

03:11:02.800 --> 03:11:05.240
and then I can use those indexes

03:11:05.240 --> 03:11:08.820
to assign different values to that variable.

03:11:09.640 --> 03:11:11.640
Let's see, was there a question in the chat?

03:11:13.480 --> 03:11:14.600
Oh, perfect.

03:11:17.200 --> 03:11:18.900
And then to use those,

03:11:18.960 --> 03:11:22.260
just like I can use that index to assign values,

03:11:22.360 --> 03:11:23.820
I can also use that index

03:11:23.820 --> 03:11:25.220
when I'm referring to those values.

03:11:25.640 --> 03:11:28.540
So if I wanted to write out the value

03:11:28.540 --> 03:11:30.180
that's in that first position,

03:11:30.980 --> 03:11:35.480
I can use that zero index to write that value out.

03:11:35.940 --> 03:11:40.120
Same idea with the first, second, third, excuse me,

03:11:40.260 --> 03:11:40.880
fourth position.

03:11:43.080 --> 03:11:45.060
What if I tried to do something like this?

03:11:45.100 --> 03:11:46.480
So I have five values in there.

03:11:46.500 --> 03:11:48.520
What if I tried to do something like this

03:11:48.520 --> 03:11:52.200
on line 23 and write out even numbers five?

03:11:53.460 --> 03:11:55.640
Some sort of index exception,

03:11:55.900 --> 03:11:57.300
index doesn't exist exception.

03:11:57.960 --> 03:12:01.540
Absolutely, so you're basically trying to use an index

03:12:01.540 --> 03:12:04.520
that's out of the range of what you've assigned.

03:12:04.720 --> 03:12:06.720
You set aside these five values

03:12:07.220 --> 03:12:09.800
and so those indexes go from zero to four.

03:12:10.220 --> 03:12:12.160
So if you try to do something that's outside there

03:12:12.160 --> 03:12:14.620
like the five or even under there,

03:12:14.720 --> 03:12:17.100
like the negative one or something like that,

03:12:17.360 --> 03:12:18.440
that's going to say no.

03:12:18.520 --> 03:12:21.540
It's going to blow up when you run your code,

03:12:21.580 --> 03:12:22.960
you'll get some kind of an error message

03:12:22.960 --> 03:12:26.940
that says you're outside the range of those values.

03:12:29.380 --> 03:12:30.640
Okay, so let's take a look.

03:12:30.640 --> 03:12:32.340
So that's what was working with numbers.

03:12:32.820 --> 03:12:34.900
You can also do the same thing

03:12:35.620 --> 03:12:37.900
if you're using strings or other data types.

03:12:38.400 --> 03:12:41.600
So for example, here on line 29,

03:12:41.920 --> 03:12:44.180
I want to declare an array of strings.

03:12:44.240 --> 03:12:46.500
So I'll have that data type of string.

03:12:47.320 --> 03:12:49.440
I'm going to use that same brackets

03:12:50.020 --> 03:12:52.400
to let C-sharp know there's multiple values coming.

03:12:53.980 --> 03:12:56.480
I'm going to call that variable days of the week.

03:12:57.520 --> 03:12:59.960
And then the same idea, when I assign this,

03:13:00.080 --> 03:13:01.320
I'm going to have to tell C-sharp,

03:13:01.420 --> 03:13:04.260
I have to use that new keyword to tell C-sharp,

03:13:04.360 --> 03:13:06.080
go ahead, set aside space for this thing.

03:13:06.520 --> 03:13:10.420
I have to tell it to set aside the space

03:13:10.420 --> 03:13:13.200
and then I can also at the same time,

03:13:13.260 --> 03:13:14.920
remember when we declared our variables,

03:13:15.480 --> 03:13:18.520
we could also assign values to them at the same time.

03:13:19.200 --> 03:13:21.000
We can do the same thing with arrays.

03:13:21.260 --> 03:13:24.240
So here, I'm declaring this variable

03:13:24.240 --> 03:13:25.160
called days of the week.

03:13:25.760 --> 03:13:27.640
I'm setting aside that space.

03:13:28.040 --> 03:13:31.080
You'll notice I'm not providing a number here for string.

03:13:31.680 --> 03:13:33.420
It's actually going to look at the data

03:13:33.420 --> 03:13:34.840
that I'm assigning to that

03:13:34.840 --> 03:13:38.180
and it'll figure out the number based on that.

03:13:38.220 --> 03:13:40.740
So it's like, oh, here's these pieces of data

03:13:40.740 --> 03:13:41.600
you're giving me.

03:13:41.860 --> 03:13:44.240
So I'll go ahead and set aside the space

03:13:44.240 --> 03:13:45.600
for those pieces of data.

03:13:47.000 --> 03:13:48.540
And you're going to see also,

03:13:48.560 --> 03:13:51.580
it's using that same curly brace.

03:13:54.180 --> 03:13:56.120
Right, so curly brace syntax.

03:13:57.000 --> 03:13:58.760
Everything inside those curly braces

03:13:58.760 --> 03:14:00.020
is going to be the data

03:14:00.020 --> 03:14:03.060
that I'm assigning to my array of strings.

03:14:03.260 --> 03:14:07.040
And so again, I can do arrays

03:14:07.040 --> 03:14:08.460
with different types of data.

03:14:08.460 --> 03:14:10.480
They could be doubles, they could be integers,

03:14:10.740 --> 03:14:11.600
they could be strings.

03:14:12.380 --> 03:14:14.260
I'm going to have very similar syntax

03:14:14.260 --> 03:14:16.040
as far as I'll have to declare the type

03:14:16.040 --> 03:14:16.920
that I'm going to store

03:14:17.680 --> 03:14:20.940
and the brackets to indicate that it's multiple values.

03:14:20.940 --> 03:14:21.560
It's an array.

03:14:22.200 --> 03:14:26.660
And then I'm able to assign multiple values to those,

03:14:26.780 --> 03:14:29.000
either right at the time that I create that,

03:14:29.560 --> 03:14:31.040
or as you saw above,

03:14:31.200 --> 03:14:34.360
I can also then sort of individually assign values.

03:14:34.720 --> 03:14:37.540
I get the flexibility to do either way.

03:14:41.440 --> 03:14:43.540
And once I've created this array of strings,

03:14:43.680 --> 03:14:45.280
you're going to see I'm able to use that

03:14:45.280 --> 03:14:46.600
just like I did with the numbers.

03:14:47.340 --> 03:14:49.200
I'm just using the name of that variable.

03:14:49.880 --> 03:14:51.340
It's the days of the week.

03:14:51.640 --> 03:14:53.220
And then I can use that index

03:14:54.000 --> 03:14:55.700
to get that specific value.

03:14:56.680 --> 03:14:58.700
And the big thing to keep in mind here

03:14:58.700 --> 03:15:00.100
is just they start at zero.

03:15:00.480 --> 03:15:04.080
So it's a lot of times not as intuitive.

03:15:04.380 --> 03:15:07.000
You're thinking, oh, the first value in here

03:15:07.000 --> 03:15:08.000
should be one,

03:15:08.400 --> 03:15:10.320
but the first value is really zero.

03:15:10.420 --> 03:15:13.140
So zero, one, two, et cetera.

03:15:13.440 --> 03:15:14.540
Any questions on that part?

03:15:15.720 --> 03:15:18.320
So what's the advantage of using an array

03:15:18.320 --> 03:15:21.520
versus just declaring a regular variable and using that?

03:15:26.640 --> 03:15:27.260
In other words,

03:15:27.360 --> 03:15:29.760
like I could easily have declared day of the week, right?

03:15:29.780 --> 03:15:31.480
I just declared seven days of the week.

03:15:32.900 --> 03:15:34.620
Why would I do that in an array

03:15:34.620 --> 03:15:36.520
versus just declaring seven strings?

03:15:40.260 --> 03:15:42.320
You could take a dynamic route here,

03:15:42.420 --> 03:15:43.160
or any better.

03:15:43.760 --> 03:15:46.220
Just answer some of them.

03:15:46.700 --> 03:15:48.520
Yeah, so basically any time

03:15:48.520 --> 03:15:50.600
that I'm working with related data,

03:15:51.160 --> 03:15:54.020
it's very useful to be able to work with that data

03:15:54.520 --> 03:15:55.940
together as one thing.

03:15:56.560 --> 03:16:00.920
And so that's a common use of arrays, right?

03:16:01.140 --> 03:16:02.820
So since when I'm working with days of the week,

03:16:02.840 --> 03:16:03.580
for example,

03:16:04.800 --> 03:16:06.460
I'm gonna do something related

03:16:06.460 --> 03:16:07.800
with those days of the week,

03:16:08.440 --> 03:16:10.220
storing that in a single variable

03:16:10.220 --> 03:16:12.440
and just being able to use that whole

03:16:12.440 --> 03:16:15.400
set of related data can be very useful.

03:16:17.220 --> 03:16:20.680
Similarly, if I was reading in say grades for students,

03:16:21.140 --> 03:16:23.480
so each student maybe has multiple grades,

03:16:23.800 --> 03:16:26.520
it would be very useful to have all the grades

03:16:26.520 --> 03:16:30.140
for one student in a single variable that I can work with.

03:16:30.180 --> 03:16:31.840
Then I could maybe do some averages

03:16:31.840 --> 03:16:35.020
or I could figure out what's their overall grade,

03:16:35.040 --> 03:16:35.840
that type of thing.

03:16:36.320 --> 03:16:38.240
So anytime you have related data,

03:16:39.720 --> 03:16:41.540
using that data in an array

03:16:42.180 --> 03:16:45.580
is probably gonna be the approach that you'll take

03:16:45.580 --> 03:16:47.900
so that you're working with that data in the same way.

03:16:48.280 --> 03:16:49.140
So let's take an example.

03:16:49.440 --> 03:16:51.500
So we saw looping with for loops

03:16:51.500 --> 03:16:53.020
and we've seen arrays now.

03:16:53.440 --> 03:16:55.240
Let's bring those together and show you.

03:16:55.260 --> 03:16:56.420
So as an example,

03:16:57.740 --> 03:16:59.220
I've got those days of the week

03:16:59.220 --> 03:17:00.760
and I could have worked with those

03:17:00.760 --> 03:17:01.900
sort of individually, right?

03:17:01.900 --> 03:17:04.160
Day one, day two, day three, et cetera.

03:17:05.660 --> 03:17:08.280
But I can also use a loop,

03:17:08.420 --> 03:17:09.660
take advantage of using a loop

03:17:09.660 --> 03:17:12.020
to work with all of the data

03:17:12.020 --> 03:17:14.500
that's stored in that single array variable.

03:17:15.880 --> 03:17:18.380
So here I've got a loop on line 43

03:17:18.900 --> 03:17:20.920
and I'm gonna start that at zero.

03:17:21.420 --> 03:17:23.160
And what I'll do is I'll just look

03:17:23.160 --> 03:17:25.700
and as long as I haven't reached the end of the array,

03:17:25.740 --> 03:17:27.120
as long as they still have data,

03:17:27.920 --> 03:17:31.240
I'll just continue moving forward to the next element

03:17:32.180 --> 03:17:33.500
and doing something with those.

03:17:33.500 --> 03:17:34.920
So here I'll start at zero

03:17:35.420 --> 03:17:36.820
and I'll check and say,

03:17:36.820 --> 03:17:39.800
as long as I'm not over seven,

03:17:40.020 --> 03:17:41.500
as long as I'm less than seven,

03:17:42.100 --> 03:17:47.040
I'll go ahead and write out that value at that index.

03:17:47.780 --> 03:17:49.100
So I'll write out,

03:17:49.260 --> 03:17:52.280
it'll start out doing days of the week zero.

03:17:53.180 --> 03:17:55.640
Then it'll check, is that less than seven?

03:17:56.120 --> 03:17:59.380
If it is, it'll move my index to one

03:17:59.380 --> 03:18:02.020
and then it would write out days of the week one.

03:18:02.900 --> 03:18:04.280
And so this way with a loop,

03:18:04.280 --> 03:18:07.620
I can very easily take all that related data

03:18:07.620 --> 03:18:10.060
that's in the days of the week array

03:18:10.740 --> 03:18:16.620
and I can run some code for each item that's in that array.

03:18:16.760 --> 03:18:18.440
So this is a very common pattern.

03:18:18.640 --> 03:18:20.520
Now, again, I could easily work

03:18:20.520 --> 03:18:22.280
with those individually, right?

03:18:22.540 --> 03:18:25.140
But typically when you're working with related data,

03:18:25.180 --> 03:18:27.560
you're trying to do some related thing with that data.

03:18:27.900 --> 03:18:33.320
And so I'm able to very easily loop through that array

03:18:33.860 --> 03:18:36.600
and for each element that's in the array,

03:18:37.420 --> 03:18:40.000
I can do something, some operation.

03:18:40.140 --> 03:18:42.280
So here I'm gonna just print out the value

03:18:42.280 --> 03:18:44.200
that's in that element.

03:18:45.960 --> 03:18:48.720
And I'm gonna make sure that I'm still inside the array.

03:18:48.800 --> 03:18:50.300
I haven't gone past the end of it, right?

03:18:50.320 --> 03:18:52.740
So as long as this index is less than seven,

03:18:53.180 --> 03:18:55.480
I'll continue to move to the next item.

03:18:56.120 --> 03:18:57.060
Any questions on that part?

03:18:57.220 --> 03:18:59.760
So I'm just doing that inside a loop

03:18:59.760 --> 03:19:03.280
and basically shorting the amount of code

03:19:03.280 --> 03:19:04.040
that I would write,

03:19:04.540 --> 03:19:07.360
but I'm also making sure that I'm doing the same thing

03:19:07.360 --> 03:19:11.240
for every item that's in that array, okay.

03:19:12.500 --> 03:19:15.000
It turns out this is such a common thing

03:19:15.000 --> 03:19:17.740
that there's actually a shorter way to write this

03:19:17.740 --> 03:19:19.840
as well or a more convenient way.

03:19:19.880 --> 03:19:21.880
So here, what's the challenge with this?

03:19:22.000 --> 03:19:24.640
I have to make sure that I pick the right value here.

03:19:24.960 --> 03:19:27.820
If I accidentally pick a larger value

03:19:27.820 --> 03:19:30.580
or maybe the data in my array changes,

03:19:31.600 --> 03:19:33.820
this is gonna blow up potentially.

03:19:33.840 --> 03:19:35.220
It's gonna have an error, right?

03:19:35.440 --> 03:19:38.500
If I try to read past where that data is at.

03:19:39.800 --> 03:19:42.520
So since this is such a common thing to do

03:19:42.520 --> 03:19:43.960
to be able to read sets of data,

03:19:45.220 --> 03:19:48.880
I can actually take advantage of every array

03:19:48.880 --> 03:19:52.180
actually has information as part of the array

03:19:52.180 --> 03:19:55.300
about how big it is, how many items are in there.

03:19:55.960 --> 03:19:58.940
So I can actually, instead of hard coding that

03:19:58.940 --> 03:20:00.520
or writing that number in,

03:20:01.020 --> 03:20:05.260
I can actually say the name of the array dot length,

03:20:06.260 --> 03:20:11.140
and that will tell me how many things are in that array.

03:20:13.180 --> 03:20:14.840
So the advantage that I'm getting there

03:20:14.840 --> 03:20:16.700
is I don't have to know up front

03:20:17.700 --> 03:20:19.460
or hard code that number.

03:20:20.140 --> 03:20:24.480
I can rely on whatever amount of items are in that array

03:20:25.160 --> 03:20:25.940
I'll just loop.

03:20:26.020 --> 03:20:29.680
And as long as I'm not past the end of that length,

03:20:30.600 --> 03:20:34.000
I can continue looping and print out the current value.

03:20:35.640 --> 03:20:38.340
So it's just the name of that variable

03:20:38.960 --> 03:20:41.320
and then the period, the dot,

03:20:42.680 --> 03:20:45.500
and length is what we're looking for.

03:20:45.500 --> 03:20:48.100
Length will tell us for that array

03:20:48.920 --> 03:20:50.580
how many items are in there.

03:20:50.580 --> 03:20:52.160
Again, either one will work.

03:20:52.160 --> 03:20:54.380
You can do either approach.

03:20:55.520 --> 03:20:56.800
Using that dot length

03:20:56.800 --> 03:20:58.500
is just a little bit more bulletproof

03:20:58.500 --> 03:21:00.940
in the sense that you don't have to worry

03:21:00.940 --> 03:21:02.360
about that number being right.

03:21:03.320 --> 03:21:05.900
C-sharp knows how many items are in that array.

03:21:06.700 --> 03:21:09.460
And so C-sharp knows what the length of that array is.

03:21:09.820 --> 03:21:11.580
And so you can take advantage of that

03:21:12.140 --> 03:21:14.920
and then you don't have to write that hard coded value.

03:21:15.060 --> 03:21:17.220
And then you also get the flexibility

03:21:17.220 --> 03:21:18.860
that if the data in that changes,

03:21:18.860 --> 03:21:21.820
if there's more data than you're expecting or less data,

03:21:22.240 --> 03:21:23.740
you're not gonna have an error.

03:21:23.780 --> 03:21:25.580
Your code is gonna handle that situation.

03:21:26.600 --> 03:21:28.580
Okay, so let's take a look down.

03:21:29.240 --> 03:21:31.820
I'll show you yet another approach,

03:21:32.300 --> 03:21:34.680
another loop that you can do with that as well.

03:21:35.060 --> 03:21:36.580
So we've seen the for loop.

03:21:37.220 --> 03:21:39.000
There's also a for each.

03:21:39.140 --> 03:21:43.400
So in C-sharp, all of the data we're defining up front,

03:21:43.400 --> 03:21:45.540
we have to say what type of data it is,

03:21:45.640 --> 03:21:47.600
what type of data is going in this variable.

03:21:48.320 --> 03:21:52.840
So as a result, when we're looping on through this array,

03:21:54.060 --> 03:21:57.140
C-sharp knows already the type of data that's in there

03:21:57.140 --> 03:21:59.060
and it knows how to loop through that data.

03:21:59.720 --> 03:22:02.160
And so you can actually do this as well.

03:22:02.180 --> 03:22:04.300
You can just use a for each.

03:22:06.000 --> 03:22:08.820
You can say, I wanna get the string values

03:22:08.820 --> 03:22:09.880
from this array.

03:22:10.900 --> 03:22:14.380
So you're declaring a variable that'll hold the value

03:22:14.380 --> 03:22:16.920
for each value in that array.

03:22:17.640 --> 03:22:20.600
So I wanna get a string value, I'll call it day,

03:22:21.960 --> 03:22:23.840
in and then the name of that array.

03:22:24.200 --> 03:22:27.120
And so what's happening here is the runtime.

03:22:27.140 --> 03:22:31.240
C-sharp is actually handling most of the work for you.

03:22:31.600 --> 03:22:32.900
It handles the looping.

03:22:33.180 --> 03:22:35.440
It's handling moving from one item

03:22:35.440 --> 03:22:36.800
in that array to the next.

03:22:37.300 --> 03:22:39.740
And as it moves, it's automatically gonna take

03:22:39.740 --> 03:22:44.580
that current item, assign that into the day variable,

03:22:45.060 --> 03:22:47.660
and then you can just write out the day.

03:22:49.580 --> 03:22:51.360
So again, all these approaches

03:22:51.360 --> 03:22:53.380
that are doing the same thing ultimately, right?

03:22:53.380 --> 03:22:55.360
They're allowing you to loop through an array

03:22:55.360 --> 03:22:58.220
and work with the multiple values that are stored in it.

03:22:59.380 --> 03:23:02.140
You're just getting some different ways to do that.

03:23:02.160 --> 03:23:04.540
And so if you're just working with the value

03:23:04.540 --> 03:23:06.060
and you don't care about the index,

03:23:06.480 --> 03:23:07.940
if all you need to do is go,

03:23:08.140 --> 03:23:09.860
I need to loop through that array

03:23:09.860 --> 03:23:13.120
and work with the values that are in that array,

03:23:13.120 --> 03:23:15.520
then you really don't care about the index

03:23:15.520 --> 03:23:17.660
and all that other sort of overhead, right?

03:23:18.460 --> 03:23:22.060
This for each will handle all of that work for you.

03:23:22.900 --> 03:23:25.140
And basically, we'll just give you,

03:23:25.360 --> 03:23:28.780
it'll loop one time for every item that's in that array.

03:23:29.540 --> 03:23:32.240
It'll automatically assign that value

03:23:32.240 --> 03:23:33.780
of that item into a variable.

03:23:34.220 --> 03:23:36.780
And then you can simply just use that value.

03:23:37.020 --> 03:23:38.880
And any questions on those three different approaches?

03:23:40.040 --> 03:23:42.300
Okay, so you're just getting some different ways

03:23:42.300 --> 03:23:44.280
that you can work with the same set of data.

03:23:44.680 --> 03:23:46.640
And it really, what you use really depends upon

03:23:46.640 --> 03:23:47.920
what you're trying to do with the data.

03:23:48.900 --> 03:23:51.460
If all you need to do is work with the values,

03:23:52.060 --> 03:23:55.540
then this line 59 is gonna provide those values to you

03:23:55.540 --> 03:23:57.180
and they're already set up in a variable

03:23:57.180 --> 03:23:58.580
that you can just simply use.

03:23:59.020 --> 03:24:01.420
So you can actually just write that or read that,

03:24:01.480 --> 03:24:02.420
whatever you need to do with it.

03:24:03.280 --> 03:24:07.000
If you do need to count or you do need to know

03:24:07.000 --> 03:24:09.480
where your current position in that array is,

03:24:09.940 --> 03:24:11.620
then you're gonna wanna keep track of that index.

03:24:11.620 --> 03:24:13.680
And so you maybe wanna do something

03:24:13.680 --> 03:24:15.160
like we're doing on line 51,

03:24:15.340 --> 03:24:18.120
where you're setting up that loop ahead of time

03:24:18.120 --> 03:24:21.480
and you're moving one step at a time through there

03:24:21.480 --> 03:24:23.700
and you're keeping track each time you move

03:24:23.700 --> 03:24:25.420
of what that current position is.

03:24:25.840 --> 03:24:28.940
Why might it matter knowing what position you are?

03:24:29.320 --> 03:24:32.100
So if I have like this days of the week, for example,

03:24:32.840 --> 03:24:33.960
why would it matter?

03:24:34.980 --> 03:24:37.180
Why wouldn't I just be able to use the values?

03:24:37.260 --> 03:24:39.660
Why would I care that this is the value

03:24:39.660 --> 03:24:40.740
from the third position

03:24:40.740 --> 03:24:42.860
or this is the value from the fifth position?

03:24:46.680 --> 03:24:47.800
Can you think of an example

03:24:47.800 --> 03:24:49.380
where that might make a difference?

03:24:52.760 --> 03:24:54.040
So think about this.

03:24:54.620 --> 03:24:56.340
If I had, say I was storing,

03:24:57.680 --> 03:25:02.100
I was gonna store like last names, for example.

03:25:02.440 --> 03:25:07.040
And so I was gonna store last names of athletes

03:25:07.040 --> 03:25:08.940
into a variable, into an array.

03:25:09.720 --> 03:25:11.640
If I just need to display,

03:25:11.640 --> 03:25:13.620
here's all the names of the athletes,

03:25:14.120 --> 03:25:15.240
I wouldn't need the index.

03:25:15.300 --> 03:25:16.580
I could just loop through there

03:25:16.580 --> 03:25:18.900
and just display the values that are in there.

03:25:19.500 --> 03:25:22.900
But maybe the athletes compete in a certain order.

03:25:23.300 --> 03:25:25.320
So I need to know who's the first to compete

03:25:25.320 --> 03:25:26.600
and who's the second to compete,

03:25:26.740 --> 03:25:27.660
who's the third to compete.

03:25:28.120 --> 03:25:31.140
So in that case, I actually do care about the position.

03:25:31.480 --> 03:25:33.940
I need to know if it's the first element

03:25:33.940 --> 03:25:36.260
or the second element or the third element, right?

03:25:36.580 --> 03:25:38.680
So if you do need to know that information,

03:25:39.260 --> 03:25:41.100
then that's why you would need that index.

03:25:41.920 --> 03:25:43.160
If you just need to display,

03:25:43.280 --> 03:25:45.540
here's the names of everybody, all the athletes,

03:25:46.160 --> 03:25:47.440
you don't really need that position.

03:25:47.560 --> 03:25:48.940
So you could just loop through

03:25:48.940 --> 03:25:51.280
and use the foreach to get the values.

03:25:52.520 --> 03:25:55.140
All right, let's take a look at one last thing.

03:25:55.580 --> 03:25:57.060
And we don't use this as often,

03:25:57.060 --> 03:25:58.560
but I do want you to be aware,

03:25:59.120 --> 03:26:00.680
depending on the data you're working with,

03:26:00.700 --> 03:26:01.560
you might run into this.

03:26:02.220 --> 03:26:05.740
So just be aware that arrays actually

03:26:06.500 --> 03:26:09.220
can be multiple dimensions.

03:26:09.360 --> 03:26:10.880
So what I mean by this is

03:26:10.880 --> 03:26:14.600
you can actually have an array of arrays.

03:26:15.260 --> 03:26:16.900
Not super common necessarily,

03:26:16.980 --> 03:26:19.360
it just depends entirely on the data you're working with,

03:26:19.700 --> 03:26:21.460
but sometimes it might be useful.

03:26:22.320 --> 03:26:25.160
So on line 66 here, for example,

03:26:25.280 --> 03:26:26.940
we've got temperatures in Celsius.

03:26:27.900 --> 03:26:31.920
You'll notice that the declaration for that,

03:26:32.460 --> 03:26:34.100
so I've still got the data type

03:26:34.100 --> 03:26:36.900
and then I've got the brackets there,

03:26:37.300 --> 03:26:39.260
but I have a comma in there.

03:26:39.420 --> 03:26:40.940
And that comma is basically,

03:26:42.040 --> 03:26:43.160
if you wanna think about it,

03:26:43.380 --> 03:26:45.640
it's in between the indexes, right?

03:26:45.640 --> 03:26:46.920
So this is basically saying,

03:26:47.400 --> 03:26:51.300
I've got two indexes into my array.

03:26:52.800 --> 03:26:54.800
And if you look at this array,

03:26:56.000 --> 03:26:58.440
so the array is here on line 66,

03:26:59.240 --> 03:27:00.900
goes down to line 69,

03:27:01.620 --> 03:27:05.000
and in between line 67,

03:27:05.000 --> 03:27:09.720
this is the first index in my array, right?

03:27:10.100 --> 03:27:12.440
And then here's that first index.

03:27:12.480 --> 03:27:15.400
So I've got two sets of data

03:27:16.060 --> 03:27:19.080
and then each of those sets of data is also an array.

03:27:19.800 --> 03:27:22.440
So they're individually an array as well.

03:27:23.340 --> 03:27:24.460
And the example we're giving you here

03:27:24.460 --> 03:27:26.160
is that maybe you have temperatures

03:27:26.160 --> 03:27:29.180
and you're grouping them by month, right?

03:27:29.180 --> 03:27:32.540
So the first index in this array

03:27:32.540 --> 03:27:34.660
is gonna be all the temperatures for January

03:27:35.340 --> 03:27:37.760
and then that'll be the individual temperatures

03:27:38.380 --> 03:27:39.600
for days in January.

03:27:40.920 --> 03:27:42.460
Obviously, there's more days in January

03:27:42.460 --> 03:27:44.280
than I'm showing you in here.

03:27:44.740 --> 03:27:46.840
And then the second week of January,

03:27:47.100 --> 03:27:49.140
this might be the second week as well.

03:27:51.220 --> 03:27:55.420
So it's entirely possible if you have related data,

03:27:56.220 --> 03:28:00.600
you can have an array that actually contains arrays.

03:28:01.760 --> 03:28:02.900
So you might wanna say,

03:28:03.260 --> 03:28:04.540
if I might wanna move through

03:28:04.540 --> 03:28:06.260
those individual weeks of January,

03:28:06.840 --> 03:28:09.060
and then I might wanna be able to get the temperatures

03:28:09.060 --> 03:28:10.860
for each day of that week.

03:28:11.580 --> 03:28:14.020
Again, this isn't something that's extremely common,

03:28:14.040 --> 03:28:14.820
but it does happen,

03:28:14.840 --> 03:28:17.320
so I just wanna make you aware that if you see that,

03:28:17.740 --> 03:28:19.960
that's what's happening is that each element

03:28:19.960 --> 03:28:22.320
in that array is actually its own array.

03:28:23.100 --> 03:28:25.920
And in order to be able to get data in there,

03:28:26.320 --> 03:28:30.480
you have to provide two indexes, right?

03:28:30.820 --> 03:28:32.760
So if I wanna get a specific day,

03:28:33.580 --> 03:28:34.900
I'm saying one comma two.

03:28:34.940 --> 03:28:40.040
So that's gonna say line 67 is my zero element,

03:28:40.940 --> 03:28:42.740
line 68 is my one element.

03:28:42.860 --> 03:28:46.480
So that one is telling me go to this element.

03:28:46.600 --> 03:28:51.420
And then within that, go to the second index, right?

03:28:51.420 --> 03:28:56.500
So there's the zero, the one, and the two, right?

03:28:56.700 --> 03:28:59.760
Again, not common,

03:28:59.820 --> 03:29:01.840
just depends entirely on the data you're working with,

03:29:01.860 --> 03:29:04.740
but just be aware that you can hold arrays

03:29:05.220 --> 03:29:07.160
that have other array data.

03:29:09.560 --> 03:29:11.680
So probably the syntax on this one

03:29:11.680 --> 03:29:14.100
is gonna be the most confusing, I feel like,

03:29:14.100 --> 03:29:15.800
when you're looking at the syntax for that.

03:29:16.200 --> 03:29:18.200
The key takeaways are that arrays

03:29:18.200 --> 03:29:19.580
lie for multiple values.

03:29:19.580 --> 03:29:22.100
You still have to declare the data type for those.

03:29:22.820 --> 03:29:26.280
You're gonna declare those using that new keyword, right?

03:29:26.300 --> 03:29:28.360
So that you know to set aside that,

03:29:28.440 --> 03:29:30.160
C Sharp knows to set aside that space.

03:29:32.520 --> 03:29:36.300
You do get the ability to provide data to that array

03:29:38.100 --> 03:29:42.220
and that using loops is a very common pattern

03:29:42.220 --> 03:29:43.700
or a very common way to work

03:29:43.700 --> 03:29:45.580
with the data that's inside your array.

03:29:45.920 --> 03:29:47.280
Let's take a look at an activity

03:29:47.280 --> 03:29:48.720
we're gonna use arrays

03:29:50.440 --> 03:29:52.380
and then we'll be pretty close

03:29:52.380 --> 03:29:54.600
to our final activity for the day here.

03:30:13.780 --> 03:30:15.060
So in this activity,

03:30:15.060 --> 03:30:17.860
we're gonna have you loop through some months,

03:30:18.020 --> 03:30:18.940
an array of months,

03:30:19.820 --> 03:30:20.940
and then we're gonna calculate

03:30:20.940 --> 03:30:23.520
and display the average temperature for the month.

03:30:23.900 --> 03:30:27.540
So we'll have you loop through that month names array,

03:30:29.040 --> 03:30:30.340
display that name of that month,

03:30:31.720 --> 03:30:33.760
and then calculate and display

03:30:33.760 --> 03:30:35.800
the average temperature for that month.

03:30:37.780 --> 03:30:41.000
And sample output we're showing you here.

03:30:41.800 --> 03:30:42.960
So for January,

03:30:43.480 --> 03:30:47.040
we're gonna find the average temperature for January,

03:30:47.660 --> 03:30:50.720
display that, do the same thing for April, right?

03:30:50.720 --> 03:30:51.680
So as we loop through,

03:30:51.680 --> 03:30:54.300
we're gonna do January, April, July, October,

03:30:54.300 --> 03:30:55.880
and then for each of those months,

03:30:55.900 --> 03:30:58.560
we're gonna have to find the average

03:30:59.260 --> 03:31:00.640
of those temperatures.

03:31:04.360 --> 03:31:06.940
And look at the starter codes.

03:31:09.760 --> 03:31:17.060
Let me just move this window for a second here.

03:31:18.660 --> 03:31:21.060
Still hiding behind the window there, there we go.

03:31:22.900 --> 03:31:24.460
And so if you look at the starter code,

03:31:26.080 --> 03:31:27.220
you're gonna see that we're giving you

03:31:27.220 --> 03:31:28.620
some of the data up front.

03:31:28.680 --> 03:31:30.440
So we're giving you the month names,

03:31:31.100 --> 03:31:32.460
we're giving you those temperatures,

03:31:32.940 --> 03:31:34.600
and then our to-do steps

03:31:34.600 --> 03:31:36.920
are basically walking you through

03:31:36.920 --> 03:31:38.280
the pieces that you'll need to write

03:31:38.280 --> 03:31:39.500
in order to be able to do that.

03:31:39.920 --> 03:31:41.500
So to be able to loop through the months,

03:31:42.440 --> 03:31:43.540
display the name of the month,

03:31:44.500 --> 03:31:46.240
calculate, display the average temperature.

03:31:49.000 --> 03:31:50.060
Was there a question in the chat?

03:31:58.600 --> 03:32:00.140
Oh, okay, Hari's just letting us know.

03:32:00.360 --> 03:32:03.240
So Hari, the final activity isn't any new concept.

03:32:03.280 --> 03:32:04.560
It's basically gonna bring together

03:32:04.560 --> 03:32:06.660
all of the stuff we've done throughout today.

03:32:07.560 --> 03:32:10.000
So just take a look and try that activity yourself

03:32:10.000 --> 03:32:12.000
if you won't be with us for that activity.

03:32:20.820 --> 03:32:22.500
I'll message him, let him know that.

03:32:23.700 --> 03:32:25.160
All right, so let's take a look at this activity

03:32:25.160 --> 03:32:26.840
and we'll spend,

03:32:26.960 --> 03:32:28.340
I think it's a little bit more time on this one.

03:32:28.340 --> 03:32:29.760
It's about 15 minutes.

03:32:30.160 --> 03:32:34.180
So we'll go probably till like five after maybe.

03:32:42.180 --> 03:32:42.620
Okay.

03:32:42.700 --> 03:32:44.840
Actually, I don't know if I have contact info for Hari.

03:32:44.860 --> 03:32:47.680
So if one of you could just message Hari

03:32:47.680 --> 03:32:50.060
to let him know about that last activity.

03:32:50.240 --> 03:32:52.480
The final one we'll do is no, not new material.

03:32:52.920 --> 03:32:57.040
It's just gonna be bringing together everything, so.

03:32:57.980 --> 03:32:59.040
I'll message him.

03:32:59.980 --> 03:33:00.640
Perfect, thanks.

03:33:19.560 --> 03:33:20.960
Okay.

03:33:51.420 --> 03:33:52.820
Okay.

03:34:20.300 --> 03:34:21.700
Okay.

03:34:58.340 --> 03:34:59.740
Okay.

03:35:17.940 --> 03:35:19.340
Okay.

03:35:50.300 --> 03:35:51.700
Okay.

03:36:21.880 --> 03:36:23.280
Okay.

03:36:54.700 --> 03:36:56.100
Okay.

03:37:17.940 --> 03:37:19.340
Okay.

03:37:47.680 --> 03:37:49.080
Okay.

03:38:06.040 --> 03:38:06.400
Okay.

03:38:06.920 --> 03:38:08.060
Yeah, ready, go.

03:38:22.260 --> 03:38:23.780
Is there an answer?

03:38:24.740 --> 03:38:25.120
Yes.

03:38:26.160 --> 03:38:26.880
Quick question.

03:38:27.660 --> 03:38:31.260
Is, and we're talking about the answers to this,

03:38:31.260 --> 03:38:41.600
Is there a way to determine the length of an array, like the first array length?

03:38:43.520 --> 03:38:45.460
I know what you're asking.

03:38:47.220 --> 03:38:47.840
I know what you're asking.

03:38:49.260 --> 03:38:52.160
I don't know, get into it faster or get into it faster.

03:38:52.760 --> 03:38:54.360
Yeah, it is kind of a trick question.

03:38:54.420 --> 03:38:59.600
I'll show you when we get to it, but when you have those that have multiple dimensions,

03:38:59.600 --> 03:39:04.500
it's a little trickier to get the length than it is normally.

03:39:04.520 --> 03:39:08.680
I figured it was, but I was like, at the end of it, I was getting ready to start Googling it,

03:39:08.740 --> 03:39:11.500
and I thought, oh wait a minute, maybe I'll just wait and see what you guys say.

03:39:12.600 --> 03:39:14.580
Google's your friend, Google's your friend, absolutely.

03:39:18.180 --> 03:39:18.760
Google, Google.

03:39:22.380 --> 03:39:24.620
Okay, let's take a look here.

03:39:28.840 --> 03:39:30.740
Let's see, am I sharing the right one?

03:39:31.480 --> 03:39:31.840
Okay.

03:39:46.020 --> 03:39:51.820
So one of the things I like, I'm really happy about this class, excited that the questions that you're asking are fantastic.

03:39:51.820 --> 03:39:55.420
And so you're thinking about the right kinds of things, right?

03:39:56.500 --> 03:40:01.640
So here we've got, we're starting out with month names and we've got the temperature there in Fahrenheit.

03:40:02.600 --> 03:40:06.640
And what we're trying to do is display a couple of different things, right?

03:40:06.640 --> 03:40:10.040
So we want to be able to loop through the months and display those.

03:40:11.680 --> 03:40:15.840
And so since we have those variables that month names declared,

03:40:16.820 --> 03:40:21.240
we can actually just loop, do a loop to get the names of those months, right?

03:40:21.240 --> 03:40:28.940
So we can do a for loop and just do something like, you know, I equals zero.

03:40:29.220 --> 03:40:35.860
And then as long as that's less than, you know, the month names that we have.

03:40:37.620 --> 03:40:41.140
It's funny, VSPR Visual Studio is actually trying to write the code for me there.

03:40:41.780 --> 03:40:48.660
So as long as that's less than the length, then we'll go ahead and be able to loop through those.

03:40:49.520 --> 03:40:51.040
So we're just going to start at zero.

03:40:51.620 --> 03:40:58.200
And as long as there are indexes less than that length, we can just increment that or we can move through that.

03:40:58.280 --> 03:41:00.140
So that'll start here at zero.

03:41:00.820 --> 03:41:04.840
And we can just print that name, January, April, July, October.

03:41:06.480 --> 03:41:10.100
So we could do something like console.

03:41:11.900 --> 03:41:13.580
And then we can do write line.

03:41:17.660 --> 03:41:20.940
And then in order to write that out, I'll have to do the name of the month, right?

03:41:21.040 --> 03:41:22.020
So month names.

03:41:23.120 --> 03:41:31.540
And then I'll just use that index value and write that out.

03:41:31.540 --> 03:41:39.480
So as that index moves from zero through that array, I'll be able to write out those names of the month.

03:41:40.820 --> 03:41:41.880
Was there a question in chat?

03:41:44.080 --> 03:41:44.920
No, not a question.

03:41:45.180 --> 03:41:47.360
Oh, perfect.

03:41:48.360 --> 03:41:52.020
OK, so this will allow us to move through those names.

03:41:52.720 --> 03:41:56.980
I think everybody, as I was moving around between the monitors, everybody was able to get this part.

03:41:56.980 --> 03:42:05.840
So you're able to take that array, you know, use the dot length and move through that array to get those different name values.

03:42:07.080 --> 03:42:09.740
So that's going to handle sort of the first part of this.

03:42:09.740 --> 03:42:11.320
So that covers this.

03:42:12.500 --> 03:42:19.880
Actually, these two rights are looping through as well as displaying the name of that.

03:42:19.880 --> 03:42:25.740
So now the challenge is then how do I get those average temperatures for the months?

03:42:27.300 --> 03:42:35.400
So each of these arrays or each of these elements in that temperature array is going to represent a month.

03:42:36.040 --> 03:42:40.140
So that's going to be our January, our April's line 13, right?

03:42:40.180 --> 03:42:43.860
Line 14 will be July and line 15 will be October.

03:42:44.500 --> 03:42:47.660
So I need to be able to loop through those sets of values.

03:42:47.660 --> 03:42:53.420
And then I also want to be able to loop through the values for each month.

03:42:54.940 --> 03:42:59.020
So the question when you were asking earlier was, hey, I can do dot length here.

03:42:59.160 --> 03:43:04.500
Is there a simple way to do the same thing when I've got the two dimensions?

03:43:05.200 --> 03:43:07.420
It's not quite as simple, right?

03:43:07.460 --> 03:43:11.140
It's actually a little bit trickier, but I'm going to try a different approach.

03:43:11.260 --> 03:43:12.780
I'm actually going to do this.

03:43:13.460 --> 03:43:19.260
This right here, this index is already doing the first part for you, right?

03:43:20.400 --> 03:43:23.420
So this is already going through the months, the four months.

03:43:23.980 --> 03:43:26.120
So this will actually do the same thing.

03:43:26.120 --> 03:43:28.900
It'll actually loop me through the four sets of data.

03:43:29.980 --> 03:43:38.220
So all I need to do is in each set, I need to just get the right values, right, temperature values for that month.

03:43:38.220 --> 03:43:42.720
So if I want to get January and then I'll get April and July and October.

03:43:43.560 --> 03:43:45.840
So what I'll do actually in here.

03:43:47.480 --> 03:43:51.900
Is I'll just loop through the data for that.

03:43:53.280 --> 03:43:55.820
That set of the daily temperatures, right?

03:43:55.940 --> 03:43:59.920
So in here, I'll just do you can call these whatever, you know, whatever you want to.

03:44:00.000 --> 03:44:02.660
The default is going to give me like I and J or something.

03:44:03.820 --> 03:44:06.560
But here I'm going to just loop through there.

03:44:06.560 --> 03:44:07.860
And I can do a couple things.

03:44:07.900 --> 03:44:09.560
One is I could just hard code it, right?

03:44:09.580 --> 03:44:13.880
I could say, well, I know that there's 24 days in there.

03:44:14.180 --> 03:44:16.640
So as long as I don't go over that, I'll be fine.

03:44:18.480 --> 03:44:23.540
And I'll show you the end, the other shortcut or other way you can handle this.

03:44:25.700 --> 03:44:29.000
I think I got a typo up there.

03:44:29.080 --> 03:44:29.760
It's lagging.

03:44:29.900 --> 03:44:30.900
I don't know if you can see it.

03:44:30.900 --> 03:44:32.660
It's lagging just a little bit.

03:44:33.460 --> 03:44:34.100
There we go.

03:44:35.180 --> 03:44:39.640
So what I'm relying on the fact here is I'm actually going to use two loops.

03:44:40.360 --> 03:44:49.180
And since there's four months and there's also four sets of data, data for each month, I'm just going to rely on that loop.

03:44:49.320 --> 03:44:52.380
I'm going to say, OK, well, I need to loop four times.

03:44:53.020 --> 03:44:59.780
And then within those, I need to loop 24 times to get all of these days that are in there.

03:44:59.780 --> 03:45:04.320
So I'm going to loop four times, one for my each month.

03:45:05.020 --> 03:45:09.820
And then as I'm looping, I'm going to loop through the set of data for that month.

03:45:11.120 --> 03:45:13.660
So I'm actually getting those two indexes.

03:45:13.840 --> 03:45:16.880
This is going to be my basically row.

03:45:17.300 --> 03:45:20.020
If you want to think about it like this is what row I want of data.

03:45:20.720 --> 03:45:24.380
And then the second J, this is actually going to be my columns.

03:45:24.380 --> 03:45:30.940
So I'll get each day of that month or each temperature for that month one at a time.

03:45:32.720 --> 03:45:36.180
So that's going to allow me to sort of move through that set of data.

03:45:37.360 --> 03:45:40.280
But what I need to be able to do is actually calculate the average.

03:45:40.480 --> 03:45:44.860
So what I'll do is I'm going to say, let me store the total.

03:45:44.860 --> 03:45:47.440
I need to figure out the total temperature for that month.

03:45:48.460 --> 03:45:52.800
And so I'll store something called total temperature.

03:45:52.800 --> 03:45:55.200
If I could spell, I would call it that.

03:45:57.840 --> 03:46:00.900
And I'll just say that that's zero currently.

03:46:02.480 --> 03:46:08.680
And then as I loop, as I move through each of those days, I want to keep adding up that value.

03:46:11.180 --> 03:46:16.620
So here I would say something like, oops, I'm sorry, I'm doing this in the right place.

03:46:16.620 --> 03:46:17.940
Let's see here.

03:46:19.160 --> 03:46:20.040
I think I need to do that.

03:46:20.160 --> 03:46:21.520
Oh, yeah, I'm doing it inside here.

03:46:23.660 --> 03:46:25.700
If I did it in here, it would just change.

03:46:25.940 --> 03:46:28.160
It would be zero for sort of zero for every day.

03:46:28.340 --> 03:46:30.280
So I want to get the total for that month.

03:46:31.260 --> 03:46:35.580
So as I loop through each month, I want to get the total temperature for that month.

03:46:36.200 --> 03:46:37.860
So I'll start it out at zero.

03:46:37.860 --> 03:46:42.480
And then as I move through each day, I'm going to just add that total temperature up.

03:46:42.480 --> 03:46:44.720
So I want to just say total temperature.

03:46:48.420 --> 03:46:50.360
It's trying to write the code for me.

03:46:51.160 --> 03:46:55.560
As I loop through that, I want to say total temperature equals and then I want to get the current temperature.

03:46:56.620 --> 03:47:02.760
So that's going to be the month and then the day.

03:47:03.120 --> 03:47:04.780
Give me that total temperature.

03:47:06.020 --> 03:47:06.620
All right.

03:47:06.880 --> 03:47:12.400
So each month, I'll go ahead and loop through all the days of temperatures I have for that month.

03:47:12.820 --> 03:47:14.280
I'll add those up.

03:47:14.460 --> 03:47:18.920
And then at the end of this, I should have that total temperature for the month.

03:47:19.640 --> 03:47:23.180
So here, if I was to say console, right.

03:47:27.200 --> 03:47:29.280
If I was to write total temperature.

03:47:32.060 --> 03:47:35.820
I'm expecting that that's going to be the total temperature for that month.

03:47:37.720 --> 03:47:41.640
So I'm going to write out the name of the month and then hopefully this writes out the total temperature.

03:47:42.260 --> 03:47:44.440
And I'm actually going to just save that and see if that works.

03:47:44.440 --> 03:47:46.020
That first part.

03:47:48.280 --> 03:47:51.860
So if I run that, let's see if that's going to give me a number.

03:47:57.060 --> 03:48:01.500
So here I'm getting for January, I'm getting a number, April getting a number.

03:48:02.240 --> 03:48:07.440
So I don't know if that's the right number, but it looks like a good number and I'm getting different numbers for each month.

03:48:08.720 --> 03:48:14.600
And so to get the average, I'm going to have to take all those numbers and divide them and then get to get that average.

03:48:14.600 --> 03:48:14.760
All right.

03:48:16.680 --> 03:48:20.020
So let's go ahead and.

03:48:20.460 --> 03:48:22.500
None of that up what's in the chat.

03:48:27.740 --> 03:48:30.080
Oh, yeah.

03:48:30.240 --> 03:48:36.340
So there's a special way when you have the multiple dimensions that you have to get that that index that that length of the index.

03:48:38.660 --> 03:48:42.900
So so far I am getting the months and I'm getting the total temperature.

03:48:43.040 --> 03:48:47.480
And now I basically here just need to display that average temperature.

03:48:49.740 --> 03:48:53.120
So I'm going to go ahead and say, how do I get that average temperature?

03:48:53.180 --> 03:48:55.240
I'll just bring this little comment up here.

03:48:56.300 --> 03:48:58.300
So this is where I need to get my average temperature.

03:48:59.920 --> 03:49:03.300
So my average temperature.

03:49:08.560 --> 03:49:13.880
It's crazy how that little bit of a delay makes me over type it every time.

03:49:14.320 --> 03:49:18.200
So the average temperature then is going to be.

03:49:19.000 --> 03:49:20.860
Oh, yeah.

03:49:22.380 --> 03:49:27.640
I'm going to store that as a double actually, right, because I'm going to have some decimal points in that.

03:49:29.260 --> 03:49:34.160
And that's just going to be my my total temperature that I just calculated there.

03:49:35.120 --> 03:49:38.080
And then it's just divided by the number right there in there.

03:49:39.260 --> 03:49:42.100
So this will give you my total for those 24 days.

03:49:42.120 --> 03:49:45.820
And then if I divide that by 24, I'll get this average temperature.

03:49:46.720 --> 03:49:48.760
And then I can just write that out as well.

03:49:48.760 --> 03:49:50.400
Right. So just console.

03:49:51.920 --> 03:49:52.300
Right.

03:49:53.640 --> 03:49:55.340
There we go.

03:49:57.560 --> 03:49:59.280
And write that average temperature out.

03:50:00.780 --> 03:50:04.040
And I don't need to write the total out anymore.

03:50:05.820 --> 03:50:07.800
So I'll just comment this line out.

03:50:09.680 --> 03:50:13.780
OK, let's try saving that and running that, see what that gets me.

03:50:18.900 --> 03:50:24.940
And so now I'm getting 51, 55, 69, 64 for my averages.

03:50:30.220 --> 03:50:34.260
Did you share the link for the how to get the index?

03:50:38.340 --> 03:50:42.740
No, I figured if anybody else wants to go ahead, they can do it.

03:50:52.860 --> 03:50:56.540
Yeah, even Google is definitely your friend.

03:50:56.760 --> 03:51:00.360
Right. So there's always going to be those sort of weird things that you very rarely use.

03:51:00.400 --> 03:51:02.960
But when you do need to know them, they're useful.

03:51:04.800 --> 03:51:14.020
So if you search on, I think Maria had that in the chat, you search on something like, how do I get the index of a multiple, a multidimensional array?

03:51:14.980 --> 03:51:21.680
You're going to see that just like we have dot length, you can actually get the length of those different indexes as well.

03:51:23.700 --> 03:51:29.760
All right, so the big takeaway here, arrays allow you to store multiple data, right, multiple values of data.

03:51:30.680 --> 03:51:40.780
And then you're able to use for loops. Loops are very useful for working with your sets of related data and giving you the ability to loop through that data.

03:51:41.200 --> 03:51:43.720
And then in this case, you know, do some calculations.

03:51:44.200 --> 03:51:50.820
Right. And just like we saw before, you're not limited to the amount of code that's inside that code block.

03:51:50.820 --> 03:51:57.240
So this for, you know, loop, for example, has a few more lines of code than what we were seeing in some of the examples.

03:51:58.060 --> 03:52:01.320
But it still works the same way. So it's going to have the four keyword.

03:52:01.900 --> 03:52:10.760
You're going to have some condition to start the thing off, something to check to decide how many times it loops and and then be able to move through that loop.

03:52:12.200 --> 03:52:15.800
Besides the crazy extra array in there.

03:52:16.220 --> 03:52:19.700
Any any other questions about this? Did anybody solve it a different way?

03:52:25.760 --> 03:52:28.320
Okay, you could you could have you could have done it as two loops.

03:52:28.640 --> 03:52:34.240
You know, you could have looped through the months and displayed those and then done a separate set of loops to do the other temperature.

03:52:34.240 --> 03:52:40.120
Again, the key thing is your code may not look like my code or may not look like the salt code.

03:52:40.500 --> 03:52:45.360
But the important thing is that if you understand what your code is doing and it works, you get the correct result.

03:52:45.880 --> 03:52:52.040
That's really the key takeaway. Understanding what it's doing and having your code be valid.

03:52:52.320 --> 03:52:54.300
Right. Give you give you the right result and right output.

03:52:56.100 --> 03:53:03.460
So we've talked about all of sort of the basic tools that we're going to need to work with that solve real problems.

03:53:03.460 --> 03:53:06.460
So we've talked about variables, data types.

03:53:06.980 --> 03:53:09.120
We've learned how to do conditional checks.

03:53:09.820 --> 03:53:11.360
We've learned to do some looping.

03:53:11.980 --> 03:53:16.080
And now we've learned how to store multiple values in a variable.

03:53:16.500 --> 03:53:20.220
So the only thing remaining is bringing those all together.

03:53:20.860 --> 03:53:27.360
Right. So this final activity for the day grades will have a little bit more time on this one.

03:53:27.380 --> 03:53:29.160
I think it's like 20 minutes roughly.

03:53:29.160 --> 03:53:35.240
So we'll do that. We'll do a quick review of that and then kind of a final wrap up before the end of the day.

03:53:35.860 --> 03:53:40.320
So this activity you're going to see you start with almost no starter code.

03:53:40.960 --> 03:53:48.260
But basically what we're trying to do here is get you the opportunity to work with all of the things we've done today.

03:53:48.660 --> 03:53:50.580
So we're going to create some variables.

03:53:50.720 --> 03:53:52.060
We'll practice creating some variables.

03:53:52.660 --> 03:53:55.240
We're going to store some data here.

03:53:55.240 --> 03:53:57.560
We're going to want to store the names for a couple of students.

03:53:59.800 --> 03:54:04.220
And we have sample data that if you don't want to be creative that you can use the sample data.

03:54:04.480 --> 03:54:07.020
But we'll store some variables for at least two students.

03:54:07.520 --> 03:54:10.360
We're going to store three exam scores for each student.

03:54:11.620 --> 03:54:14.580
And so we're going to want to be able to just like we did with the temperature activity,

03:54:15.000 --> 03:54:19.720
we're going to want to be able to loop through those students and display their average score.

03:54:20.940 --> 03:54:25.680
And then we're also going to use that average score to figure out what their grade is.

03:54:25.680 --> 03:54:29.480
So we're going to have to loop to figure that score out.

03:54:29.540 --> 03:54:35.760
And then we'll have to compare that score to decide what letter grade does that student get.

03:54:38.100 --> 03:54:44.000
Here's a sample data we're going to show you just if you don't want to feel particularly creative today.

03:54:45.100 --> 03:54:47.260
So we've got two students here, Samantha and Ethan.

03:54:47.620 --> 03:54:49.760
We've got three exam scores for each of them.

03:54:50.520 --> 03:54:55.480
And then when we run our code, what we're looking for is something like this for our output.

03:54:56.020 --> 03:55:02.980
So we're looking displaying that student's name, what their average score is from those three exams,

03:55:02.980 --> 03:55:06.900
and then what that means their letter grade is going to be based on.

03:55:07.880 --> 03:55:12.060
So given you the opportunity to kind of apply all of these things that we've talked about today.

03:55:14.560 --> 03:55:17.860
And again, if you take a look at starter code,

03:55:18.420 --> 03:55:20.700
it's rolling pretty light for this activity.

03:55:21.080 --> 03:55:24.260
So starter code is going to just give you that solution and project.

03:55:25.180 --> 03:55:34.280
And then some ever helpful comment about this is where your code goes, but not a lot else.

03:55:34.580 --> 03:55:38.540
So you're going to need to create some variables, some arrays to hold that data.

03:55:39.300 --> 03:55:45.500
You'll need to loop through that data, display their name, display their average score.

03:55:45.500 --> 03:55:48.920
And then you'll need to do some kind of conditional, right?

03:55:48.920 --> 03:55:52.760
To figure out what does that mean their letter grade is based on that score that they got.

03:55:54.980 --> 03:55:56.820
Are there any questions at all before we start?

03:55:59.000 --> 03:56:03.360
Okay, so perfect. So we'll do about 20 minutes on this, and that'll take us pretty close to perfect timing.

03:56:03.580 --> 03:56:10.140
We'll give us about 15 minutes to kind of wrap up, review this, and then we'll get out of here for today.

03:56:59.160 --> 03:57:00.560
Okay.

03:57:12.820 --> 03:57:14.220
Okay.

03:57:42.200 --> 03:57:43.600
Okay.

03:58:07.580 --> 03:58:08.980
Okay.

03:58:29.120 --> 03:58:30.520
Okay.

03:58:52.720 --> 03:58:53.500
Any blockers?

03:58:53.500 --> 03:58:56.360
It looks like everyone's kind of working their way through it.

03:58:56.360 --> 03:59:01.220
So does anything, any questions you have, whatever, just let me know.

03:59:01.220 --> 03:59:24.220
All right.

03:59:24.220 --> 03:59:32.180
About like four minutes or so, and then we'll review what we've got.

03:59:48.100 --> 03:59:52.400
So let's take a look at what we had to work with here.

03:59:55.540 --> 04:00:01.940
So we know we need to have some variables that represent some of our data and pull some of that in, right?

04:00:02.580 --> 04:00:07.260
So the first thing that we needed to do there was create some things to store that.

04:00:07.800 --> 04:00:13.740
I saw some of you doing things a different way or a couple different ways of doing it, but there's no really right or wrong way here.

04:00:15.680 --> 04:00:17.220
So let's take a look.

04:00:17.220 --> 04:00:20.140
I'm going to go ahead and declare some student names.

04:00:20.200 --> 04:00:20.640
Whoops.

04:00:21.140 --> 04:00:22.320
And I make that an array.

04:00:23.060 --> 04:00:23.920
Let's see.

04:00:25.720 --> 04:00:26.740
Are you able to see my screen?

04:00:28.260 --> 04:00:28.740
Okay.

04:00:29.680 --> 04:00:32.400
For a minute there, it didn't have a little green outline, so I wasn't sure.

04:00:33.120 --> 04:00:33.980
All right.

04:00:35.540 --> 04:00:37.900
And so we're going to create some student names.

04:00:39.120 --> 04:00:42.580
And we know that's going to be string data, right?

04:00:42.580 --> 04:00:44.060
So we'll do our string array.

04:00:45.920 --> 04:00:54.180
And again, we could give it a size or if we just put some data or provide some data, we can let C Sharp figure that out for us.

04:00:55.220 --> 04:01:03.660
So here I'm going to create a new string array of data, and then I'm just going to create my curly braces for the data that I'm going to put in there.

04:01:04.260 --> 04:01:12.400
Sometimes I like to just do it this way to kind of make sure I have all the curly braces and everything in place first, right, and then kind of come back and fill in the data.

04:01:13.500 --> 04:01:18.960
It gets confusing sometimes remembering where those curly braces should go or where the semicolons should go.

04:01:19.480 --> 04:01:24.860
So in this case, I'll just fill that out first and then I'll go and put some data in here.

04:01:27.080 --> 04:01:29.100
And then same idea.

04:01:29.200 --> 04:01:31.020
We'll put a couple of students.

04:01:34.940 --> 04:01:36.800
And get that data in there.

04:01:36.800 --> 04:01:40.780
The white space I'm kind of adding around this totally unnecessary.

04:01:41.060 --> 04:01:42.640
It just makes it easier to read.

04:01:42.820 --> 04:01:46.320
So just be aware for the majority of things you'll do.

04:01:46.360 --> 04:01:48.500
C Sharp really doesn't care about the white space.

04:01:49.300 --> 04:01:53.460
It's really more about where the curly braces and where's the semicolon.

04:01:54.780 --> 04:01:57.280
I also need some exam scores, right?

04:01:57.280 --> 04:01:59.760
So we'll do an integer array for those.

04:01:59.760 --> 04:02:07.220
And kind of like we were doing on that example with the temperatures, I'm just going to do an array with a couple of dimensions here.

04:02:08.080 --> 04:02:10.180
And so we'll just call that exam scores.

04:02:11.440 --> 04:02:16.940
And obviously, as I'm going to feel free to interrupt ask questions, I don't have any issues with that at all.

04:02:17.680 --> 04:02:20.440
So I'm going to create an array of exam scores.

04:02:22.720 --> 04:02:29.560
And you'll notice on this with the int array, I'm not even using the new type thing, right?

04:02:29.560 --> 04:02:31.420
I'm just doing int. I'm not even using new int.

04:02:31.480 --> 04:02:37.280
I'm actually going to just give it the data and let it figure out what that means.

04:02:37.780 --> 04:02:40.620
How many rows and columns that need to be in there.

04:02:41.540 --> 04:02:43.820
And so I need to have two sets of data, right?

04:02:43.840 --> 04:02:47.940
So I'm going to have one set of data and then comma my second set of data.

04:02:49.180 --> 04:02:52.300
And then in here, I'll just fill out those scores that I need.

04:02:53.040 --> 04:02:54.640
So I'll just make up some numbers here.

04:02:54.640 --> 04:02:59.380
I think my sample got 64 and like 92 or something.

04:03:02.640 --> 04:03:04.800
And then same idea for this student.

04:03:04.940 --> 04:03:06.680
We'll just give this student some scores.

04:03:08.620 --> 04:03:12.420
So 78, 85 and 89.

04:03:13.620 --> 04:03:14.400
Shane. Yes.

04:03:15.160 --> 04:03:17.820
Is it OK to have those on the same line?

04:03:18.100 --> 04:03:18.580
Oh, absolutely.

04:03:21.640 --> 04:03:23.220
Yeah, absolutely. Great question.

04:03:23.220 --> 04:03:28.660
Yes. So just like everything else, the white space is really just for you and me.

04:03:28.860 --> 04:03:29.880
It's for readability.

04:03:30.300 --> 04:03:35.500
But I could absolutely do this all entirely on one line, right?

04:03:37.680 --> 04:03:44.420
So this is all just just to make it a little bit more readable when human beings are coming in.

04:03:44.420 --> 04:03:48.560
But sometimes, you know, if it's just these two exam scores, this might be perfectly readable that way.

04:03:49.120 --> 04:03:55.640
And again, for the most part, Python, the indentation of the white space matters.

04:03:56.140 --> 04:03:58.180
C Sharp really does not care. Great question.

04:03:59.180 --> 04:04:00.980
So I've got a couple of sets of data there.

04:04:01.000 --> 04:04:03.420
So I've got my student names and my exams.

04:04:05.920 --> 04:04:07.540
Let's see what else I need to do.

04:04:08.820 --> 04:04:11.140
I need a loop, right? Do some loops here.

04:04:12.740 --> 04:04:16.160
So we'll do a for loop and then the same idea.

04:04:18.600 --> 04:04:20.860
I need to be able to loop through those values.

04:04:22.720 --> 04:04:28.900
And as long as that's less than all the student names.

04:04:33.540 --> 04:04:33.940
Length.

04:04:37.980 --> 04:04:40.720
Then we'll go ahead and keep moving that forward.

04:04:45.700 --> 04:04:53.040
And so, again, we're going to just be able to loop through those values in that array to work with that data.

04:04:55.520 --> 04:04:56.980
And I think I'm done with typing.

04:04:56.980 --> 04:04:59.600
So let's switch over to the solution code.

04:05:01.260 --> 04:05:03.560
I don't want to type out the rest of that's a lot.

04:05:04.140 --> 04:05:04.900
It's a lot of typing.

04:05:06.040 --> 04:05:10.260
All right. So let me take a look over here.

04:05:14.360 --> 04:05:16.860
Go ahead and close this one.

04:05:23.520 --> 04:05:26.560
And close that one.

04:05:29.400 --> 04:05:33.020
OK, then we'll just open the solution for this.

04:05:37.920 --> 04:05:46.840
We'll try to follow the same pattern each day of the training where we'll basically have a final activity that will kind of bring together the stuff that we've done throughout the day.

04:05:47.900 --> 04:05:50.300
Just as kind of a way to review what we've done.

04:05:51.940 --> 04:05:53.940
So if I take a look at this great solution.

04:05:58.920 --> 04:06:02.760
And I'm definitely going to try doing this just off my desktop tomorrow.

04:06:02.860 --> 04:06:05.060
I think this will be quicker for this part for sure.

04:06:05.360 --> 04:06:09.080
Plus, you'll be able to actually see the code a little bit better on my desktop.

04:06:11.640 --> 04:06:15.180
OK, so let me move some zoom windows around.

04:06:20.420 --> 04:06:23.520
All right. Fantastic. So we have the students created.

04:06:23.680 --> 04:06:26.900
We have the scores in the chat. I linked you.

04:06:27.040 --> 04:06:30.960
I know a couple of you looked it up with the multidimensional arrays.

04:06:31.040 --> 04:06:37.080
You can get the the length of those individual indexes here.

04:06:37.080 --> 04:06:41.480
Here I'm just going to actually just provide some values. So I know I have two students.

04:06:41.620 --> 04:06:46.640
I know I have three exams and then I'll just use those values down here to loop.

04:06:47.060 --> 04:06:49.940
So I'll live for my number of students.

04:06:51.020 --> 04:06:55.920
Just like we did with the temperature, I'm going to need to track that total score.

04:06:56.720 --> 04:07:04.300
Right. So that total as I go through. So as I loop through the students, I want to get that score for each student so that I can get the average.

04:07:05.140 --> 04:07:08.160
So I'll go ahead and keep that zero originally.

04:07:08.400 --> 04:07:14.500
And then as I loop through their exam scores, I'll go ahead and add that total.

04:07:14.640 --> 04:07:19.920
Keep track of that running total for that student so that I can then get the average for the student.

04:07:21.340 --> 04:07:24.060
So I'm using two indexes here, right?

04:07:24.060 --> 04:07:27.940
The first one represent which student row am I getting of data?

04:07:27.940 --> 04:07:35.740
And then that second index is indicating which exam or which score from that row am I getting?

04:07:36.780 --> 04:07:41.540
So the outside loop is moving through my students, the inside loop is moving through their scores.

04:07:41.960 --> 04:07:48.280
Your visual like I am. So that first loop is going from this row to this row.

04:07:50.720 --> 04:07:53.560
Super dry today. And the I apologize for that.

04:07:53.560 --> 04:07:58.520
And the second loop is going through those scores, individual scores for each student.

04:08:00.280 --> 04:08:02.720
Again, lots and lots of ways that you could do the same code.

04:08:03.160 --> 04:08:06.720
The important thing is that you understand what the code is doing and the code is working.

04:08:07.200 --> 04:08:09.200
Many ways you could have solved the same problem.

04:08:11.040 --> 04:08:16.220
So we'll write out the name of that student here on line twenty seven, loop through their scores.

04:08:17.000 --> 04:08:23.820
And then once we have that total score for them, then we're able to get their average score, right?

04:08:24.120 --> 04:08:28.460
So once we've got their total score, we can write that out.

04:08:29.000 --> 04:08:30.280
Here's your average score.

04:08:32.080 --> 04:08:34.280
And then we can use that average score.

04:08:34.760 --> 04:08:39.780
We can compare that to actually figure out what letter grade they get.

04:08:40.260 --> 04:08:44.460
So if that final score is an eighty one, then we can actually compare that.

04:08:44.460 --> 04:08:51.120
We can say, OK, well, if it's greater than or equal to 90, but less than 100, it's an A.

04:08:51.860 --> 04:08:58.740
If it's between 80 and 90, they're equal to 80 or greater than less than 90.

04:08:59.760 --> 04:09:01.160
That'll be a B.

04:09:01.660 --> 04:09:05.260
And so we'll do each of those checks to figure out what that final score is.

04:09:05.280 --> 04:09:09.440
And then we can write that grade score out for the students as well.

04:09:10.080 --> 04:09:14.340
And then so we can finally go ahead and write out that grade score for those students.

04:09:17.320 --> 04:09:21.160
And so I know we covered a lot of things in this activity, a lot of different pieces.

04:09:21.680 --> 04:09:23.480
Any any questions on any part of this?

04:09:23.780 --> 04:09:26.380
Or did anyone maybe do it differently and run it as an issue?

04:09:28.620 --> 04:09:29.440
Oh, good.

04:09:29.440 --> 04:09:34.080
I was going to ask, is it possible to put different types of data in the same array?

04:09:35.260 --> 04:09:37.700
Or would you just be like, please just create an object at that point?

04:09:38.360 --> 04:09:39.720
Yeah, that's actually a good point.

04:09:39.940 --> 04:09:45.300
So C sharp doesn't let you put multiple or different data types in.

04:09:45.620 --> 04:09:51.480
So when you're declaring the array, you're declaring that as a specific type.

04:09:53.740 --> 04:09:56.480
And so we're so you're declaring that data type.

04:09:56.480 --> 04:10:04.700
And so you'll see literally tomorrow we'll talk about this when you're when you have data that's related, but different data types.

04:10:05.180 --> 04:10:07.380
We'll actually kind of store that in a different way.

04:10:07.380 --> 04:10:08.780
And we'll talk about that tomorrow.

04:10:09.340 --> 04:10:16.240
So by default, when you're creating these things, these arrays in C sharp, just like your variables, you're not mixing types.

04:10:17.020 --> 04:10:19.320
So all of the scores are going to be integers.

04:10:19.880 --> 04:10:21.780
You know, all the student names are going to be string.

04:10:22.260 --> 04:10:25.380
And then, yeah, to your to your point, we'll take a look tomorrow.

04:10:25.380 --> 04:10:30.040
Exactly. Hey, if I have different data types that are related, how do I work with that?

04:10:30.060 --> 04:10:32.000
That'll be exactly what we'll talk about tomorrow.

04:10:32.520 --> 04:10:33.060
So perfect.

04:10:33.900 --> 04:10:35.020
Was there another question?

04:10:37.020 --> 04:10:37.860
Did you have a question, Kelly?

04:10:37.980 --> 04:10:38.860
It's fine if not.

04:10:39.020 --> 04:10:40.960
I just want to be sure we don't have any questions.

04:10:41.140 --> 04:10:41.360
Don't go.

04:10:41.440 --> 04:10:43.440
Kelly may have locked out.

04:10:44.020 --> 04:10:46.000
Oh, it still shows connected.

04:10:46.180 --> 04:10:48.560
But maybe she got disconnected from the session.

04:10:49.700 --> 04:10:53.400
OK, well, we have about four minutes or so left, so we should be OK.

04:10:53.400 --> 04:11:01.340
So I know a lot of this for some of you is probably a little bit easier than others because you have more exposure to kind of language.

04:11:02.640 --> 04:11:05.820
Hopefully, either way, you got some some good grounding, some good fundamentals.

04:11:06.760 --> 04:11:13.920
And if you did see any differences or you notice any differences to kind of the language that you're used to, feel free to ask about those as well.

04:11:14.420 --> 04:11:17.520
I can speak to the C sharp side a lot better than the Python side.

04:11:18.600 --> 04:11:22.660
But, you know, but I know there are some differences in kind of the way things are handled.

04:11:22.660 --> 04:11:25.480
And you've been asking great questions about that already, I think.

04:11:28.160 --> 04:11:34.820
So today we've kind of covered just sort of all the starter tools that we'll need to dive into our code tomorrow.

04:11:35.460 --> 04:11:44.180
Tomorrow we'll pick up with with talking about how do I handle related data that's different data types and kind of how do I work with that together?

04:11:45.520 --> 04:11:48.720
And then day three is going to be a lot about unit testing.

04:11:49.160 --> 04:11:50.500
And right now it's XML.

04:11:50.500 --> 04:11:52.500
Do you do you currently use XML?

04:11:52.740 --> 04:11:55.080
I think you use mostly JSON from what I was understanding.

04:11:56.460 --> 04:11:57.660
Is it mostly JSON data?

04:11:58.760 --> 04:11:59.860
Yeah, OK.

04:12:00.200 --> 04:12:03.500
So the core discourse material talks a lot about XML.

04:12:04.360 --> 04:12:04.980
I'll take a look.

04:12:05.080 --> 04:12:13.440
Maybe we can tweak those activities and make it more JSON focused to kind of be more relevant to what you're you know what you're seeing in your day to day stuff.

04:12:15.660 --> 04:12:26.780
It could also be that I am not 100 percent sure how the new framework is going to look, but it could be that we may switch to using XML in the C Sharp side of things.

04:12:28.260 --> 04:12:29.440
I'm not sure.

04:12:29.860 --> 04:12:30.820
Oh, OK, OK.

04:12:32.140 --> 04:12:32.860
It's funny.

04:12:33.260 --> 04:12:34.720
The trend has been kind of the other way.

04:12:34.960 --> 04:12:35.020
Right.

04:12:35.720 --> 04:12:36.760
Ditching XML.

04:12:37.240 --> 04:12:41.120
I mean, I prefer JSON, but we'll see what we get.

04:12:42.700 --> 04:12:46.760
Well, if it's C Sharp making your choice, C Sharp is with you.

04:12:46.900 --> 04:12:48.320
C Sharp is definitely JSON.

04:12:49.220 --> 04:12:52.640
But there's a lot of XML legacy stuff.

04:12:52.740 --> 04:12:55.440
You know, C Sharp, just like other languages, has been around for a while.

04:12:55.960 --> 04:12:58.100
So there was a lot of XML support.

04:12:58.240 --> 04:12:59.560
Everybody was going to XML.

04:13:00.040 --> 04:13:03.160
And now the trend is everybody's using JSON instead.

04:13:03.500 --> 04:13:07.060
So that's kind of where the current new stuff is at.

04:13:08.720 --> 04:13:13.760
But otherwise, if you have any questions, I would say thank you for your time today.

04:13:14.320 --> 04:13:16.000
And hopefully this answered a lot of questions.

04:13:16.040 --> 04:13:21.520
Kind of got your feet wet as far as what we'll be doing and the way the language looks and that type of stuff.

04:13:21.860 --> 04:13:23.740
And then tomorrow we'll kind of build on that.

04:13:23.740 --> 04:13:31.360
And we'll that'll lead us into day three when we can start showing you how tests work in this environment and how you can test your code.

04:13:33.140 --> 04:13:35.660
So no other questions. Have a fantastic day.

04:13:35.720 --> 04:13:36.620
I will see you tomorrow.

04:13:40.680 --> 04:13:41.660
Bye. Thanks.