Visit the C# for Automation Test Engineers course recordings page
WEBVTT--> My apologies, it's taking a little bit of time. --> Here we go, okay. --> So let me see what you're seeing here, Colton. --> So let's take a look at your, --> oh, so you need to go to Visual Studio. --> This is a Visual Studio code. --> Yeah, so if you go to your search menu --> and just type Visual, start sending Visual Studio. --> Yeah, there you go. --> Oh, don't do it that way. --> If you do it that way, you're gonna open --> all the activities for the week in Visual Studio. --> Yeah, let's just do it from here. --> Yeah, no, not a problem. --> I have a quick question. --> I'm seeing a framework .NET 08. --> Is that correct? --> Let's see, you're seeing... --> Oh, what comes up in your window here? --> Yeah, I'm about to create --> and it says .NET 08 instead of 472. --> Give me one second. --> How do I minimize this desktop now? --> Well, Anne, did you make sure you are doing --> console.net framework and not just console.net? --> Oh, no. --> I made that mistake, too. --> That was like, I'll just keep going with it. --> That was not the right thing to do. --> I think, yeah, I think on this one, too, --> the previous client was, of course, was four. --> They had a specific version of the .NET framework. --> And so the instructions in some of this material --> are referring to that specific version. --> So honestly, in this one, you could just use --> the console app and it would still work. --> Let me see what you're seeing there. --> Yeah, you can even, yeah, it's fine when you pick that --> and then you're going to see the option there. --> That's fine. --> Okay, thank you. --> So Shane, when you're saying location --> and you're saying starter. --> Yes. --> I'm seeing C user student source equals. --> Am I, are you, is that farther down the road --> where you're talking about the starter? --> No, I'll show you what I mean there. --> No, it's not from, let's see. --> Oh no, I think I went to the wrong desktop. --> I think I went to, yeah, give me a second here. --> I wish I had like bigger names next to these desktops. --> This is a pretty, okay, give me one. --> Oh my gosh, this is like fun, but between Zoom. --> So that's gonna be the default location --> that you're seeing there. --> If you click on that little blue button with the dot, dot, --> dot, and now just on the left side there, pick desktop --> and then pick the C sharp folder there. --> And then go, yeah, just keep going. --> You go into O1 lesson and the activities. --> Sorry, I try to give you a bunch of directories. --> Go to O2 Hello World and then there's the starter folder. --> So double click that starter folder. --> Yeah, and then you select folder at the bottom, right? --> Yeah, perfect. --> So that'll just create it so that when we're done --> with all the course, you'll still have all your files --> and the solutions and everything kind of --> in the same place. --> So this is where we're supposed to be then? --> Yes, yep, that's exactly where you wanna be. --> I promise it gets easier. --> There is a little bit of overhead though, right? --> In getting these things set up. --> Your screen is kind of small too, Shane. --> And I know it's because we're all got our cameras on, --> I would assume, but is there any way --> to make it just a little bit larger? --> When I'm sharing my screen? --> Yeah. Oh, absolutely. --> Yeah, I can zoom in when I do that. --> Okay, thank you. --> I was gonna mention that as well. --> I got bad-ass. --> Yeah, I'm doing this with my glasses. --> I know, I'm going like. --> No, I could feel the pain. --> My eyes are not the same as they used to be either, so. --> Yeah, that attention that I got --> are saying my eyeglasses are ready today. --> I'm like, yay! --> So like, Fist of Five, how are we doing? --> Five, you're finished already? --> This, we need more assistance? --> All right, cool. --> So let's take a look. --> Share my screen here. --> Let's take a look at some solution code --> and we'll just talk again --> about kind of what's going on there. --> All right. --> After writing Python for a while, --> the semi-colons just kill me. --> I'm just like, let's do it. --> It's a little bit different, right? --> Yeah, I'm like, oh, sometimes semi-colons, oh yeah. --> Okay, let's see. --> I think I'm gonna zoom back out and get to my desktop. --> All right. --> Okay. --> All right, I'm actually gonna step back from this --> and show you again. --> All right, so again, --> this is a little bit of overhead that has to happen --> in order for Visual Studio to have all the files --> that it needs in order to run your code. --> And so there's gonna be some things --> it'll need to create, for example, --> if you're running a desktop application, --> versus a web application. --> Is everyone able to see my screen? --> I can zoom in here, I'm pretty sure. --> Let's see. --> The only thing I don't know --> is if this is gonna zoom in on that tool --> or if it's gonna zoom in only for me. --> Let's see here. --> Let's try this. --> Okay, so at the top of my screen, --> are you able to see kind of a zoomed in version there? --> Okay, so anytime you're gonna start working --> with Visual Studio, --> there's gonna be kind of two options you're gonna go to. --> So if we're doing something new, --> it'll be just create a new project option. --> If you're opening something existing, --> there's an open existing project or solution, --> as well as I'll show you that you can just --> double click on that solution file --> right in your Windows Explorer --> and it'll open it as well. --> So these are kind of your two options --> that you're gonna have. --> This create a new project option. --> This is actually the only activity --> we're gonna do this for. --> Just so that you're familiar, --> that you're aware of kind of how these things --> get built and created. --> Everything from here forward --> will actually have a starter file --> for you to work with already. --> But it's important to understand --> kind of where these things come from. --> You're gonna see that there's lots and lots --> of different templates that are available. --> And the particular one that we're using here --> is gonna be this console app. --> Again, if that doesn't appear, --> you can always type in your search up here. --> You can type for different kinds of applications --> to find those. --> So in this case, I just say console. --> And you're gonna see there's different types of apps --> that are available. --> So in this example, I'm just gonna go and pick --> an option here. --> And where's the scroll bar now? --> Oh my gosh. --> There we go, okay. --> And then on this next screen, --> what you'll see is you're gonna get --> a couple more choices, right? --> So here when I'm configuring my project, --> the first thing I'm gonna get --> is the name of that project. --> So in this case, we called it Hello World. --> Oh, there's a little bit of a lag. --> If you could see what I'm typing. --> So we're gonna call it Hello World. --> And this is gonna just be the name --> that it'll use to name that file, right? --> So typically you wanna make this something friendly. --> If I called it Hello World --> and then it actually did my taxes or something else, --> it would be confusing, right? --> So you wanna pick a descriptive name for this. --> Something that's gonna make sense --> to whatever it is you're actually working on. --> And then this location is gonna be where in your files --> it's gonna actually create these files for you. --> And again, for this one, --> I just browsed with my browser --> into the activity folder. --> So into that C sharp and lessons and activities --> and just created it in here. --> All right, I'm gonna cancel out. --> I'm not gonna actually finish creating that particular one. --> We'll take a look at the one we did create though. --> So I'm gonna cancel out of that. --> And then I'll show you, --> there we go, fantastic. --> I'll show you the other way. --> So since this is already existing, --> here I am in the Hello World folder. --> I'm gonna go back up a folder. --> And so in this solved version, --> you're gonna see that there's already --> the solution file already exists. --> So if I just double click on that, --> that'll actually open that in Visual Studio --> for me as well. --> So Windows is smart enough to know, --> oh, that's the Visual Studio solution. --> Let me open that in Visual Studio for you. --> And you can see that that opens that up for me. --> So what is this project doing for me? --> This is gonna allow me to create --> different kinds of things, right? --> So in this case, --> I'm gonna be able to create this little application --> that we were running. --> And if I go ahead and click start, --> you're gonna see that that will come up and run, --> and it'll print that message out on the screen for me. --> All right, so that's the most important takeaway --> that you're gonna have some files that you'll work with, --> how to open those in Visual Studio, --> and then the fact that you can use --> that little start button or play button --> to actually run your code --> and see what you're doing. --> That's what your code is gonna do for you. --> All right, let's take a look at actually --> writing some code, --> learning how to write some code. --> All right, let me close this. --> All right, so all the activity is going for, --> you're gonna see that, in this case, --> I've got starter files for it. --> So I'll actually be able to just start --> with that existing solution. --> I won't have to create those from scratch. --> And from this activity forward, --> we're gonna focus just on the code itself. --> So once that opens, you're gonna see, --> I'll have my variables project over here. --> Oh, you were asking me about zooming in on this, right? --> Let's see. --> Am I gonna be able to zoom? --> Are you gonna allow me to do that? --> Are you able to see that? --> Is that zoomed in for you on the top there? --> Okay. --> So here are my variables project. --> If I click to expand that, --> I'm gonna see there's some code files under here. --> So this program.cs file. --> And if I double click that, --> that will open it for me here in my editor. --> All right. --> We'll talk as we go through about some of this stuff --> that Visual Studio is creating for me. --> So this using and the namespace, all this. --> We'll talk about that as we get further along. --> For right now, the key thing to keep in mind --> is that all the code we're gonna write --> will be inside this thing called main. --> So this is where we're gonna write all the code --> that we wanna actually write and run. --> And we'll let Visual Studio for right now --> sort of create the rest of that framework for us. --> And we'll just focus on the code we'll write. --> And then once we've understand what the code is doing --> a little bit better, --> then we'll come back and talk about --> what some of these things mean out here. --> But for right now, --> Visual Studio will create that for us, --> that sort of template. --> And we'll just focus on the code --> that we write inside here. --> So let's try writing some code. --> So the first thing you're gonna notice --> as we start writing code. --> Oh, it's lagged a little bit, I think. --> There we go. --> Okay, there we go. --> The first thing you're gonna notice --> as you start writing code is --> any time we wanna write our programs to do things, --> and I'm sure you're seeing this in Python already, --> we have things that we wanna track, --> data that we wanna track. --> And just like in Python, --> we're gonna track that in variables. --> So the variables are gonna be --> how we'll know what we wanna track. --> So what might be some examples of things --> that we would wanna track in a program? --> A counter? --> Yeah, exactly. --> So maybe a counter we wanna keep track of --> how many times something has happened --> or how many times something is run, --> something like that, right? --> What might be some other examples --> of things we would wanna track in a program? --> The idea of an activity in MES web. --> That seems very specific. --> Something like the activity ID, right? --> Yeah. --> Oh, okay, all right. --> Oh, let's try that. --> Would it be like the result of a mathematical expression? --> Yeah, absolutely. --> So something like a result, right? --> So in programming or in code in general, --> there's lots of data we wanna work with --> and things we wanna track. --> And so what we'll do to track that in most languages --> is we'll create something called variables. --> So these things we've created here --> are basically gonna be, --> it's trying to like help me, --> but it's not being helpful. --> These things we've created here --> are all things we wanna keep track of. --> And so we'll keep track of those with variables. --> And a variable is just gonna be a way --> to store information or store data --> that we wanna keep track of. --> In C Sharp specifically though, --> we have to have a couple of things --> in order to create a variable. --> So we already have name for this thing, --> but we also have to say, --> what type of data do we wanna store here? --> So I'll have to do something like this, for example. --> And I'll give you a couple of examples --> and then we'll talk about this. --> So this is probably also, --> it's probably actually a different type of data, --> but just pretend with me. --> And yeah, maybe this is also a data type as well. --> So in C Sharp, --> not only do we have to have a name for a variable, --> so here's gonna be the name of, --> we'll call this thing counter, --> but I have to tell C Sharp, --> what kind of data do I want to store in this variable? --> And C Sharp will take that information that I give it --> and do a couple of things with it. --> One is it's gonna say, --> oh, how much space do I need --> to set aside for this thing? --> And the other thing it's gonna do is that, --> if sometime later you try to put data into there, --> into that variable that doesn't match --> the type that you told it that it was, --> C Sharp will actually tell you that, --> hey, you're trying to store something in there --> that you told me --> that you were gonna store something different in. --> And that's really important --> because you might've done that accidentally --> or you might not realize it's a different data type. --> So in this example here, --> I'm saying I wanna have something of a number type --> or an int type, --> and I wanna store this in a variable called counter, --> and then I'm gonna have different data types --> that are available to me. --> We'll talk more as I go through this --> about the different data types that are available. --> But the key takeaway here --> is that you wanna be able to tell C Sharp, --> the type something is, --> what kind of data do I wanna store in this? --> And then you're gonna give it a name --> in order to be able to refer to that. --> So I'll show you the other example here. --> Let's do something like maybe a file name. --> So maybe I wanna keep track of a file name. --> So again, I have to give it a certain data type, --> and then I have to give it a name. --> You're gonna notice also C Sharp always ends --> in a semicolon. --> So every line, --> how the computer knows that one line --> is different from the next line --> is actually the semicolon. --> So if I don't put that in, --> I think you'll notice I'm getting --> like a kind of a red error there when I do that. --> And a string is gonna just be data like character data, --> like a first name or a file name, --> paragraph, something that would be a string. --> Now, all I've done here on this line --> is just created this variable, the name of it, --> and what type it is. --> How do I actually get data in that variable? --> So in C Sharp, I'll use the name of that variable, --> and then the equal sign, --> and then that'll allow me to assign some data to there. --> So maybe I'll do something like this. --> So the equal sign is basically saying, --> take whatever data is on the right side of this --> and store that in that variable. --> Any questions on that part so far? --> For the file name, --> so you don't have to do like a, --> I said, give you a whole path. --> What was the question for file name? --> I'm wondering for a file name, --> do you have to give like a whole file path name --> or you just have, it just doesn't set --> whatever inside this folder it will look for a name? --> Oh, we can, we'll talk more about paths in a little bit, --> but for right now, just keep in mind, --> like if any kind of character data --> or string data that I wanna store in here, --> this is how I would do it. --> So I declare this variable, --> and then I'm able to assign stuff in there --> using the equal sign. --> So equal sign is what's gonna allow me --> to actually assign data into that. --> Great question. --> Yeah, we'll talk more about files --> as we work with files later on. --> So, oh, go ahead. --> Sorry, who was that? --> Is that Harry again? --> No. --> Oh, no, go ahead, Maria, I'm sorry. --> Oh, I was just gonna ask what, --> so you'll probably cover this later, --> so this might, I don't know. --> You might tell me, just wait, we'll get to it. --> But what is the difference, --> like what is the different use case for, --> you declare the type of a variable --> and then you set the variable --> versus using like the far keyword? --> Oh, absolutely, we'll talk about this. --> So I just wanna show you --> that there's actually two parts to this. --> So you can declare variables ahead of time. --> You're always gonna have to say, --> if I want things that I wanna track --> or I wanna store, --> you'll have to, ahead of time, let C-sharp know, --> here's something I am interested in tracking. --> So by saying string file name, --> I'm letting C-sharp know, --> hey, there's this data that I'm interested in tracking. --> I'm gonna call it file name. --> Here's the type of data that'll go in there. --> And then later on, I'll use that. --> And then when I decide to use it, --> I'll actually assign values or store data in there. --> So this file name equals read me --> is actually storing read me in that file name. --> And I think, Maria, what you were just asking is, --> well, couldn't I just do this instead? --> Couldn't I just say, for example, --> couldn't I just do something like this --> where I just say string first name and then equals it? --> You absolutely can. --> You can actually do both of those things at the same time. --> So you're actually doing two things at once here. --> So I'm just showing you that --> there's the declaring variable part --> and then there's the assigning it. --> And you can absolutely do both at the same time. --> That was your question, I think, right? --> Why would you do one versus the other? --> I think that was the other part of your question. --> Was that the other part? --> So if in this case, I know at the time --> that I'm creating this, --> I know exactly what that data is gonna be. --> I could just assign it right at the time I'm using it. --> What if I wanted to ask the user --> what file name they wanted the user, --> what their first name is. --> Or so for example, say last name. --> So here I could say, --> let's create a variable called last name. --> And I don't know at this point --> what data is gonna go in there. --> At some point later, --> I'm gonna ask the user what that information is. --> So I know that I need it. --> I would still have to declare that variable. --> And then later on, --> something will assign data into that. --> That's the only reason you would do one versus the other. --> Does that answer your question? --> Yeah, thank you. --> Perfect, okay. --> So the only other question we have now is, --> we know that we have to have a name for variable. --> We know we have to have a data type. --> How do I know what data types are available --> or even what those different data types would represent? --> This is a question for you all, the class. --> How do I know what the data types are available --> or what's even out there? --> I would probably Google. --> Yeah, absolutely, absolutely. --> So you're gonna see Google as your friend, absolutely. --> So we're gonna, --> I'll provide you in the activity, --> you'll see that I'm gonna give you a list --> of different data types that are available. --> But yeah, absolutely, --> Google is gonna be your friend --> to know what those things are. --> And if you take a look here in the activity coming up --> in that read me for the activity, --> we're actually gonna give you --> some examples of what those different data types are. --> So here's a little chart --> that'll have different data types. --> Are you familiar with Boolean types? --> Do you use those currently? --> Okay, so everyone knows what a Boolean type is? --> So Boolean is really just true or false. --> If you're only storing true or false, --> there's a special data type for that --> that'll make that simpler. --> So that will be Boolean. --> There's a lot of data types in this list. --> We're not gonna use all of these, --> but the common ones we're gonna use, --> you'll see string we're gonna be using very commonly. --> And then there's actually lots --> of different data types for numbers. --> And the difference between those you're gonna see --> is what the size of the number you can store in there is. --> So for example, let me go back to my code window here. --> And let me just close this guy out. --> Yeah, it seems like it takes --> just a little bit of time there, unfortunately, --> a little bit of a... --> Let me move this window around. --> Zoom wants to sit on top of everything --> at the bottom of the screen, apparently. --> Here we go. --> So let me go ahead and show you. --> Hmm, yeah, it's interesting. --> I actually picked a larger size machine --> or more memories that these would open faster, --> but it still seems a little bit slow. --> Yes, seems like everything looks good on my end. --> Yeah, yeah, it's interesting. --> It still takes a little bit of time, but... --> All right, so let's take a look. --> So here we were talking before. --> Let me zoom in on that for you --> so you can see what I'm talking about there. --> So we were talking before that file name --> is a good example. --> Again, you're gonna have to have a name for a variable --> as well as the type of the variable. --> And then when you're assigning --> and actually assigning data to it, --> you'll use the equal sign. --> And then how would we actually use that data? --> Well, you can see here that when I'm writing some code, --> this right line we'll talk more about --> as we get further in, --> but this is gonna be a built-in ability for us --> to be able to write things out to the window. --> And so you're gonna see, --> if I just write out the name of that variable, --> it'll actually take and look at the value --> that's stored in that variable, --> and that's what'll get displayed on the screen. --> So if I run this, --> let me go ahead and hit the little green play button --> here, the start button. --> It'll build that code --> and run that. --> And you're gonna see when it writes that out, --> it's gonna say the name of the file is, --> and it's not writing out the variable name, --> it's actually writing out the value --> that's stored in that variable. --> And hopefully this is fairly straightforward --> from the stuff that you've done already --> in your current work. --> And obviously, if you have any questions, --> I think a lot of you have the Python background. --> If you have any questions about --> something that behaves differently --> or works differently in C Sharp, --> definitely call those out as well. --> So let's look at some other examples of types here. --> Oh, it's showing the background, there we go. --> So let's look at some other examples. --> So here we have char, we have char grade equals a. --> What's the difference between this char? --> Why am I doing that? --> And then I'm using the single quotes. --> And then here for file name, --> I add a string and I'm doing the double quotes. --> Any ideas what's going on there? --> They're both letters, right? --> So why would I need double quotes for this one as a string? --> And then for this grade, --> I only have a single quotes in char. --> Any ideas why? --> Because on the double quotes, --> I think you wanted that to write print --> exactly as read me. --> And on the character and grade, --> the A, you want to find anything with A. --> Am I correct? --> That's a good guess actually. --> But what's happening here is --> a string is gonna be multiple characters. --> So if I have something that's gonna be --> more than one character, --> and so this example, I've got read me, --> or here I have a sentence that says --> the name of the file is. --> Because I have multiple characters, --> I don't necessarily know how long it's gonna be. --> It could be one character, it could be 20 characters. --> So quotes is gonna be how I will use --> if I have multiple characters. --> And I'll use a string data type for that. --> So string data type can be any length. --> It's not limited to a certain size. --> This character data type --> is actually just a single character. --> So the only thing that'll fit into that variable --> that I can store in there is just that letter A. --> And you're gonna see, so as a result, --> I'll use the single quotes around this A, --> and that's all I can store in there. --> Why would it matter? --> Why do you think it matters --> if having this character data type --> versus a string data type? --> Why would I use this here? --> Why wouldn't I just use maybe string everywhere? --> Does it compile faster? --> It's really efficiency, right? --> So if I know up front --> that I'm only gonna store a single character in there, --> then this is much more efficient --> because it's only gonna set aside space for one character --> and it's gonna allow me --> to work with that data more efficiently. --> If I don't know up front, --> or I know that I have multiple things --> that I'm gonna store in there, --> then I would use the string data. --> So yeah, so it would actually compile faster, --> but it's really about the storage --> that you're setting aside. --> So same idea here. --> Let's look at these different numbers. --> So I've got all these different data types for numbers. --> Int, long, float, double, decimal. --> Why do you think there's so many different data types --> for numbers? --> I would think storage is efficiency, --> like you mentioned earlier. --> You've got to have enough storage --> for these different lengths of numbers. --> Yeah, that's absolutely right. --> And the other thing too is that you're gonna see, --> so for example, an int is an integer. --> An int is gonna be a whole number. --> There's no decimal part of that. --> So if I know right up front, --> just like Lisa was saying, --> if I know right up front --> that I'm not storing any decimals in there, --> it's more efficient to store as an integer. --> And also when I start doing math operations, --> it's gonna handle that a little bit differently, right? --> With an integer, there's no decimal part. --> So I'm always gonna just get whole numbers. --> If I do care about the decimal part, --> then I would have to use a different data type. --> What's the difference between long and int, --> do you think, just from looking at the data --> that I'm showing you here? --> I think it's still something higher than you --> under that certain limit. --> Yeah, so int, exactly. --> Int is looking for a certain size number. --> And if you know your number is under that certain size, --> then you can store it as an int. --> And again, you're just gonna save --> a little bit of space memory-wise. --> It's gonna work a little bit faster. --> And then if your data exceeds that, --> then you can use the long --> and then that'll have more space, right? --> It'll allow you to store larger numbers in there. --> And you're gonna see some similar scenarios too. --> So here, if I do have decimals, --> you're gonna see there's actually three different data types --> that let me work with decimals. --> So I'll have floats, doubles, and decimals. --> And the difference that you're gonna see there --> is the precision. --> When I say precision for a number, --> what does that mean? --> Does anybody know what that means --> when I'm talking about numbers and precision? --> Like significant figures in calculation? --> Yeah, absolutely. --> So what'll happen is I have the numbers --> that are to the right of the decimal point. --> And the more numbers that I have --> to the right of the decimal point, --> I can be more precise, right? --> So if I only have two numbers --> to the right of the decimal point --> and I'm doing addition, division, things like that, --> I might wind up losing some of that information --> because I don't have enough space to store it. --> So for certain things that won't matter, right? --> So if I'm trying to figure out --> like an average or something like that, --> it might not matter. --> When do you think it does matter though? --> When does that precision really make a difference --> for most people? --> Money. --> When we talk about money, right? --> So with money, do you care if you lose that cent or not? --> Absolutely, right? --> So that's why we actually have a special data type --> in C Sharp called decimal that'll be the most precise. --> So when you're working with money, --> this is gonna have a very high precision --> so that you're gonna not lose those pennies, right? --> That's fine, those financial calculations. --> For these other numbers, you'll notice --> I just have the number of value. --> And then for these float, double, and decimal, --> you'll see there's actually an F there --> and then there's an M after that. --> Why do you think that I have to have --> that sort of extra character on there --> for those different types? --> Yeah, what'll happen is that if I don't put, --> so they're all decimals, right? --> If I don't put the decimal, --> C Sharp will try to guess what type of data that is. --> And by default, it's gonna guess --> that this data is a double. --> And so I can actually put an extra character --> to sort of say, no, this actually is a float. --> So I can sort of help give C Sharp a little bit of a hint --> when I'm trying to convert these to different numbers --> or store these different numbers. --> And then you would think decimal would be D, --> but of course it's M. --> So I think M is money, --> but it's a little bit different than what you'd expect. --> Float is an F, but decimal is actually an M. --> And again, all these different data types, --> the importance you're getting with those --> is the precision for the numbers, --> and then you're setting aside a certain amount of space, --> and you're telling C Sharp, hey, --> this is the kind of data that I'm gonna store in here. --> And then obviously with the Booleans, --> you're just getting those values of true or false. --> Some languages you'll see are not case sensitive. --> C Sharp is case sensitive. --> So this lower case true is what you're gonna see, --> or lower case false. --> If you try to type, --> Visual Studio is gonna give you a lot of help actually. --> So if you try to type this, for example, as cap, --> you're gonna see it's not buying that, right? --> It's telling you right away, like that doesn't exist. --> So you're gonna see the two are in false. --> And then the same idea, --> if I write these out to the console, --> so if I write the value of grade, console write grade, --> it's gonna write the value, --> not the name of the variable. --> So grade will write out whatever that is. --> In this case, that's an A. --> It's showing my Zoom window here. --> Let's move that a little bit. --> Gonna adjust. --> Okay, there we go. --> So same idea, for all these variables, --> it's gonna write out the value of that variable. --> It's smart enough not to write out the name --> and notice you're trying to use the value for those. --> What else I wanna show you? --> Oh, typically, and this is sort of a best practice thing, --> but typically naming variables in C Sharp, --> they're gonna be lower case. --> And then you're gonna see that they use --> camel case is what we call it. --> So for example, total population, --> we're capitalizing the other words in that variable name. --> Height and meters, we're capitalizing the I and the M. --> Does it matter what you name your variables? --> Is the code still gonna work? --> The code will still work, right? --> But this is just a typical common practice. --> And if you're looking at other people's code --> or people are coming to look at your code, --> this is just sort of what they're expecting as practice. --> Every language that you work with, --> I'm sure Python has its own naming standards and variations. --> The important thing is really to be consistent --> in your application. --> So this is the common C Sharp standard. --> Again, the important thing is to be consistent. --> And the important thing too is to name your variable --> something that makes sense, right? --> So here, if I just put speed, --> you might know what it is, but you might be like, --> well, what's that speed represent? --> Is that 110 miles an hour? --> Is it 110 feet per second, right? --> So just having consistent, well-named variables --> is only gonna help you later. --> I could name these, right? --> G, S, T, H, Z, X, right? --> But that's gonna be so much more confusing later --> when I'm trying to look at that and figure out. --> Any questions before we try using some variables, --> declaring a few variables and using them in our code? --> Fantastic. --> Let's take a look at this next activity. --> This will be 04 variables. --> And if you look at the README file, --> it's gonna have some information --> about those different data types. --> And then at the top of this, --> it'll have some directions --> about what we're gonna do here, --> as well as we're giving you some sample output. --> So what your output should look like. --> And then the starter code, --> if you open that up in Visual Studio, 2022, --> open that solution file, --> and that'll already have all the starter code. --> And then all you'll have to do is go --> into your program file and start writing your code. --> All right, so let's take a look. --> Let's try this activity. --> We'll do this for about 10 minutes as well. --> And then we'll come back and take a look and review that. --> I don't see if you have any questions at all. --> Please ask. --> I can easily share your desktops --> and help out wherever we need to. --> I'm already lost to try to find that file, sorry. --> Oh, no problem. --> Let's see. --> Let me take a look at your desktop there. --> When to desktop, cash for automation, --> lesson one, activities. --> Let me see. --> Let me go to your screen really quick. --> Yes, so go into, it's the variables, 04 variables. --> And then inside there, there's a starter. --> Yeah, that was the thing. --> Yep, and then there'll be a solution file. --> If you just double click on that. --> Solution file. --> The .SLN, yeah, that file, yep, right there. --> Right here? --> Yep. --> Okay. --> Yep, and that'll open --> and then it should have all your files --> and everything for you. --> Yes. --> So on the right side of your screen, --> can you see the mouse on your screen or no? --> Oh, I see mine. --> I see mine. --> Okay. --> So expand variables. --> Yep, expand that. --> And then there's a program.CS file. --> Just double click on the program.CS file. --> Yeah, right there. --> Yeah, perfect. --> And then that'll open the code up for you. --> And so see on line nine there, --> there's a little comment that says --> to do about writing your code here. --> Yeah. --> So that's where we're gonna write some code. --> And if you look at the activity instructions, --> it'll walk through the code that we wanna write in there. --> And the activity instructions are where? --> So go back to your Windows Explorer --> that you were just in. --> Yep, right in there. --> And go back up to the variables folder. --> So at the top of your screen there, --> there's in your path at the top. --> Yeah, just click on variables. --> Yep. --> And then there's that README file right there. --> And so here are the instructions that it says, --> open the variable solution. --> And then line eight. --> This is what we want you to do. --> We want you to create some variables --> to hold some values. --> So we wanna have you create a variable for your name, --> a variable for the number of years --> programming experience you have, --> your ideal salary and dollars, --> and whether you are excited to be here. --> And then you'll obviously, --> we'll have you create those variables --> and then we're gonna have you display those, --> the values of those. --> Oh, is there a question in the chat? --> Oh, okay. --> So it's 11, or headed towards 11 for you, right? --> Am I doing my time right here? --> It's 10.30. --> Okay, okay. --> So I'm gonna try to make sure --> we plan our breaks accordingly based on your time. --> So not my time zone. --> Okay, so I'm gonna try to make sure --> we plan our breaks accordingly based on your time zone, --> okay? --> Okay. --> Another minute or so, and then we'll take a look. --> Let me just adjust my zoom with Windows here. --> Let's see, hide that. --> And put this back. --> There we go, okay. --> Let's zoom out a little bit. --> It's kind of out of the way a little bit there. --> All right, so let's take a look. --> I'm gonna close this off here. --> So as we're working these different activities, --> are you able to see my screen? --> Yes. --> Okay. --> So as we're working these different activities, --> so you'll see I'm in this activities, variables folder, --> and each of these is gonna have that solution file, --> right, that .SLN. --> You're gonna just double click on that --> and that'll open it up into Visual Studio. --> And then once that opens, you're gonna see, --> it takes a second there. --> Let me just zoom on this for you. --> You'll see that once that opens, --> what happens there? --> Why is that displaying it like that? --> Let me hide zoom for a second. --> It's trying to minimize that window. --> Oh my gosh, okay. --> Well, that's not gonna work. --> Let me try this again. --> Put this down here. --> Is that gonna do? --> Oh, it's auto sizing this window now. --> All right, well, one second here. --> Okay. --> Are you able to see that? --> It's not very zoomed in, I don't feel like. --> Is that big enough for you to see --> what I've got showing on the screen there? --> Yeah, let's get them in. --> Okay. --> So if I double click on that program.cs file, --> it's gonna open the solution for me there. --> And we're gonna give you some comments here --> about where to put your code. --> So a couple of things to call out. --> One is that if you wanna do comments, --> the little double slash indicates that it's a comment. --> So Visual Studio and C Sharp will ignore --> whatever is on that line. --> So comments are super useful for leaving yourself notes. --> In this case, we're leaving you a note --> to say where to put your code at. --> I like to think of comments as a way --> for current Shane to let future Shane know --> what the heck current Shane was thinking, right? --> So a lot of times when you're writing code, --> you may write something that's not obvious. --> And if it's not obvious, --> you're not gonna remember later what it was doing, right? --> So it's very useful to be able to leave yourself --> a little note that you can look at in the future --> and go, oh, that's what I was doing here, --> that's what this calculation is doing. --> You can easily do that by using the little double slash. --> In Visual Studio also, and on your toolbar, --> you're gonna see there's these little buttons here, --> these toggles. --> And if you have something highlighted, --> you can just click this to easily comment --> or uncomment a whole block of code. --> So sometimes when you're writing code, --> you'll try something and you'll be like, --> I'm not sure if this is gonna work, right? --> So you'll try something like this. --> And you can easily use these buttons. --> So if I click this comment button, --> you're gonna see that it'll automatically --> comment that out for me. --> And then if I wanna uncomment that, --> there's a button right next to it here --> that does the same, this removes. --> Oh, did I click it? --> Apparently not. --> Yeah, there we go. --> So you get the option to do that as well. --> So what do we need to do for this? --> We needed to create some variables --> to represent the data we wanted to store, right? --> And so one of the two things that I need for variables --> in order to create a variable. --> I need a data type, --> and I need to be able to have a name of it, right? --> So for this one, --> I wanna store some data. --> I wanna store string data in it, --> so I'll call it string. --> And I think I wanted to store like my name, right? --> So we're storing in this. --> And we're gonna assign that some data, right? --> So obviously not my real name, --> this is just a sample data name. --> So we'll store value in there. --> And then remember, semipole, --> and I was gonna put that on the end --> to indicate that's the end of that line. --> What else do we wanna store? --> We wanna store years of experience. --> What data type should we use for years of experience? --> Yeah, integer probably makes the most sense. --> I mean, you could use a decimal value for that, --> but integer is probably enough --> for what we wanna do there. --> And so I'll just call this years of experience. --> And we'll say 20, --> just round it off there. --> What about salary? --> What kind of a data type would you expect to use for salary? --> Yeah, so as soon as you think about money, --> I would always use a decimal, --> just because that's gonna handle the rounding better. --> And so you're not gonna lose those imported pennies. --> And I don't know, let's just say 220, right? --> That sounds good. --> And what was the last thing when you did? --> Oh, whether you're excited or not. --> What data type would that be? --> It should be a true or false, right? --> Yeah, absolutely. --> Oh, can't spell apparently. --> And then we'll assign a value to that. --> And you're gonna notice too, --> as you're typing in this, --> Visual Studio is actually doing --> a lot of guessing for you, right? --> So as I start to type, for example, true, --> you see how it's giving me the option to accept that, --> so I can hit the tab key to accept that. --> So Visual Studio is actually gonna try --> to help you write your code. --> So some of the things it suggests are great. --> Some of the things it suggests are not so great. --> So you're still gonna have to kind of pay attention --> to what it's asking, --> but just be aware that it does try --> to give you a lot of help. --> It's also giving me some help here. --> What is it? --> Why are these all underlined with green? --> Yeah, so it's actually doing two things. --> Because I've declared these variables, --> but I'm not using them anywhere, --> it's actually sort of graying out the names of these, --> as well as putting a little squiggly under there. --> And if I hover under this, --> it's actually telling me that this is a sign, --> but never used. --> So it's actually pretty useful. --> If you have actual code that you're working on, --> and you see that, --> it's telling you that at some point --> you declared that variable, --> but you didn't really use it anywhere. --> So you can probably get rid of that variable --> is what it's telling you. --> All right, let's go ahead --> and write the values of these out. --> So that would be console write line. --> And again, here, as I'm starting to type this, --> you'll notice it's suggesting --> what it thinks I'm gonna do there. --> And so we can write those different variables out --> just by using the name of those variables. --> And then obviously semi-colon to end all of those. --> Any questions on this? --> So hopefully this is fairly introductory stuff for you --> as far as just maybe doing it a little bit differently. --> Python doesn't require the semi-colon, right? --> But does white space matter in Python? --> Is like the indentation pretty important? --> Yeah, so in Visual Studio, --> the white space doesn't matter at all, right? --> So I can put tons of white space here. --> I can put this way over here. --> This will make you crazy as a developer, --> but C Sharp doesn't care at all about the white space. --> Another thing that you can do as well --> is when you're in these different files, --> if you do the menu, the right-click menu, --> you're gonna see a lot of times you'll get... --> I can't believe it doesn't hide the Zoom thing in there. --> That's crazy. --> Let's see here. --> Let me see if I can move that. --> Toggle it off or something. --> A lot of times it'll give you suggestions --> in formatting as well. --> So it'll give you tips to help format your code. --> It's not showing up in the menu here, is it? --> I don't believe so. --> But you do get these different quick actions --> that you can do. --> Oh, that didn't disappear for me there. --> So white space, again, not important. --> Semi-colons, very important. --> What else? --> I want to show you this one. --> I think that's really it. --> And then again, the data type. --> Somebody, I forgot you said this earlier, --> maybe it was Lisa, about --> how do I know when data types are available? --> Google is definitely your friend. --> If you have a question about it, --> absolutely just do a quick Google search --> and you'll find the answer to the information. --> The majority of times it's gonna be the numbers --> when you're looking at those --> to try to decide what type of data am I storing --> and does that precision matter on your numbers? --> A lot of times you're gonna see --> we'll be using very similar data types --> as far as strings and integers and Booleans. --> So very common data types. --> What other questions that I have for you on this? --> Let's see. --> Oh, sure. --> Oh, so that's a great question actually. --> So what's interesting is there is actually a data type --> in C-sharp that they added called VAR. --> What does VAR do for me? --> Any ideas? --> It tries to guess what you're trying, --> like the data type you're trying to use. --> Yeah, so what VAR will do is --> C-sharp is strongly typed, --> which means that every variable --> has a specific data type associated to it --> and you can't store data of a different type --> in that variable. --> You have to do some kind of conversion, right? --> So the VAR, if you look at this, --> it is actually still strongly typed. --> So this, my name is actually still a string. --> If I hover over that, --> you can see that that's still gonna be a string. --> But VAR is basically telling Visual Studio --> to figure out the type for you. --> So you actually can use this to declare a variable. --> And how does it figure out what type of data --> is what my name is, what the value that is? --> It's actually gonna look at the data --> that you're assigning to it. --> And so since this is a string, --> it's gonna assume that's a string. --> So here's what I would say, --> what I would recommend is when you're first learning --> to use the language, --> I would suggest that you actually explicitly use --> the data types that you want. --> That way you know what you're getting. --> And then as you get more familiar --> with using C Sharp and the data, --> then you can decide when to use VAR or not to use VAR. --> I think beginning it, when you're first learning it, --> it's better to make sure --> that you know exactly what data type it is --> and you're telling C Sharp what data type to use. --> And then later on you can experiment with VAR --> and see how it works or how it assigns the values. --> Does that answer your question? --> Yes, it does. --> Perfect. --> The other reason you might use VAR --> is sometimes when you're working, --> and you'll see later, --> we'll talk about variables can be things --> other than these few data types. --> And we'll show you some more examples --> when we start doing that as well. --> Great question. --> Let's take a look at now. --> We've got these data that we wanna track --> where we've got variables. --> And now we're gonna learn about using some operators --> that'll allow us to work with those variables. --> So let's take a look. --> I'm gonna go ahead and close this. --> Yeah, it's just a little bit. --> I can't tell if it's the machine. --> I feel like it's my connectivity to the machine --> that's like a little bit lagging maybe. --> So let's take a look at operators. --> So operators are gonna be things --> that allow us to work with our variables. --> And you'll see that they're kind of grouped --> into some categories here. --> Once this opens up. --> Okay, so they're kind of grouped into some categories. --> So there's gonna be operators --> that allow us to do arithmetic operations. --> There's operators that allow us to do logical operations. --> There's also equality operators. --> And then finally, we'll look at comparison. --> So all of these operators are gonna allow us --> to work with our variables --> and do different things with those variables. --> Oh, let me zoom in on that as well. --> Hopefully this zoom will work. --> There we go. --> All right, so let's take a look at arithmetic operators. --> So you're gonna notice that this is in yellow --> and there's this little arrow on the side of my screen. --> I'm gonna call this out right while we're looking at it. --> This has nothing to do with your code. --> It doesn't affect your code in any way. --> But C Sharp does have this kind of cool comment. --> If you put a little hashtag in front of it, --> this region allows me to say, --> hey, this region of code is related. --> Let me see if I can hide this silly zoom window thing here. --> Let's see. --> Doesn't it, it's like Control-Alt-H --> or something silly, right? --> Let's see, hide Control-Alt-Shift-H. --> That's easy to remember. --> Let me show you this region. --> So this region in my code here, --> I've created a region --> and there's a end region tag down here. --> This doesn't affect the way your code runs at all. --> It's just a way for you, --> particularly in demos like I'm showing you, --> to have a block of code --> that you can sort of hide or collapse. --> So it's completely a UI thing. --> Doesn't affect the way your code runs at all. --> So when you see that, --> just be aware that's what it's doing. --> And it doesn't affect the way the code runs. --> It's just something that might make it --> a little bit easier to work with that block of code. --> So let's take a look at some different --> arithmetic operators we can do. --> So I've got some numbers here online, 11 and 12, --> that we've declared and assigned some values to. --> And we're gonna support in C Sharp, of course, --> all of the basic math operations. --> So if I wanna add two numbers together, --> I'm gonna use the plus, right? --> So number one plus number two. --> And then what am I doing here? --> I'm storing the result of that --> in a variable called result. --> And so plus is how you do addition in C Sharp, --> minus, not surprisingly, right? --> That's how you do subtraction. --> I think this is similar to Python, right? --> The asterisk is multiplication --> and then the forward slash is gonna be division. --> Any questions on those? --> Hopefully those are fairly familiar operators. --> So math-wise, we've got plus, minus, --> multiplication and division. --> What is the percent here? --> What does this operator do? --> Any ideas? --> Yeah, so sometimes it's important to know --> not the result of the division, --> but you wanna know what's left over. --> So this percent is actually gonna take number one, --> divide it by number two, --> and then we call it in C Sharp, --> they change the name of it actually. --> It's called the remainder operator now. --> It literally is gonna give you what's left over. --> So if I had, for example, seven divided by two, --> what is the remainder operator --> gonna put into result for me here? --> One, yeah. --> So it'll say, hey, seven divided by two, --> okay, it goes in there evenly three times --> and there's one left over --> and that's what goes into that result. --> So that's probably one that you may or may not --> be familiar with from other languages. --> Does Python use the percent also? --> Yeah, it does. --> Okay, perfect. --> So those are the math operators, --> pretty straightforward, hopefully. --> Let's take a look at the next block here. --> So logical operators. --> So here we've got some Boolean values that we've defined. --> So is big, is green, is quiet. --> And we can write some of these values out. --> So what does the little exclamation point do --> if I put that in front of my Boolean operator? --> Is it like a knot? --> Yes, exactly. --> So what it'll do is it'll say basically --> whatever the value of this is, --> so is green is true --> and with the exclamation point in front of it, --> it'll be a knot. --> So this is basically saying not true, right? --> So the result of that would be false. --> And you're gonna see, --> we'll actually use that exclamation point, that knot, --> quite a bit in our C-sharp code. --> So this is one example of that. --> I can put that in front of a Boolean value --> and it basically swaps the value of that. --> So if it's true, --> putting the knot in front of it makes it false. --> If it's false, --> putting the knot in front of it makes it true. --> Are all of you familiar? --> How do you feel about Boolean operations --> on like one fist to five? --> Everybody's pretty familiar with ands and ors and knots, --> that type of stuff. --> Okay. --> So C-sharp of course has logical operators. --> In C-sharp, we use the ampersand to indicate an and. --> So if I have is quiet and is green, --> both of those values have to be true --> in order for the result to be true, right? --> Same idea, both of those values have to be true --> in order for the result. --> So when you're using the and, --> if either one of those variables has a value of false, --> the result would be false. --> Right, and says that everything has to be true --> in order for the result to be true. --> And we use the ampersand for that in C-sharp. --> In C-sharp, we use the pipe symbol for or. --> So this is is quiet or is green. --> And the pipe symbol, if you're on your keyboard, --> that's right above your forward slash. --> So your enter key typically forward slash --> is right above there. --> And if you do the shift on that, --> that's for your pipe symbol, --> it's a straight up and down line. --> So that's represents or in C-sharp. --> All right, so let's talk about some differences --> C-sharp has. --> What do you think the double and is doing in C-sharp? --> I don't believe to use the double and in Python, --> is that correct? --> So what'll happen here is with an and, --> both of these values would have to be true --> in order for the result to be true. --> So if the computer looks at is quiet --> and his quiet is false, --> it doesn't have to look any further, right? --> It can tell already, well, this one's false. --> I don't even care what the value of this is, --> the result is false. --> So if you use the double and percent, --> it allows you to do what we call short circuit, --> because it basically says, --> if this value is false, --> I don't even care what the second value is, --> I don't have to look at that --> because I know that they both have to be true --> in order for it to be true. --> So as soon as it sees a false here, --> it actually doesn't execute the rest of this. --> Why does that matter? --> Why do you think that's valuable or useful? --> It's really just exactly, --> it's just a time saver, it's more efficient. --> It can literally just say, --> and right now we've just got --> these kind of two simple conditions, --> if these things were a little bit more complicated, --> but yeah, it's really just a time saver. --> It hits this first part, --> it's like, I don't even have to continue. --> With the double and percent, --> oh, was there a question? --> I was just thinking like, --> why would you ever use just one and percent then? --> That's a good question. --> It depends on what you're evaluating. --> Sometimes you actually want to evaluate both sides of it. --> It just entirely depends upon --> what it is that you're checking --> or what those conditions are. --> If it doesn't matter, you can use the AND. --> You're gonna see this used a lot though, --> because you're typically trying to do it faster, --> and a lot of times the things that you're comparing --> are fairly complicated. --> And so, if you can save time --> by not even looking or evaluating this side of something, --> you're gonna do that. --> So you'll see the double and percent used quite a bit. --> What happens if this is quite as true? --> And we still have to check both sides, right? --> The only time the short circuit works --> is actually if the first value is false. --> If this is true, --> the other value could be false, --> so it still has to look at the other value, right? --> And same idea we'll get for, --> let me just scroll down a little bit. --> It's so weird that it doesn't move that automatically. --> Same thing we'll get with the double and percent. --> This is gonna be short circuit also. --> So with the short circuit, --> with an OR, either condition can be true, right? --> So same idea here. --> If the first value is true, --> it doesn't have to even look at the second value. --> So you get the double and percent, --> or not and percent, --> the double pipe symbol for OR as well. --> Any questions at all on that? --> That should be fairly straightforward. --> I think it's the short circuit one. --> It's probably something different in C-sharp --> than what you get in Python. --> All right, let's take a look at --> our equality operators here. --> Oops. --> Okay, so equality, --> we're gonna check and see if something is equal, right? --> So here I've got total one --> and we're signing at this value one plus two plus three --> and total two we're signing at this value six. --> So in C-sharp, we're gonna use the double equal sign. --> We wanna check if something is equal. --> So in this case, is total one equal to total two? --> Right, yes, because six equals six. --> So the double equals is gonna check --> if something is equal. --> And the single equals, --> we're using when we're assigning it. --> So we're assigning the value of six --> to total two with the single equals --> and we use the double equals when we wanna compare --> if those values are the same. --> Let's take a look at that with characters as well. --> So here I've got character data. --> I've got the lowercase a and the uppercase a. --> Are those equal? --> No, because it's case sensitive, right? --> So lowercase a is not equal to uppercase a, right? --> So C-sharp is case sensitive. --> All right, we can also check, --> just like we checked if something is equal, --> we can check inequality --> or we can check if it's not equal. --> So here, just like we saw before --> with the exclamation point, --> the exclamation point is gonna be our not. --> So this is basically saying not equal, right? --> So score not equal to score two. --> And in this case, that's true, right? --> Because seven doesn't equal six. --> So anytime I wanna check inequality, --> I can do the not equal. --> All right, what about this? --> So I've got two strings, --> message one, hello, message two, hello. --> If I check if those are not equal, --> it's gonna tell me false. --> Why are these equal? --> There's two different variables. --> Why are those equal? --> The value assigned to most of the variables is equal. --> Yes, exactly, exactly what Lisa said. --> So in some languages, --> when you're checking if something is equal, --> it would actually look to see --> if the variable is the same. --> C-sharp in this case is looking at the value. --> It's checking the value of those --> when you're checking the equality. --> So it's looking at the value stored --> in each of those variables. --> And because that value is the same, --> it's gonna say that those are the same, right? --> So just be aware of that. --> That's slightly different. --> I don't remember Python equality. --> Would it tell you those are the same --> because they're different variables? --> It compares by value. --> Does value as well? --> Okay, perfect. --> So very familiar what you're used to then. --> All right, so those are equality. --> Let's look at our final group here, --> comparison operators. --> And let's see, we're coming up on about 11 o'clock. --> So we're gonna do, I'll finish this demo. --> We'll do the activity --> and then we'll do our first, --> we'll do basically two 15-minute breaks a day --> and then we'll do an hour for lunch in the middle. --> So coming up here, we'll do an activity --> and then we'll do a 15-minute break after that --> before we review and then we'll keep on rolling. --> All right, let's take a look at comparison operators. --> So here I've got some variables declared, --> some heights, one, two and three. --> Less than, I think this is very familiar to you --> as well in Python. --> We're gonna use the less than symbol. --> It's pointing to the left. --> So we're saying height one is less than height two. --> And in this case, that's false. --> Greater than, we're gonna use that greater than symbol. --> Again, this is saying is height one --> greater than height two. --> Sometimes you wanna know if it's included as well. --> So here we can also do less than or equal to. --> So there's the less than symbol and then equals. --> So we're saying if height one is less than height two --> or if they're the same value. --> So you can actually check both of those conditions --> at the same time, less than or equal to. --> And same idea with greater than or equal to. --> I don't think that's any different --> than what you're, which you'll be able to in Python. --> I think that's very similar as well, right? --> Okay, let's take a look at an activity. --> So in this activity, we're basically gonna have you try --> taking a look at some existing code --> where we're doing some of these different operators --> and writing down what you think --> will be the result of those. --> And then we'll run that code to see how close you were, --> how accurate you were with understanding --> what those different operators are doing. --> Let me show you this in here really quickly. --> So let me go Hello World variables. --> So this is gonna be your operators activity. --> And if I open the preview for that. --> So here we're gonna have you evaluate operators --> and determine what the result that will be written out --> will be. --> So we're gonna take a look at that operator solution. --> And then you'll see there's a bunch of comments --> in there with to-dos where we're asking you --> to answer some different questions. --> And then of course, give me a note that, --> be prepared to discuss your answers. --> And then we'll have you build and run the code --> to see your output. --> So if you take a look at that starter code, --> it's in there. --> So I will open that for you really quick. --> So activities. --> That was in the right folder. --> Operators starter. --> And then if you open this solution, --> you're gonna see that there's a existing code --> already in here. --> We're not having any write any new code for this activity, --> but we'll have you take a look at the existing code. --> So again, those regions, --> you're gonna see they're collapsed. --> You can just click the little arrow, --> the care there to expand those. --> And so we just got a series of operations --> and we're basically asking you, --> what's this gonna write out? --> To the console. --> So just some quick understanding --> of what those different operators are gonna do, --> or what they're gonna output. --> So as you expand those, --> you'll see there's quite a few of these. --> And then once you're finished putting your, --> you can write in a comment, --> you can put what you think the result will be. --> And then once you're finished with that, --> we'll run that and we'll actually take a look and see, --> was there anything unexpected? --> Is there an operator in there --> that the output is different than what you thought? --> All right, so about 10 minutes on this, --> and then we'll do our quick break. --> And then we'll come back from that and do a review. --> Any questions on that? --> All right, fantastic. --> Let's take a look at that. --> And we'll stop here. --> Once I remember that crazy sequence, --> Control-Shift-Alt-H. --> Okay. --> Whoa. --> Okay. --> It'll take about a minute or so here, --> and then we will take a quick break. --> Like most of you are already running it --> or looking at your results. --> Yes, that's happening. --> So we'll do a 15 minute break now. --> And then this is what, 11, 15 for y'all. --> Normally we would do 15 minute break. --> And then the middle of the day, --> a class would do like 60 minute break for lunch. --> Since we're kind of on different time for that. --> I don't know. --> We'll see how that works out. --> Cause you're getting a 15 minute now. --> And then the 60 minute break is gonna be --> kind of in your afternoon, I guess. --> But we'll try this. --> We'll see how it works. --> And then we'll do from now, 9, 10 until 9, 25. --> I'm sorry. --> We'll do a 15 minute break. --> So what, that's 11, 10 for you to 11, 25. --> And then we'll come back --> and we'll do a few more activities before our big break. --> Any questions? --> I'll see you back in about 15 minutes. --> Yeah, it's weird. --> So they're gonna get a 15 minute break. --> It's already 11 for them. --> Yeah, that's just a weird, weird time. --> 25, we'll already do that. --> Any question? --> So that's nine to four. --> 9 to 10, 10 to 11, 11 to 12, 11 to 12, --> 1 to 2, 2 to 3, 2 to 4, 7 on. --> I totally knew something, I thought you were asking me. --> Oh, yeah. --> Welcome back. --> Let's take a look at some code here. --> Don't bother. --> Don't bother, you're fast. --> Do you write code quite a bit in your current role? --> No. --> No. --> Oh, okay, okay. --> I saw there was a- --> So, I'm sorry. --> Oh, no, good, no, I'm sorry. --> No, I'm just saying that I'm just starting --> to learn Python, I'm not very far into it. --> And I'm trying to keep up with you --> doing what you're doing. --> And it seems logical when I see it on your screen --> and then when I go into mine to do it, --> it's like, I don't know what the flip you did. --> Yeah, I understand that. --> So, I'm trying to keep up with, --> but it's confusing to me when I'm trying to do it --> on my own, it's just not working very well. --> I mean, if it helps to do it, --> you're welcome to code along with me, --> while I'm doing the code, if that helps. --> But what I'm gonna do and then when you do the activity --> is gonna be like slightly different code, --> but very similar ideas. --> So, I don't know if that helps, --> you're welcome to do that. --> Yeah, Kayleen, in college what we used to do --> is we used to pull up the same program --> the professor opened and then we just create a comment --> and note it while he was talking. --> So, I have notes from the same program, --> whenever he opens, I just put note comments in there. --> So, it helps for you to remember --> and follow along with what he's doing at the same time. --> Well, that's a great suggestion, Alain. --> And if I'm going too fast as well, --> there is a timetable, --> like a schedule that we're trying to meet, --> but if I'm going too fast, --> like feel free to call me out, --> like I can slow it down. --> I'm trying to juggle that balance --> between making the schedule --> but still make sure everybody comes along with me. --> Right, so. --> Yeah. --> I don't know, he was just very passionate. --> So, he kind of went off the subject --> and then we had to go back and try to catch up. --> It's like, okay, well, my notes. --> Well, hopefully we're not quite that, --> but we'll try to get there. --> Let's see here. --> Let me move this to the side. --> Oh, what's going on with my desktop here? --> Need to refresh the browser maybe? --> Okay, there we go. --> That was a little scary. --> All right. --> So, take a look at this operator's activity --> that we were just working on. --> Can't tell, is it opening it or not opening it? --> There we go. --> All right. --> Gonna have to remember that. --> I got to refresh my desktop once in a while there. --> So, the big takeaway on this one really is --> that the important thing to our programs is data. --> And we're gonna use variables to store that data. --> And with this activity, we're learning about ways --> that we can work with those variables, --> either change those variables or compare those variables. --> And so, that's really the focus on this. --> This isn't a math quiz. --> I don't care if you got the exact numbers right, --> but really just understanding what's available to you, --> all these different operators that allow you --> to work with your variables --> and do different comparisons with those. --> So, on the first one, the other thing I wanna call out, --> and this is a takeaway, --> let me zoom in on my desktop here real quick, --> is that, oh, it's so strange, --> it leaves the start menu open. --> There we go. --> Okay. --> Is that when we're writing the results of these out, --> you can see, we can write variables out, --> as well as we can actually write out --> those expressions as well. --> So, here, C Sharp is actually gonna do that addition first, --> and then it's the result of that --> that's gonna get written out. --> So, you have that kind of flexibility both ways --> to do those. --> So, hopefully, the plus, --> the addition one is fairly straightforward. --> It's just gonna add those together, --> and you're gonna get that result out as a value. --> And obviously, as I go through here, --> if you have any questions at all --> on any of these operators or what the result was, --> please feel free to ask me that. --> No, that's actually a great question. --> So, even though those data types are different, --> so if you hover over those, --> you can see this is a double because of the decimal, --> and then this is gonna be an integer. --> What'll happen is when you're passing the result of that --> to this console write line, --> C Sharp is actually gonna try to convert those if it can. --> So, it's gonna say, I've got this decimal value, --> and I've got this different data type. --> Is there a way that I can still add those together? --> And so, what it'll do, actually, --> is it'll treat this integer as though it was a double. --> So, it'll say, hey, I can make this a double, --> and then I can add these two together, --> and I can get a double result. --> So, that's a great question. --> Even though those data types are different, --> it'll actually still try to use those for you. --> Was that what your question was? --> Perfect. --> And the other thing to be aware of there --> is a lot of times, --> you'll get some kind of a warning message. --> So, just like we saw those squiggly lines, --> you'll get some kind of a warning message --> in Visual Studio anytime you're doing something --> where you're working with two different data types. --> Even if the result still works, --> which it does in this case, --> Visual Studio will usually warn you and say, --> hey, FYI, those are actually different data types, --> and I'm gonna convert those for you, --> but just be aware. --> So, this case, it doesn't, actually. --> So, that's a good call out. --> And in other examples, --> you can see if you hover over these, --> these are actually two integers it's adding, right? --> And then here, you're also just adding those two decimals. --> So, that one is the only different one there. --> Same idea when you're doing the subtraction. --> So, in this case, again, --> because we're doing different values. --> And so, you're gonna see here, --> it actually, this is an integer, right? --> This is a double. --> So, it's actually gonna do the same thing. --> It's actually gonna say, --> hey, can I take one of those values and convert it --> so that they're both doubles, --> and then I can do the math operation on those. --> Multiplication, again, very similar. --> So, if it can do the result, --> it'll do that, and you'll get the result. --> If it does have to do some kind of conversion, --> it will. --> In this case, is it converting here on line 26? --> If you- --> Yeah, if you look, --> these are actually both, both have decimals, right? --> So, it actually doesn't have to do any conversion there. --> What about this? --> So, line 31, we're doing the console, right? --> Line 13 divided by nine, --> and I'm getting the value of one. --> Is that what you would expect for that? --> So, because these are both integers, right, --> that you're putting in, --> you're actually gonna get an integer value out. --> And so, integer means whole number, right? --> And so, you're losing any decimal --> that you would have there. --> So, again, when you're working with numbers, --> that's probably the trickiest thing --> to remember is that the different data types do matter --> as far as the, how accurate or how precise --> that result that you're gonna get back is. --> You know, if this was dollars, --> I would be very, very concerned --> that I was losing the percentage, right? --> And then same idea for remainder. --> It's gonna scroll the screen a little bit there, --> apparently. --> I think tomorrow I'm gonna do the code demos --> off of my regular machine, --> just because I think it'll be a little easier --> to zoom in and out here. --> For the remainder operator, --> again, you're only gonna get what's left over. --> And so, since these are gonna be integers, --> we're not keeping those decimals. --> What's left over is really zero, right? --> So, you're getting zero. --> Well, in this case, it's even. --> It divides evenly, so you're getting the zero. --> Any questions at any of the comparison operators? --> I'm sorry. --> Any question at any of the mathematical operators? --> All right, logical ones. --> This is ones where sometimes things --> you can easily get tripped up, I feel like. --> So Boolean passed variable, we're declaring as false. --> And so, if I write out not passed, --> I'm actually gonna get true as the result from that. --> So, remember that exclamation point --> is gonna do the reverse of whatever the value is. --> So, this value is gonna be false. --> And so, the reverse of that, --> the not of that is gonna be true. --> And this is just another example, too, --> of where naming your variables something descriptive --> can help because, --> you know, here, if I've got this variable called passed, --> when I see this line on line 50, --> you can almost read it, right? --> If you read the exclamation point as not, --> you're saying not passed, right? --> So, making your variable names descriptive --> can actually sort of help you --> when you're trying to look at code --> and understand what that code is doing. --> Why is this pink or whatever? --> Why do you think this true is highlighted here? --> That's a Boolean value that's recognized by C-charm. --> Yeah, it's actually a key word, right? --> So, just be aware that there are certain words --> that C-sharp is using and it's expecting to use. --> And so, those are actually words --> that mean something to C-sharp. --> So, just be careful that, you know, --> as you're naming things, when you're naming it, --> be descriptive, right? --> You don't wanna name something the same --> that a C-sharp keyword is --> because that's gonna not do what you expect, right? --> So, in this example, we're just showing you, though, --> that you can use that keyword true. --> When you're doing your test. --> And you can also use the not operator --> on that keyword, right? --> So, not true is false. --> Hopefully, these are fairly straightforward. --> So, with the and, --> the ampersand is gonna be our logical and, --> both parts have to be true. --> So, since this is false, --> the result is always gonna be false. --> The tool tips are trying to help me out there --> by getting in the way. --> So, false and true. --> Both of them have to be true --> in order for the result to be true. --> So, in this case, the first one is false. --> We're gonna get false as the out. --> If they're both true, --> like they are here on line 58, --> then the result would be true, all right? --> Gonna keep scrolling this thing, apparently. --> Okay, same idea with our or, right? --> So, the pipe symbol is gonna be the or. --> So, you can true or true. --> If either one of them is true, --> then the output will be true. --> False or true. --> Again, if either one is true, --> you're gonna get a true as an out. --> And then, always keep in mind, --> and you'll see this very common, --> commonly that they'll use the short-circuit version. --> So, the double ampersand, the double and, --> is basically gonna try to short-circuit, --> try to be more efficient, right, if it can. --> So, here, as soon as C-sharp sees --> that this first part is false, --> it doesn't even have to look at the second part. --> Doesn't have to evaluate it. --> They both would have to be true --> in order for the result to be true. --> So, as soon as it sees the false --> in that first position, it's done. --> It doesn't even have to look at the rest of the code. --> All right, similarly, if the first one is true, --> it can't short-circuit. --> It actually has to look at the second part --> to make sure that it's also true. --> Any questions on that, that short-circuiting? --> So, it's just basically, if it can, --> do it quicker. --> If it doesn't have to look at the second one, --> it won't. --> But, if it doesn't have enough information, --> it actually has to look at both parts. --> All right, and you can see the same thing here --> with the double-pipe sign, the or. --> Just allows you to short-circuit if you can. --> All right, let's look at equality. --> All right, so remember, the single equal sign --> is gonna be, whoop. --> There we go. --> Single equal sign is gonna be our assignment, right? --> So, we're assigning a value. --> So, we're gonna use the double equals --> to check if something is equal. --> So, if those values are equal, that'll be true. --> Here, --> the values, uppercase and lowercase, --> are not the same in C-sharp. --> So, those were equal will be false for that, --> because those are not the same in C-sharp. --> You can also test the reverse of that, right? --> So, inequality. --> So, with the exclamation point, --> we can check not equals --> to see if the values of those are not the same. --> All right, same thing we did in the demo, --> we're on the strings. --> They're actually the same because the value is the same. --> Here is a curveball we threw you, right? --> So, there's a data type we're using called object, --> and even though the values are the same on those, --> those are, in fact, not equal, --> because this equality for data type of object --> is actually looking to see if the object, --> the variable is the same, not the value. --> So, this is kind of a curveball to throw at you there. --> So, normally, in most scenarios, --> when you're checking that equality, --> it's looking at the value, --> but be aware that for object, --> and we'll show you some other scenarios, --> that when you're checking equality for those objects, --> that it's actually looking to see --> if the variable is the same. --> Even though the value is the same, --> it's a different variable, --> and so it's telling you it's not the same variable. --> Now, let's do some comparisons as well. --> Let's scroll again, let me pre-scroll here. --> Excuse me, enough, there we go. --> So, the less than, we're checking to see --> if this value less than this value, right? --> So, we're able to do those comparisons. --> Similarly, the greater than, right? --> So, is this value on the left side --> greater than the value on the right side? --> And then, you also have the ability --> to do less than or equal to. --> Why is this less than or equals to? --> So, 7.0 less than or equal to 9.1. --> Why would we do that versus just less than 9.1? --> What's the difference there? --> What is the equals doing for me there? --> It's including. --> I'm sorry, go ahead. --> Yeah, it's matching exactly to the 9.1. --> It's exactly, you said it's including it. --> So, if you're just checking less than, --> you're not including that 9.1, --> so it's only things that are less than that value. --> Sometimes you wanna make sure --> that that value is also included, right? --> So, you're doing less than or equal to, --> you're gonna include 9.1 --> and all the values less than that. --> So, sometimes it's important that you include --> that boundary, whatever that boundary value is. --> For example, if I said everything less than six foot --> and everything greater than six foot, --> I would be missing anything that was six foot, right? --> So, by saying less than equals to, --> I can say everything that's less than or equal to six foot --> and then everything greater than six foot. --> And so, I'm not gonna miss that six foot value. --> Any questions at all, anything there --> before we take a look at using these operators --> in our variables? --> I have a question. --> When do we use objects, the variable? --> Oh, actually, I'll show you. --> In C Sharp, actually, everything really is an object --> and we're gonna start creating some of our own. --> I believe that's gonna be the first thing tomorrow. --> So, let me just check really quick. --> I think that's the first thing. --> Yeah, we're gonna do that fairly early tomorrow. --> So, yeah, C Sharp, actually, --> if you look at these other values we're working with, --> actually, everything is an object. --> So, integers, strings, --> those are all really objects underneath. --> But we'll actually look at working with objects --> and stuff first thing tomorrow. --> Hey, great question. --> All right, let's take a look at how do we use, --> now that we've got data that we can store --> and now that we've got ways that we can work with that, --> those variables, let's take a look at using those. --> Yeah, I think, Lillian, you're the one that said this earlier. --> As we're going through this, --> if you want to open the solve with me --> and add comments in there as you go, --> that's a great suggestion. --> Yep, doing it right now. --> Yeah, all the files in here, --> you'll be able to get those files --> at the end of training so that you can have those --> as references, right? --> So, yeah, I think that's a great suggestion. --> So, let's take a look. --> And I will zoom in on that real quick. --> So, the important thing is we've got data, --> we're able to store in variables, --> different types of data, --> and now we have operators that allow us to work with, --> do comparisons or do operations on that data, --> on those variables. --> And so, let's look at why that's gonna be useful for us. --> So, let me, why is it not going, here we go. --> So, here we've got a variable called water temp in Celsius --> that's of type double, --> and so we're gonna store value in there. --> We're gonna store this 37.5 value in there. --> And again, this is what all of your code is gonna do. --> You're gonna have data that you want to track --> that you're interested in keeping track of, --> and you're gonna want to do something with that. --> So, let's take a look at what we can do with that. --> One of the first things we can do is we can do --> what we call conditionals. --> We can decide whether certain code runs --> based on the value that we put in those variables. --> So, here I've got this water temp in Celsius, --> and I've got this value, 37.5 assigned to it, --> and I wanna, based on the value of that variable, --> I wanna do something. --> So, I'm gonna check and see --> if the value of that variable is greater than 37, --> I wanna do something. --> So, in C-sharp, we have the if statement, right? --> So, this if keyword, --> and then you can see I have parentheses here. --> So, there's the open parentheses, --> and then way over here on the right, --> there's a closed parentheses. --> And so, what I can do is I can have --> some kind of condition that I wanna check --> inside those parentheses. --> So, C-sharp is gonna take a look at that. --> It'll look at the value of that variable, --> it'll determine is that greater than 37? --> And if that's true, if that condition is true, --> then you're gonna see on my if statement, --> I've got curly braces. --> There's an opening curly brace, --> and then down here on line 14, --> there's a closed curly brace. --> And so, it will decide to run this code --> that I have inside those curly braces. --> So, this console right line, bath is ready, --> that code will only get run --> if this condition is true. --> So, what we're able to do is we're able to take --> and decide what code we're gonna have get executed or run --> based on the values that we have in our variables. --> And so, we're able to check that value --> using the if statement. --> So, the if statement has the if keyword, --> it has some kind of condition, --> and this condition is anything that's in these parentheses. --> So, that could be like really short or really long --> or really crazy, --> but whatever's in those is gonna be the condition --> that'll check. --> And then based on that, --> the if statement will have what we call the body --> of the if statement. --> Anything that's in the curly braces after the if --> is gonna be the body of this. --> And so, that code that's in the body of the if there --> on line 13 is only gonna get run --> if that condition is true. --> Why does that matter? --> Why would I want to run some code --> and not run other code --> based on the value of variables? --> Is there a value that I would get --> or a benefit I would get from that? --> Is it to help stop the whole program from being ran? --> Kind of. --> So, what you're really trying to do there --> is a lot of times, --> there's things that you wanna make decisions, right? --> So, for example, in this case, --> I might wanna know, --> hey, is this water ready? --> Is it warm enough? --> If it's not, then maybe I need to do something else. --> Maybe I need to keep heating it --> or there might be some alternative. --> So really, what we're doing with conditionals --> is we're making some kind of decision. --> So, we're getting the ability for our code --> to do different things --> depending upon the value of our variables. --> It almost seems like if you passed in that variable, --> it kind of would make more sense, so. --> Oh, to the fact that we're kind of just setting it? --> Yeah. Yeah. --> Yeah, that's true. --> So, pretend right here --> that this isn't just like we're just assigning it. --> Maybe that value is coming from like a thermometer --> or something like it's getting red. --> That's a great call out, thank you. --> But the key value we're getting with these, --> the conditionals, particularly the if statement, --> is that we're able to do different things. --> We're making decisions --> based on the value that we have for our variables. --> So sometimes, in this example, --> we're just doing a check that says, --> you know, there's one thing. --> We only wanna do this thing --> if a certain condition is met. --> Sometimes we wanna do a little bit more involved, right? --> So for this example, --> we're actually checking two conditions, right? --> So here, we're gonna say --> the water temperature has to be greater --> than a certain value, --> and it also has to be less than a certain value. --> And only if this entire block here, --> this entire if condition is true, --> will we run the code inside that if block, right? --> So again, keep in mind, --> you know, we saw on that first, on line 11 there, --> it can be a very short, simple condition, --> can be very long condition, --> but it's gonna evaluate everything that's in there --> to determine, ultimately, is it true or false, --> and that'll decide whether that code runs or not. --> Why would we do something like this --> where we're checking these two conditions --> versus just the one condition? --> One example for, that might be relevant for our stuff is, --> say we have a CNC instant quote, --> or part that went through a CNC instant analysis. --> We might check, is it a CNC quote, --> and then also did it successfully --> go through instant analysis. --> And that combination of one condition. --> Yeah, great example. --> So what Maria was saying there is a perfect example. --> Typically, we're gonna look --> at sort of multiple conditions, right? --> There has to be more than one thing --> to decide what we're doing. --> So, you know, the first thing might be, --> hey, is it not this certain type? --> If it's not, then my code isn't designed to handle that, --> right, so then I would have to give you --> some kind of message. --> Just because it is that type, --> I have to see, did it pass, right? --> So I have to check something else. --> So you're able with the if statements --> to check more than one thing --> and ultimately, everything that's between those parentheses --> will be what you're checking, right? --> So all of this information at the end of the day --> has to result in true in order for that code to get run. --> That was a great example. --> So let's take a look now. --> Sometimes we want, this is controlling what happens --> when that condition is met, when it's true. --> Sometimes we wanna do something when it's not true, right? --> So we wanna say, okay, for example, --> if the water temperature is greater than 99.9 degrees, --> then we're gonna say that the water is boiling, right? --> So if this condition is true on line 21, --> the code here on line 23 will get executed. --> If this condition is not true though, --> it'll actually go to this else keyword --> and this else keyword will match everything that's not true. --> And so if it is true, it does whatever is on line 23. --> If this condition is not true, --> then it'll do this code here on line 27. --> So sometimes it's important to check something --> and actually have two different outcomes. --> If it's true, I'll do one thing. --> If it's not true, I'll do something else. --> So the else keyword, --> you can see it doesn't have any condition, right? --> It's the result of it checks the if condition. --> And if this is not true, it won't run this code, --> but it will look and see, --> is there something else I should be doing? --> Any questions about that? --> So in the first example, a couple of examples here, --> we were showing, we didn't have an else. --> What happens here if this condition is not true --> on line 16? --> What's gonna happen? --> If this condition is true, --> it would run this code on line 18, right? --> But if this condition on line 16 is not true, --> what's gonna happen here, do you think? --> It goes to the next if statement. --> Yeah, absolutely. --> So it looks at this condition. --> If it's not true, --> it skips the body of that if statement, right? --> And it looks, says, what's next? --> What can I do next? --> And it goes down here to line 21. --> So sometimes that's what you want. --> Sometimes you wanna check something --> and you only wanted to do something if it's true. --> Sometimes you actually wanna be able to handle --> that situation and do something different. --> So the else is gonna allow us to do that. --> So here, it's gonna check this condition. --> If it's true, it'll do the code on line 23. --> And if it's not true, right? --> It'll skip the body of that if, --> and it'll say, oh wait, there's an else. --> Let me run that code. --> Right, so again, a very, very common scenario in your code --> is you're checking some condition --> and you're making a decision. --> If it's this, I'm gonna do one thing. --> If it's false, I'm gonna do something else. --> That's a very, very common pattern. --> And so if, and the else keyword --> allows you to handle that. --> Here's my check. --> I'll do this code if it's true, else. --> If it's not true, I'll do this other code. --> Okay, sometimes there may be multiple things --> that you wanna check. --> Unfortunately, let me get a move this here, let's see. --> We got zoom, there we go. --> Okay, nope, not enough. --> I gotta figure out the shortcut, --> whatever it is to hide the video menu, --> apparently now. --> Let's see, okay. --> So now I've got simple if else, right? --> So it does one thing or it does another. --> Let's take a look down. --> Maybe there's multiple things that I wanna check. --> So here I'm gonna check and see --> is the water less than 78 degrees? --> If that's true, then I'll display this message. --> That's too cold for swimming. --> If this is not true, it's gonna skip that function --> and it's gonna find this else. --> And my else, I'm actually gonna have another condition. --> So here it'll say, okay, it wasn't less than 78. --> Is it less than 82? --> If that's true, it would say just right for swimming. --> If this is not true, --> it's gonna skip that body of that function --> and it's gonna go do this else. --> There's no condition on that else, right? --> So it's just gonna match that --> and it'll say it's too warm for swimming. --> And so here, what we're doing is basically --> using two if-elses, right? --> So here's the if-else --> and then we get another if-else, right? --> So we're able to actually combine --> and have more than one if-else. --> Why would I wanna do that again? --> What would be the benefit that I'm getting --> from having sort of multiple if-elses? --> Do you want something to happen --> if none of those conditions are met? --> So that's, you check methodically --> for different conditions and then none of those are met, --> you've got kind of a default. --> Absolutely, that's what the else is doing for me. --> So with the nested if-else, --> sometimes, just like you said in the beginning of that, --> sometimes I wanna check multiple conditions. --> So I wanna say, if this is true, --> that I'll do something. --> But if this other condition is true, --> then I'll do something. --> And I can have as many of those as I want. --> And then my final else is gonna say, --> well, if it doesn't match any of this other stuff, --> then do this instead, right? --> Jane. --> Yes. --> So the 82.1 Celsius, --> if it's less than that, --> it's just right for me. --> But if it's below 78, it's too cold. --> So does that mean it's looking at the 78, --> it's comparing between the 82 and the 78? --> So how these work, --> that's a great question, by the way. --> How these work is the first condition that's true, --> it'll do, right? --> So here, let's assume that the water temperature --> is 79, right? --> It'll say, okay, is that less than 78? --> No. --> So it's not gonna do this. --> It'll ignore whatever's here. --> Then it'll come down to the next one --> and it'll say, okay, what about this condition? --> Is it less than 82? --> It is, right? --> So then I would get this block of code right here, --> this online 36, that would run for me. --> So it's gonna compare those conditions in order --> until it finds the first one that's true --> and it'll do that. --> And then if it doesn't, --> just like Lisa was saying, --> if it doesn't find any of these conditions --> that are true, --> else will basically match anything else. --> Is that what you're asking? --> I wanna make sure I answered the question you were asking. --> Well, I guess I was just because there's no difference --> between 78 and 82. --> I mean, the water temp could be below 82, --> but it's not giving the minimum. --> So the minimum is actually gonna get checked here. --> So the minimum is- --> That's what I was, yeah. --> So you didn't answer my question then, I guess. --> I just wanted to clarify. --> So it is comparing those two, right? --> Okay. --> Yeah, and to your point, --> it's gonna do those in order, right? --> So it's gonna start at the very first one --> and it checks that condition. --> And so that's what's setting the minimum, right? --> Line 30 is setting that minimum 78. --> And then if it's below that, --> then we're gonna say it's too cold. --> And then once it's checked that minimum, --> it's gonna say, okay, well, it's above the minimum. --> Now let me check, is it above the maximum, right? --> So if it's below that maximum, --> then we're saying it's just right. --> Otherwise, we're gonna say it's too warm. --> Yeah, great question. --> And that's really all we're doing with if statements, --> if else. --> We're basically gonna have some kind of condition, right? --> And again, that could be a very long, crazy condition. --> Anything that's between those parentheses. --> And whatever the result of that is, --> is gonna allow us to determine --> which code runs as a result. --> If it's true, we will run this code. --> If it's not true, we can check again, --> or we can run some different. --> Any questions on that before we try an activity with that? --> Let's take a look. --> So this is gonna be, --> it's gonna be in your activities, --> and we're gonna do conditionals. --> And if we look at our starter code. --> Oh, switch the preview on me. --> There we go. --> So what we're doing here is, --> we're gonna open that conditional solution. --> And then we wanna write a code --> that checks the value of status variable. --> And depending upon the value of this, --> we're gonna display different messages. --> So if that status is red, --> we're gonna display danger. --> If it's orange warning, yellow warning, --> green normal, blue normal, --> blue info. --> And then if the value of the status --> doesn't match any of these, --> then we're actually gonna display this message, --> unknown status. --> So what we'll have you do there is write the code --> that will determine that. --> And then we're gonna have you try --> assigning different values to that status variable --> and make sure that that correct message gets displayed. --> And if we take a look at the code, --> let me hop over there really quickly. --> That's not too bad. --> Once I figure out the lag, --> I can kind of adjust for it. --> That's before I was like over clicking everything, --> I think. --> So if you take a look at this conditional solution, --> this is the starter code that you'll have there. --> All right, so as that opens up for us. --> So let's go ahead and do that. --> All right. --> So here's what you'll have. --> We basically are setting that variable already status. --> We're making a string and we're giving it a value. --> And then we're gonna have you --> write some tests in here, right? --> So we'll be writing, --> well not, you shouldn't use the word test. --> We'll write some conditionals. --> We're gonna learn to write tests later. --> But we're gonna write some checks in here --> with if statements. --> And we're gonna compare the value of this status variable --> and decide different messages to display based on it. --> Fantastic. --> Let's take, again, we'll try about 10 on this one --> and we'll see where we come out. --> So we'll go from now for about 10 minutes. --> And then we'll take a look at the code. --> Yes. --> Is that what I thought you'd do? --> No, so I included Visual Studio code --> because I thought it might be easier --> to see sort of the folders and the whatever. --> But I'm actually opening it in Visual Studio. --> So I actually go here to the folder --> and I'm double clicking it here in that folder. --> Are you able to see my screen? --> I feel like I'm not sharing. --> I just realized I'm not sharing. --> Pretend I was sharing my screen. --> Gotcha. --> Yeah, so I'm just opening it from the folder right here. --> You actually can open these from Visual Studio code, --> but it's a little bit trickier to run them that way --> so I don't wanna go that route. --> I think that's what I'm running into. --> I did an open file and I started updating it. --> But when I run the program, --> it runs the previous program. --> Yeah, I think if you just open it from the Explorer, --> just double click there --> and then run it that way, it should work for you. --> Okay, thanks. --> No, great question. --> Was there a chat? --> I see I missed a couple of questions in chat. --> No, I was just saying the dark mode --> was kind of hard for me to find the cursor --> so I just switched it into light mode --> and put that in the chat for other folks. --> That would be helpful for them. --> Oh, perfect, yeah. --> It's so funny. --> I get mixed feedback either way. --> If I do it light mode, people complain. --> If you do it dark mode, people complain. --> Yeah, my setup is a little weird here --> because it's kind of bright --> and the cursor was just not sticking out for me. --> I don't know if that is for anybody else. --> No, that's super helpful. --> Well, thank you for that. --> Yeah, the chat too, just FYI. --> I have the toolbar hidden --> because it keeps getting in the way. --> So if you do put something in the chat, --> I'm not gonna see it right away. --> Just FYI. --> All right. --> Okay. --> Okay. --> Okay, a couple more minutes and we'll take a look. --> Obviously, if you have any blockers or questions --> as we go, feel free to ask those. --> Let me share my screen. --> We'll take a look here. --> All right, so we have this status variable. --> Let me zoom in on that. --> We have this, why is zoom not like that? --> What's going on with that? --> Okay, there we go. --> We have the status variable. --> We've signed this value red to it. --> So we need to write some code in here to check --> those values. --> So anytime we wanna check the value of something, --> we're gonna use an if statement to do that. --> Is everyone able to see my screen? --> Is it good size? --> Okay, perfect. --> So if will be the keyword we're gonna use for that. --> And then I don't know if you notice as I'm typing, --> but Visual Studio is doing the same thing --> for you as well. --> It's giving you lots of prompts on different suggestions. --> Some of these are gonna be a little not --> what you're looking for, right? --> But it's actually smart enough, --> the more code you write, --> especially if it's in the same project, --> it'll actually learn from your coding --> as well as learning from other examples. --> And so some of the prompts will get better --> and better actually over time as you use it. --> Here, we're gonna wanna check the status. --> So if I start typing status, --> I'm gonna get the option there for the status variable. --> And then I wanna check to see if that's equal to red, --> then we're gonna do something. --> So that's gonna be my whole condition status, --> and I'll check that if that equals red. --> And then I'm gonna have to have some curly braces. --> You'll notice in Visual Studio, --> some of the languages you work in --> will be a little bit more specific --> or picky about the white space. --> Visual Studio, I could actually do this --> on this line right here. --> I could do my check and do my code right in here. --> It's really all about where's the semicolon at --> and where are the curly braces. --> It doesn't really care about the white space at all. --> So I could do my console write line --> and then do something like danger --> right here in the line, --> and then I'll put my semicolon in there. --> And that'll actually work just fine. --> Some languages you'll see, --> like if you're familiar with JavaScript, --> they'll tend to do something like this. --> They'll put the curly braces on the following line. --> That'll work just fine in C Sharp, it doesn't care. --> C Sharp, typically though you'll see like this --> with curly brace, then whatever code you're gonna do --> and then the curly brace. --> I'm just letting you know in terms of --> the C Sharp language itself, it really doesn't care. --> As long as the code works, --> it's not really concerned about the white space. --> So just FYI. --> So I'm checking to see if the status there is red, --> then we're gonna go ahead and run --> any code that's in there. --> Can I have more than one line of code --> inside that if block? --> Yeah, absolutely. --> I could have multiple console writes. --> I could be doing lots of other things. --> So this code block here for the if statement --> can be as large as it needs to be. --> You can have multiple lines in there easily. --> So in these simple examples we're showing, --> we're just trying to kind of call out --> how things work at the simplest level we can --> and then you'll see in later examples --> there can be a lot more stuff going on inside here. --> Oh, to Maria's point too, --> if you don't like the theme of this, --> if it's difficult to read, et cetera, --> if you go to the tools menu in Visual Studio, --> you click tools and then click theme. --> You're gonna see there's actually --> a couple of themes that are here. --> This is the one that we're using right now. --> You can completely change the look of this. --> So if I hit blue, for example, --> it'll change the look of the entire application, right? --> So now I've got blue borders and things, --> my comments are in green. --> So just FYI, if you're gonna be spending a ton of time --> using this tool, which you likely are, --> find this setup that works the best for you, right? --> And that's one of the advantages of using tools --> like Visual Studio is that the tools are really there --> to help you facilitate what you're doing. --> So yeah, make that environment comfortable, --> take advantage of all the things that it offers you. --> So I'm gonna switch it back, --> but be aware that you can do that. --> You can do something similar in Visual Studio Code --> if you want to, I can show you about that later, --> but just be aware that's an option. --> And then I'm basically gonna do just a set of these, --> right, so I need to do a bunch of checks. --> So I need to check if it's red, --> if it's, what was it, danger was the other one. --> Oh, actually, it's checking a certain status, right? --> It's checking if it's orange, it's gonna be warning. --> Now I could do these all as individual statements, --> like if, if, if, but I'll show you --> there's a better way to do that, right? --> Let's take a look at the solved version of this. --> So here in the next Windows Explorer, --> I'm gonna go to the conditionals activity, --> and then I'll go to the solved version. --> Give that a second to open up there, okay. --> So I'm gonna go to the solved version, --> and I'm gonna go to the solved version, okay. --> All right, now if I take a look at the solved version, --> we'll see we're checking that status is red, --> we'll console write line that message, --> whoop, why does it do that every time, there we go. --> Write that message, and then we're gonna do an if, --> else if here on line 15, --> so else, we'll check a different status. --> If that's true, we're gonna write warning. --> If that's not true, we're just gonna keep --> checking these different conditions --> as we go down through here. --> So to your viewpoint earlier, --> it's gonna look at each of those conditions in order, --> and the first one that it finds that matches --> will get executed. --> And then if none of these match, --> it'll always match this else. --> So it'll find this else, --> and then it'll run that message there. --> Any questions at all on this? --> Did anyone run into any issues --> when they were writing code for that? --> Okay, what do you notice on here? --> There's something interesting about this. --> Couple of these actually have the same message, right? --> So orange and yellow are both outputting the same message. --> So that's one thing that's a little strange. --> So I've got this set of conditions that I'm checking. --> The other thing is that once, --> with the if else, if I'm just checking sort of one if else, --> one condition, it's a little bit simpler. --> When I start doing multiples like this, --> it kind of gets a little out of hand. --> So let's take a look at another thing --> that C-Sharp provides us, --> that when we're checking multiple conditions like that, --> there's another way we can do that --> that might be a little bit more straightforward. --> So let's talk about using switches. --> So the value you're getting with the conditionals --> is that you're able to only run code --> based on a certain condition. --> And the advantage you're getting from that really --> is that it allows you to respond differently. --> Your code can respond differently --> to different types of data, right? --> So that's the advantage that you're getting --> by being able to check conditions --> and then run different code based on those. --> Very, very often, you're gonna be checking --> sort of a single check. --> Does it meet this or does it not, right? --> Sort of an if else. --> But when you are checking multiple conditions, --> C-Sharp also has another keyword --> that we'll take a look at. --> Let me zoom in there. --> So C-Sharp obviously has if-else. --> And so we could check all those conditions, --> red, orange, yellow, et cetera. --> But anytime we're doing this, --> only one of these conditions is gonna be true. --> So it's only gonna run one of these lines of code --> and then it will skip the rest of the lines, right? --> So in that scenario, --> there's actually a more straightforward way in C-Sharp. --> To do this, and let's take a look at what that is. --> So C-Sharp also has the switch keyword. --> And what the switch operator will do, --> it's gonna check the value one time. --> So it's gonna take a look right here at the status. --> So just like with our if, right? --> With our if, we had that condition --> that we were gonna check. --> Here, switch is gonna do something similar, --> only what switch is gonna do right here --> is check the value. --> What is the value of that variable? --> And then switch will allow us to have a series of cases --> that match that value. --> So it'll determine there on line 42, what is the value? --> And then it starts looking through the cases --> and it finds the first case that matches that value. --> So if that value of the status variable is red, --> here on line 44, it would say, oh, that matches this case. --> And then you'll see after the case, --> so the case is gonna have the case keyword, --> the value that it matches, --> and then it has a colon at the end of that line. --> And then just like with the if statement, --> there's gonna be a block of code --> that will run if that's true. --> So in this case, that would be here on line 45, --> it will run that block of code, --> that line of code I should say. --> And then a case is gonna have a break statement --> that says, okay, I'm done, now move on. --> So switch, you're gonna see switch keyword. --> It'll have the value of this variable --> that's gonna check. --> Then it'll have a body, --> so this switch statement has a body here --> from line 43 all the way down to line 64. --> And the body of a switch statement --> is gonna just be a series of cases --> that it's gonna try to match. --> Any questions on that first part? --> So switch statement, it's gonna look at the value, --> whatever value you provide here in the parentheses, --> and then it'll try to match that value --> to one of the cases. --> It'll try to find the first case --> that matches that value. --> Any questions on that part? --> Okay, so just like with the if else, --> if it doesn't match any of these cases, --> there's actually a default case. --> So here on line 61, default is sort of like the else. --> And this will match, if none of the other cases match, --> it'll match this case. --> So it finds a case that matches, --> it runs that code, --> and then as soon as it hits the break statement, --> it exits out of the switch. --> So the difference here that you're getting is --> because really with those nested if else's, --> you're checking multiple conditions --> against the same value. --> Sometimes the switch statement --> is a little bit more straightforward --> that this is what I'm doing. --> I'm looking at this value and based on this, --> I'm gonna do something. --> And I'm just gonna look at the case statements. --> So it can be a little bit cleaner in terms of code. --> The other thing is here, --> if you look at line 48 and 49, --> if I have more than one case that does the same thing, --> so in this example, --> orange and yellow are both printing out the same message, --> I could have multiple case statements --> that match the same block of code that will be run. --> So I'm just gonna stack those case statements. --> So case orange colon, case yellow colon, --> if it matches either one of those cases, --> it's gonna run that same block of code on line 50 there. --> I don't think there's something similar --> to the switch in Python, right? --> Is this new for everyone? --> I've definitely used it before. --> I don't know if it was Python or someone else. --> Yeah, other languages support it. --> I don't remember if Python does or not. --> So again, you're perfectly welcome --> to use the Bell statements. --> Sometimes though, when you have that sort of nested, --> if else, if else, if else, --> a switch statement can be a little bit more obvious --> about what you're trying to do. --> And it's a little bit more clear --> than what your intention is, right? --> So switch is saying, look at the value of this --> and then match it and do something. --> So it's another alternative --> that you'll have in your tool. --> Let's try this out. --> We're gonna try writing some if statements, --> the nested if statements, --> and then we'll write the switch version of that --> and kind of give you a way --> to highlight the differences between those. --> So if you take a look --> here in our switches activity. --> So we're gonna have you take a look --> at the switches solution from the starter folder. --> We're gonna try, we're gonna do the same thing. --> We'll just do it two different ways. --> So what we wanna do is we wanna determine --> and display the day of the week. --> And we'll do that two ways. --> We'll do it first --> by writing some nested if else statements. --> So we'll take a look at the value --> of the day number variable. --> And then we're gonna write out a message that says, --> oh, day one is Sunday, day two is Monday, --> that type of thing. --> Then we'll take that same logic --> and we'll do that as a switch statement. --> So you can kind of compare --> the difference between the two. --> So let's take a look at what we're getting --> for starter code there. --> So you're gonna see that our first starter code, --> we're gonna get that value will be declared --> for us, that variable day number. --> And then we're gonna do it first with if else statements. --> So we're gonna have to write some if else. --> If day number equals this, then display this day. --> And then we'll do that same exercise, --> but we'll use a switch statement instead for that. --> For this one, you can assume day one is Sunday --> or Monday, it doesn't matter either way. --> As long as you handle the question --> that comes up sometimes. --> And we'll spend about 10 on this one as well. --> So from now, 12, was that 12.30? --> Yeah, 12.30 for you guys, 12.40. --> So was there a question in the chat? --> Yeah, absolutely. --> You're a keyboard shortcut person like myself. --> Maria's got a great tip in the chat there for you. --> Okay. --> Okay. --> So we'll take a look. --> A tricky part with this is just the way --> you just remember all the curly braces, right? --> Curly braces and where you put those. --> Let's take a look. --> All right, so should be able to see my screen. --> So I'm just opening up the activities 10 and the assault. --> Just click on that solution. --> So let's take a look. --> Open that up and then I'll just zoom in on that. --> So we've got this date number variable, --> the sign from an integer, --> which is assigning it a value. --> Why does it continue to open that up? --> There we go. --> And then we're just gonna do a series of checks. --> So the important thing is remember, --> on your if statement, you're gonna have that keyword. --> Then you'll have your parentheses around --> the conditions that you're checking there. --> And then the if statement has the body --> that's gonna be inside those curly braces. --> So here on line 14 and 16 will be that opening --> and closing curly brace. --> So it just has that keyword if, --> in parentheses is what you're checking. --> And then you have your curly braces --> that are gonna be the body that'll get run. --> That's the code that'll get executed if that's true. --> And so when you're nesting those, --> then the same thing. --> You can tell right away if they're not --> sort of nested correctly or something, --> you'll start getting those red squigglies. --> The challenge can be sometimes, --> it might be a squiggly or a brace --> or something you missed early on --> that's causing an error sort of later in your code. --> So one way that you can find those --> a little bit more straightforward. --> If you'll notice, Visual Studio is doing this thing --> where it's sort of giving the arrows to collapse. --> It does that by looking at your code --> and finding those curly braces. --> So if you start collapsing these things --> and you find either one that doesn't collapse, --> doesn't have the little arrow on the side there --> or is not collapsing the way you're expecting, --> that can be kind of where the problem is. --> Maybe it'll help you hone in on what's going on there. --> So really what we're calling out here, --> just kind of giving you some more practice --> doing conditionals. --> And again, you can check either way. --> Either way is perfectly valid code. --> But sometimes depending upon the amount of code --> that you're running based on those different conditions, --> a switch statement might be --> a little bit more straightforward. --> It might be a little bit more readable, --> especially when you have multiple statements involved. --> And that's kind of the big takeaway from this --> is that you do have that available to you. --> Any questions on this activity itself? --> So there's our version with the if statements --> and then the switch statement you'll see once I move. --> So I fight with my good buddy Zoom here. --> There we go. --> And move some of those out of the way. --> You'll see a switch statement, very similar. --> We're just checking the value --> and then we're gonna compare that --> to our case statements --> to find the one that matches there. --> Any questions at all on that? --> Any thoughts on switch statement versus if-else? --> I wonder if you didn't put the break on each case --> that just keep on going? --> You should try that, actually. --> So in this version of C-sharp, --> it behaves a little bit differently than it used to. --> Did you try it? --> No, I saw that going too many, actually. --> So on the other screen, but I tried now. --> Yeah, so here, if I, for example, --> you're saying basically if I just comment this out, right? --> So if I pick all these little break statements --> and I just comment that out, --> what's gonna happen, right? --> Yeah, so in this version, --> I'm actually getting this little error message --> that says they can't go from one case to another. --> So it's actually telling me it's required --> that I have to put it in there. --> So in some versions of C-sharp, --> what would happen there, --> there was a weird behavior where if you didn't put that --> break, it actually would fall through. --> So it would keep running code until it found a break --> or until it dropped out of here. --> And people were actually taking advantage --> of that behavior, using that. --> And as a result, --> they were getting some weird behavior in their code. --> So yeah, the break is, --> you're gonna see if you try to remove it, --> you're getting that message that's required. --> And that's just letting you sort of explicitly know, --> only run this code until you get to this point --> and then you're out of that case. --> Great question though. --> And again, it's really a matter of preference. --> So you're just getting different ways --> to do sort of the same thing. --> And you'll see as we work with Visual Studio and C-sharp, --> that that's gonna be the scenario quite a bit --> where you'll have more than one way to do something. --> And I would just recommend, --> do the way that you understand, --> the way that makes sense to you. --> If your code runs and you get the result --> that you're expecting and it's readable, --> that's far more important --> than writing sort of slick code, right? --> Sometimes people will spend a lot of time --> trying to write the most perfect line of code ever, --> especially when you're learning a language. --> I think it's far more important --> to understand what the code is doing --> and have code that works. --> And then as part of your learning as a developer, --> you can always come back and improve your code, right? --> But the most important thing is making sure --> that you understand it --> and writing readable code the first time. --> Okay, so let's see. --> Normally we would do a review on this activity --> and then we would do our 60 minute break. --> So that's gonna be, --> it's like quarter to one for you. --> Do you wanna take your lunch break now then, I guess? --> And we'll come back after that? --> Sounds good? --> Like yes or no? --> Like give me a yay or nay? --> All right, so it's a little bit, --> it's like 15 till, so we'll do 45 after. --> So we'll do until, what would that be? --> 145 your time? --> Okay. --> Yeah, let's do that. --> Yeah, we'll come back at 145 --> and then we have most of the fundamentals already. --> So basically after we come back, --> we're gonna talk about looping, --> we're gonna talk about arrays --> and then we're gonna do some activities --> using all this cool knowledge --> that we've been working on. --> So yeah, we'll take a break now. --> I'll see you at 145 and we'll pick it up with loops. --> Thanks. --> That's the 12.5. --> That's one. --> And then one. --> 145. --> That'll be activities. --> Okay. --> Okay. --> Oh, damn it. --> Okay. --> One, two, three, four, five, six, seven, eight, nine, --> 10, 11, 12. --> Oh, oh, oh. --> Oh. --> Oh. --> Oh. --> Oh. --> Oh. --> 10, 10, 10, 10, 10, 10, 10, 10. --> 145, six, seven, eight, nine, 10, 11, 12. --> One, two, three, four, five, six, seven, eight, nine, --> 10, 11, 12. --> One, two, three, four, five, six, seven, eight, nine, --> Oh, no. --> Oh. --> One, two, three, four, five, six, seven, eight, nine, --> 10, 11, 12. --> One, two, three, four, five, six, seven, eight, nine, --> 10, 11, 12. --> Four, five, six, seven, eight, nine, 10, 11, 12. --> Oh. --> Oh. --> Oh. --> 145, seven, eight, nine, 10, 11, 12. --> Oh. --> Oh. --> Oh. --> Ah. --> Ah. --> What is it all about? --> Ah. --> Ah. --> Ah. --> Ah. --> Ah. --> Welcome back. --> Let me just refresh my machine here. --> All right, perfect. --> All right, so before the break, --> we were talking about conditionals --> and some ways to check those, --> and then we saw switches, --> how they kind of give us an alternative to those. --> Now let's take a look at loops. --> So I'm gonna go here. --> So just like conditionals are pretty common, --> it gives us a way to check our data, --> check the values of that, --> and then make some kind of a decision based on that. --> Another very common thing that we wanna do in our code --> is to be able to repeat code. --> Perfect. --> And loops will allow us to do that. --> So let's take a look at C Sharp. --> How do we do loops? --> Okay, and I will move this. --> There we go. --> So let's take a look at some loops --> and some common ways to do this. --> So a loop is literally just something --> where we wanna have repeat code. --> We have code that we wanna repeat, --> and we could just write that code again --> and again and again. --> But with a loop, --> we're able to take a block of code --> that we wanna repeat, --> and then we can tell it how many times to repeat. --> So for example, here on line 11, --> can you see my screen? --> Is it sharing? --> Yeah, it looks like it is. --> So on line 11 here, --> we're gonna use the for keyword to do a loop. --> And so what we wanna do is the body of this, --> the line 12 to 13, --> this code that's in the body here on line 13, --> we wanna repeat that code a certain number of times. --> Now, this is kind of a silly example. --> A real world, --> we'll show you some much more realistic examples, --> but for demo purposes here, --> we're just gonna print out some numbers. --> But the key takeaway is that --> if you have code that you wanna repeat, --> a loop will let you do that. --> And specifically, --> we'll look at a couple of kinds of loops. --> So we'll start out with the for loop. --> So the for keyword. --> And then very similar to what we saw --> with the if statement, --> there's gonna be some set of conditions --> about how do we repeat this code. --> So you can see here inside the parentheses, --> I'm gonna have some conditions that tell me --> how many times I should repeat this loop. --> And you're gonna notice too, --> there's some semicolons in here. --> So remember, semicolons are actually end a line of code. --> So what we have in this for loop condition --> is actually three parts. --> So there's this first part here, int i equals zero. --> There's the second part, i is less than four. --> And then there's this third part, i plus plus. --> So with a loop, --> we're gonna have three things that we need to do. --> We're gonna have some kind of a starting condition. --> In this case, we're gonna start out --> by setting this variable i to the value zero. --> So that's kind of initializing or starting our loop. --> The second thing that's gonna happen --> is there's gonna be a check. --> So just like an if statement has a condition that checks, --> the loop, the second part of the for here --> is gonna be what condition do we check --> to decide if we continue to repeat this code --> or continue to loop. --> So here we're gonna say, is i less than four? --> So since i is zero right now, --> that means that we're gonna repeat the code. --> So as long as this condition is true here on line 11, --> then we're gonna run whatever is in the body --> of this loop. --> So we'll run this console statement here. --> And then we're gonna keep checking this condition. --> So we'll run this code --> and we'll come back and check this. --> And every time this is true, --> we're gonna keep repeating this code. --> So the last thing we need to do --> is we need to have some way to move this thing along --> so that we know how many times to loop. --> So the last part of this, --> we're gonna run every time the loop runs, right? --> So we'll start out i is zero. --> We check this condition. --> If it's less than four, --> we do whatever is in this body of the loop. --> And then we, i++. --> What do you think that i++ is doing? --> Yeah, it's basically a shorthand, right? --> So it's basically a shorthand for this, --> if you wanna think about it like this. --> It's basically the same as saying i equals i plus one. --> And so this is a shortcut that just says, --> make i, the value of i, increase by one. --> So since this is such a common thing to do, --> we actually have a little operator, --> the increment operator, that will do that automatically. --> So this i++ is really just kind of a shorthand for, --> take the value of i, add one to it, --> and then assign it back to i. --> A little bit of a lag there, --> so hopefully I don't over type, there we go. --> So what we're doing then is we're saying, --> if i is less than four, it's zero, --> go ahead and add one to that. --> And then we check the condition again. --> So one, is one less than four? --> Yes, so we'll run the body of this loop. --> And then we'll keep doing this, --> we'll keep repeating this. --> So we'll add one to i, now i is two. --> We'll check the condition. --> And as soon as this condition is no longer true, --> then we'll finish this loop, we'll come out of this code. --> And so loop has a, the four keyword --> is what's telling us to do some looping. --> Whatever is in the body of that loop, right here, --> so the curly braces between lines 12 and 14, --> that's the code that's gonna get repeated every time. --> And then we have three parts here to our loop. --> We have the starting condition, --> the second part is this check, i less than four. --> As long as that check is true, we're gonna keep looping. --> And then every time we loop, at the end of that, --> we'll go ahead and change the value of i. --> So how many times will this loop run? --> Four times? --> Four times. --> Right, so it starts out at zero, --> and then it goes to one, and then two, and then three. --> As soon as the value of i becomes four, --> four is no longer less than four, --> and it'll drop out of here. --> And so each time it's gonna write what? --> Just the value of i. --> So it's basically gonna write out zero, --> and then one, and then two, three, --> and then the loop will stop. --> So again, a really silly reason to use a loop, right? --> Typically, you're gonna be doing something more valuable --> in here than just writing out a number. --> But any time you have code that you need to repeat, --> you'll be able to do that. --> What might be an example? --> What kind of code would you maybe wanna repeat --> based on your variables? --> Well, for example, let's say we wanted to --> print out the names. --> Oh, did someone have an answer? --> I was just gonna say, --> just thinking about some of the work that we do, --> like you have some JSON output, --> and you know that you've got several key values --> that are saying you loop on those key values --> and do some work for that. --> Fantastic, great example. --> So basically, any time you have a set of data, --> so I was gonna say, as an example, --> if you have students --> and you wanna print out the student's first names, --> you would have to repeat that same code. --> You'd have to say for every student, --> write out the first name. --> For the next student, write out the first name. --> So there's lots of cases --> where you're gonna be able to reuse or repeat. --> And especially when you're working with sets of data, --> you wanna do the same thing --> to every piece of data in that set. --> Is there something in the chat? --> Let's see here. --> Oh, yeah, perfect example, right? --> Complete each task in an activity, exactly. --> And we'll talk right after loops actually --> about working with sets of data. --> So we'll kind of lead into that. --> We're gonna need to be able to loop to work with those. --> And so that's gonna kind of lead us right into --> talking about sets of data. --> So in this example, I've got a for loop. --> Again, starting condition, some kind of a check. --> And then the last part of this --> is what sort of moves the loop forward, --> keeps the loop moving. --> And for loops are really useful --> to be able to do that, right? --> To be able to repeat those DevLocker code. --> Let's take a look at another kind of loop. --> So here's a loop --> and we use this keyword, while. --> So you're gonna notice here, --> it's a little bit different with the while loop. --> I'm actually setting some value here --> of assigning the value of variable before that loop. --> And then in the while loop, --> all I'm doing there is checking the condition. --> So on line 25, it's just simply checking that condition. --> And as long as that condition's true, --> it's gonna just continue to loop. --> And so same idea, just with a for loop, --> it's gonna repeat whatever is in the body of that loop. --> So what's the difference, do you think, --> between a for and while? --> Why would I use a for loop versus a while? --> If they both repeat code, --> what would be the difference between those two, --> do you think? --> For loop is for when you know exactly --> how many times you wanna repeat it. --> I think the other one is, I'm not sure. --> Yeah, absolutely. --> So with a for loop, right as part of the loop itself, --> when I'm setting that up, --> I'm setting basically a start, --> I'm setting the end condition. --> And so I know upfront how many times this is gonna loop. --> In this example here, you can figure that out as well, --> but I'll show you, --> there's a more real world example here. --> The difference is just what Dustin was saying. --> So with a while loop, I'm just checking some condition. --> And as long as that condition continues to be true, --> I'm gonna keep looping. --> So that could be one time, that could be 20 times. --> It depends on what that condition is that I'm checking. --> So a while loop is a little bit more open-ended --> where you don't know upfront --> how many times you wanna loop. --> You're basically gonna continue looping --> as long as that condition is true. --> Now, the other thing you're gonna notice too, --> in a while loop, something has to change this condition. --> This condition has to change in some way. --> So here it's inside the loop on line 28, --> we're actually gonna move the value of K, --> increment the value of K. --> But normally real world, if you think of the example, --> I think Lisa gave this example earlier --> about checking the temperature. --> So if, for example, --> we were saying looping based on the temperature, --> it might be something external to this code --> that's actually changing the temperature. --> And all we're gonna do in here is just check. --> And as long as that temperature is over a certain value --> or less than a certain value, --> we're gonna continue to do something --> until that condition changes. --> So that's the flexibility you're getting with a while loop --> is that you can loop as many times as you need to --> until that condition changes. --> Very good. --> All right, so the final one we'll take a look at. --> Sometimes, let me draw the screen down just a little bit here. --> So with my while loop, --> what if this initial value of this was five? --> How many times is the code inside that loop gonna run? --> Never, right? --> Because the very first time that we check that condition, --> it's not true. --> And so it simply moves past that loop, right? --> So there's certain cases where you do want that code --> in that loop to run at least one time. --> And so in that case, there's a variation of while --> that you're gonna see called do while. --> And so here, similar to the while loop, --> we're gonna set some kind of data up, right? --> And then the do keyword says do whatever is --> in that code block and then check the condition, right? --> So the only difference here really is --> that with the normal while, --> we're checking the condition upfront. --> And in a do while, --> we're checking the condition after we run. --> And again, the real reason, --> the real advantage of doing that is that --> if there's code that you want to guarantee runs --> at least one time, --> the do while loop will let you do that. --> So this code will run at least once, --> then check the condition to decide if it needs to continue. --> Any questions at all on those three different ways --> that we can loop? --> When is the best scenario to do a do while loop? --> It's just to check the data if it's good or just? --> Exactly. --> So for example, say I wanted to display a message --> to the user that said, enter your last name. --> And then I'm gonna check that last name --> and if it's a certain last name, --> then I'll do a certain code. --> If I did a while loop, --> I would never prompt them, right? --> They would never see the message, for example. --> So this would say like check the value, --> but it wouldn't never display the message. --> Whereas in a do while, --> I could write out the message, enter your name, right? --> Then I could check it --> and as long as it's something I could decide --> whether I was gonna repeat or not. --> So anytime you need to do some work always, --> that's when you would use a do while. --> Another example might be, --> say you're working with a program --> and you have to enter a menu item, right? --> One does something, two does something, --> and then you can enter a queue to quit, for example. --> A do while would be perfect for that --> because I could say, enter your command. --> And then as long as that command doesn't equal queue, --> I would just continue looping and letting you do. --> Those examples make sense? --> Oh, there's a message in the chat, let's see. --> Yeah, exactly. --> So Maria's got one that's more relevant --> to your actual work. --> But same idea, right? --> You're with a do while, --> you're at least running that code --> to prompt the user at least one time. --> And then depending upon what the user enters --> or what the data is, --> you're deciding whether I need to keep prompting that user. --> So with a for loop, --> if I know upfront the number of items --> that I'm working with, --> for loop is gonna allow me to work with that. --> It's gonna allow me to loop --> a certain specific number of times, --> and I kind of know upfront what that is. --> While loop, I'm able to loop --> as long as some condition is true, right? --> So I don't necessarily know --> is that loop gonna run one time? --> Is it gonna run 10 times? --> It depends on the data, right? --> So if my data coming in, --> if I'm saying keep checking these records --> until you find a match. --> I don't know if that's gonna find a match --> on the first time it runs --> or the fifth time it runs, right? --> So with a while, you've got that flexibility. --> And then again, do while, --> the only reason you would use that versus a while --> is if you have that code --> that you want to run at least one time, --> and then you may need to run it more times. --> Great questions and great example too. --> Any other questions about that --> before we take a look at some code? --> Yeah, let's take a look here. --> And this will be in our loops activity. --> And so here we're gonna do something kind of similar --> what we did in the other one --> where we're gonna take a look at the code --> and sort of figure out --> what we think is gonna print out from that. --> So there's gonna be some comments in there, --> and we'll show you some examples --> of some different loops. --> And your goal is to take a look, --> pretend you're the computer, right? --> And figure out what you think the output --> is gonna be for those. --> And then go ahead and build it and run it --> and kind of compare that. --> And then we'll come back and review that after. --> Tom, is it, let's see, three after. --> So we'll do this till about 13 after, --> and then we'll come back and take a look. --> And this is gonna be your loops activity, --> like activity 12. --> Okay. --> And so remember this one, the goal of it is to take a look --> and understand what the code's doing. --> You don't actually have to write any code for this one. --> Just put some comments in about --> what you think the output will be, --> and then run it. --> And then we'll come back and review that. --> And then we'll come back and review that. --> And then we'll come back and review that. --> Looks like most of you are pretty close on this one. --> So I don't think we're gonna need the full time. --> I mean, obviously, if you do, let me know. --> But I'm just hopping around a little bit. --> Looked like everybody was knocking this one out. --> So let's take a look at the output. --> Then we can talk through it a little bit there. --> Let me just share my screen. --> I'm gonna go ahead and close out of this. --> Okay, now I'll get that code open, --> and we'll look at what's happening here. --> Okay, so here, line nine, I've got this for loop. --> And it's gonna look like this. --> It's gonna start out at zero. --> So it'll set this value of i, --> and start that out at zero. --> And then as long as i is less than three, --> it'll continue to loop. --> And then every time it loops at the end, --> it'll increment the value of i, --> or add one to the value of i. --> And then it'll go ahead and run this code --> in this loop here. --> So what is the actual, --> what's the output from this look like? --> Zero, one, two. --> Yeah, and why is it just doing it --> in a straight line like that? --> Why isn't it doing those on separate lines? --> You used write instead of write line. --> Yeah, so here, we kind of trick you a little bit, --> or try to, by throwing write line. --> And so write line basically will write out the value --> of whatever you tell it, --> and then it automatically does a new line --> at the end of that. --> And so in this case, --> by just doing the write version of that, --> it actually is just going to continue --> doing it on the same line --> until it runs into a new line. --> And we're looping the three times, right? --> So the first time it's zero, --> and it'll roll right out to zero, --> and then it'll keep checking, --> okay, that's still less than it, --> so it'll write out the value one, --> still less, two, --> and then once it hits three, --> it'll stop that loop. --> And so you'll get that first value. --> Any questions at all on that? --> The three parts about the looping, --> you've got that start condition, semicolon, --> and then you've got whatever you're checking there --> to know whether to loop or not, --> and a semicolon, --> and then the final part of that --> is what's moving the loop. --> Okay, let's look at, --> oh, get rid of that silly window there. --> Let's look at the while loop then. --> So here, very similar to the example I was demoing. --> So we're going to have the while, --> whoop, it's not reading my mouse, there we go. --> It's going to have the while, --> we'll start this value out at zero, --> and we'll just check, --> as long as that's less than five, --> we'll continue to write that message out. --> And then remember with the while loop, --> we're only checking that condition, --> so something inside that loop --> has to change that condition. --> What would happen if I didn't have line 22 in here, --> if I didn't have this K plus plus line in here? --> It'll completely implement it. --> Yeah, it'll just run forever --> until your power runs out --> or the computer turns off, right? --> Yeah, it'll just continue to run. --> So yeah, so it's very important, --> unless that's what you're intending --> for your code to do, --> just repeat forever. --> Make sure that whatever you're checking there --> is going to change somewhere inside that loop. --> So here, we're going to just check and see, --> as long as it's less than five, --> we'll continue to loop, --> and then same idea, --> we'll just write the value of that out. --> So the output for that, --> it'll loop five times, right? --> But it'll write zero, one, two, three, and four. --> So here on line 29, --> we tried again to kind of throw you off a little bit, --> see if you understand what's happening there. --> So you'll notice this time, --> it's a little bit different. --> What's the end part here? --> What's our line 29? --> What's the end part of our loop doing there? --> Increasing one. --> Yeah, so you're doing the reverse, right? --> So in this case, we're starting at three, --> and then every time we're checking to see, --> and if it's still greater than negative one, --> we're actually going to subtract one from it every time. --> So just be aware, --> typically when you see these loops, --> we're usually counting up. --> We're doing the I plus plus, we're counting up. --> But just be aware, you don't have to, --> it doesn't matter which order you go in. --> Sometimes it's actually useful to start at the last thing --> and work your way back. --> And so you can very easily do that in a for loop --> by using a negative and counting backwards, right? --> So just be aware, that's a possibility. --> You know, the typical scenario, --> you'll typically start at the first thing --> and count from there or work from there, --> but you can work from the opposite direction, right? --> And then here's a more, as I've said, --> a little bit more realistic example --> of why you might use a while loop. --> Let me just scroll down a little bit. --> So here, we're starting that string value out --> as empty, right? --> So quotes with nothing in that. --> And then we're actually going to, at least one time, --> we want to message the user, --> you know, to have them enter a command --> and we'll tell them that they have to enter Q to quit. --> And so inside that loop, --> you're going to see that we're also doing on line 43. --> What is this actually doing, line 43? --> Yeah, so just like we're able to write to the console, --> we're actually able to read from the console as well. --> And so here, it's going to take whatever you've entered --> and assign it into that variable M, --> and then we'll check each time --> and we'll say, hey, as long as M is in Q, --> the user wants to keep going. --> And so we'll just continue the loop --> and we'll prompt the user each time --> until they enter Q, we'll just continue to do --> whatever work we're going to do inside that loop. --> Any questions at all on any of those examples? --> So real world inside this loop, --> what will we probably do? --> We would say, you know, enter a command, right? --> And so after we read that in, --> we would probably have a switch statement or a case statement. --> We would say, if they entered A, do this code. --> If they entered B, do this code. --> And as long as they didn't enter Q, --> we would do whatever they told us to do --> and then we would prompt them again. --> Enter the next command. --> So this is a more real world example --> of why you might want to do the do while. --> Hey, Shane. Yes. --> There's that warning, --> if that's what you want to call it online, --> your line 39 for 3 a.m. --> So the way I'm understanding that --> is that you really didn't have to define it empty. --> You could have just said 3 a.m. --> Yeah, absolutely. --> And you'll see here too, --> a lot of times if you get those messages, --> this little show potential fix option, --> if you click that, it would say like, --> hey, here's what it would look like if we removed that. --> And it'll actually fix the code for you. --> Yeah, great question. --> So to Lisa's point, sometimes you'll get errors, right? --> So you'll get like the red squigglies --> or your code won't build that type of thing. --> But Visual Studio also can look at your code overall --> and you'll see that it'll make suggestions like that. --> It'll say, hey, there's really no reason --> to assign a value here --> because you're going to check it anyways --> and you're not doing anything with it --> until you check it. --> So it's actually just saying your code will run, --> but here's a tip. --> You can actually avoid having to even assign a value --> to that. --> And in some cases, as you just saw, --> it'll actually offer an auto fix for you, right? --> Or offer a suggestion, a great call out. --> And you'll notice that as we go through there, --> there'll be these little tips and suggestions. --> Any other questions about the code, --> about loops, why we would do those --> or how we create those loops? --> Okay, so now we've learned --> sort of all the fundamental operators that are available --> to us and the ability to loop --> and the ability to check conditions. --> So this is kind of the tools that we'll need. --> The one piece we haven't talked about yet, --> we'll talk about right now. --> So let's take a look at what if I want to work --> with sets of data. --> A set is actually a thing in Python, right? --> I need to stop calling it that --> so that I don't confuse you with the Python lingo. --> We do have sets. --> I think we mostly get these in our framework --> or use like lists rather than sets. --> Okay, I just don't want to confuse the terminology --> too much because I'm using it just generically --> as if you have multiple things. --> So I'll try to... --> I'll try to avoid calling it something --> that might be something else in Python. --> Let's go ahead and take a look. --> So all the variables we've seen so far --> have been single values. --> And so the variable we're giving it a name --> and we're telling you what type of data --> we're going to store in there. --> And then we're able to put a single value in there. --> And sometimes you'll see it's very useful --> to work with related data. --> And so as an example, --> I have this variable here called even numbers --> and I would actually like to store multiple values --> in that variable, right? --> So not just one even number. --> As I find even numbers, --> I want to store them in this single variable --> so that I can work with them as a related group of data. --> So you're going to see, --> I still have to give it a name, right? --> Even numbers. --> I'm still declaring the type of data that I want to store. --> So I'm going to only store integers. --> So you still see the INT. --> But what you'll notice differently here --> is these brackets after that. --> So what I'm indicating with the brackets --> is I'm actually telling C-sharp, --> I'm going to store integer type data in this variable --> but I want to store multiple values in here. --> And so the brackets is how I'm indicating the C-sharp. --> There's going to be multiple values --> in this single variable. --> So that's the first thing that's going to be different. --> The second thing is going to be, --> how do I actually declare how many, --> how much data I'm going to store in there? --> So the second part of this you're going to see, --> we're going to assign to this --> and you're going to see this piece here, --> this new int five. --> So what I'm doing here is I need to say, --> I need so much space. --> Here's how many values I want to store in that variable. --> When I was storing just one value, --> C-sharp knows how big an integer is --> and knows how much space to set aside. --> And so I don't have to really tell it --> any more information. --> Here, I need to tell C-sharp --> how many values I'm going to store in there. --> So what I'll do is I have to use the new keyword --> so anytime I'm going to put values in an array, --> I have to use the new keyword. --> And new is basically telling C-sharp, --> hey, get ready to set aside some space for me. --> I have to tell it what type, right? --> So int, and then you're going to see here, --> I have to provide a value, a number saying, --> how many values do I want to store in here? --> So here I'm setting aside space --> to store five integer values. --> All right, so the big difference you're seeing here --> is that if I'm doing multiple values, --> I'm going to use the brackets to indicate --> that I'm using multiple values. --> I still have to set the data type. --> Still have to give it a name. --> And then I need to actually tell C-sharp --> to go ahead and set aside that space for me. --> And that's what this right side of this is doing. --> So this new int is saying I need some new space. --> I'm going to store integer data in there. --> And I want to be able to store up to five values in there. --> Any questions on that part --> before we take a look at how to use the data --> or put data in there? --> Is that five in the brackets there, --> is that different than the elements? --> Is that, like I see underneath that is element zero, --> O equals two, O is four, but it turns to zero. --> Is the new int four to include zero? --> Yeah, that's a great question. --> I'll go into that more as I talk about the next part. --> But yeah, so what the number you put in here is, --> is you're saying how many values or how many elements --> am I going to set aside? --> So in this case, I want to have five spaces --> or be able to store five values --> in my even numbers variable. --> And so that's what the five indicates here. --> If I wanted to store nine numbers, --> I would make that a nine. --> Oops, you got rid of the closing bracket. --> If I want to store 10. --> So the value you're putting in there --> is literally how many elements or how many values --> do I want to be able to store in this variable? --> Yeah, no, great question. --> Was that your question? --> Okay, and the other thing to keep in mind --> is that in C-sharp, --> some languages when you're working with multiple values, --> you don't really have to tell it how many --> and you can sort of just keep adding stuff --> or removing stuff. --> C-sharp does have that, but it's a little bit different. --> I'll show you that later. --> So with arrays, what we're calling this --> when you're using the brackets, --> with arrays, they're fixed size. --> You have to stay upfront. --> How much is this going to hold? --> And adding and removing them is, --> you're not able to add and remove. --> You can change the values that are assigned in there, --> but you're not able to create new spaces --> or remove spaces, right? --> So right up front, you have to know --> how much data am I going to use in storing this thing? --> And you have to declare that right up front. --> This is going to be integer data --> and I'm going to be able to hold five values. --> Why do we need to declare it twice? --> Why do you need to do the int part --> and then this part over here? --> Yeah. --> Because it's really two different things. --> You're basically, this is where you're telling it --> what it is and then the other side --> of the right side of this equals --> is where you're actually telling you --> to set aside the space. --> Remember earlier when, was it Dustin? --> Were you the one that asked about var? --> You actually could do, you could actually do var here --> and then C-sharp would take a look --> at what you're putting in there --> and it would actually make this a number array, --> an integer array. --> So this is sort of the, you have to be explicit --> and basically spell it out --> because it's really doing two things. --> This is saying what kind of data --> are you going to put in there? --> And then the second part is actually going to create --> the space for that data. --> I think that's what you're asking me, is that? --> Okay. --> So those are the two parts of it. --> You have to sort of declare up front what it is --> and then set aside the space. --> Now, once I've set this up, --> remember with my variables before, --> I was able to just use that variable name, --> even numbers. --> Now, because I have multiple values in there, --> I have to have some way to tell C-sharp --> which value am I talking about? --> So I set aside space for five values in here --> and C-sharp is going to start counting at zero, right? --> So even though I've set aside five spaces, --> that first space is going to be actually called space zero, --> then space one, then space two. --> So there's five spaces, --> but they number from starting at zero. --> So that can be kind of tricky --> if you're expecting that it's going to go from one to five. --> They count from zero to four. --> And then you see that just like when I declared it, --> I had to use those brackets. --> So when I want to refer to which value in that variable, --> I have to use those brackets --> and then I have to use a number that we call the index. --> And that tells us which value that I'm referring to. --> All right, so I know that was a lot. --> Are there any questions about that piece of it? --> I was going to ask Lillian --> and she didn't mind going on mute. --> I'm hearing her keyboard more. --> Oh, typing. --> That's okay. --> Not a problem. --> So this variable can hold multiple values. --> So we're going to use this number we'll call the index --> and that tells C-sharp which of those values --> are you talking about? --> So even numbers zero refers to the first value --> that we store in there. --> Even numbers one refers to the second value. --> So here what we're doing is we're saying assign --> that first value, we'll assign two --> and then the second value we're going to assign four, --> et cetera, right? --> So I declare it to be able to hold five integer values --> and then I can use those indexes --> to assign different values to that variable. --> Let's see, was there a question in the chat? --> Oh, perfect. --> And then to use those, --> just like I can use that index to assign values, --> I can also use that index --> when I'm referring to those values. --> So if I wanted to write out the value --> that's in that first position, --> I can use that zero index to write that value out. --> Same idea with the first, second, third, excuse me, --> fourth position. --> What if I tried to do something like this? --> So I have five values in there. --> What if I tried to do something like this --> on line 23 and write out even numbers five? --> Some sort of index exception, --> index doesn't exist exception. --> Absolutely, so you're basically trying to use an index --> that's out of the range of what you've assigned. --> You set aside these five values --> and so those indexes go from zero to four. --> So if you try to do something that's outside there --> like the five or even under there, --> like the negative one or something like that, --> that's going to say no. --> It's going to blow up when you run your code, --> you'll get some kind of an error message --> that says you're outside the range of those values. --> Okay, so let's take a look. --> So that's what was working with numbers. --> You can also do the same thing --> if you're using strings or other data types. --> So for example, here on line 29, --> I want to declare an array of strings. --> So I'll have that data type of string. --> I'm going to use that same brackets --> to let C-sharp know there's multiple values coming. --> I'm going to call that variable days of the week. --> And then the same idea, when I assign this, --> I'm going to have to tell C-sharp, --> I have to use that new keyword to tell C-sharp, --> go ahead, set aside space for this thing. --> I have to tell it to set aside the space --> and then I can also at the same time, --> remember when we declared our variables, --> we could also assign values to them at the same time. --> We can do the same thing with arrays. --> So here, I'm declaring this variable --> called days of the week. --> I'm setting aside that space. --> You'll notice I'm not providing a number here for string. --> It's actually going to look at the data --> that I'm assigning to that --> and it'll figure out the number based on that. --> So it's like, oh, here's these pieces of data --> you're giving me. --> So I'll go ahead and set aside the space --> for those pieces of data. --> And you're going to see also, --> it's using that same curly brace. --> Right, so curly brace syntax. --> Everything inside those curly braces --> is going to be the data --> that I'm assigning to my array of strings. --> And so again, I can do arrays --> with different types of data. --> They could be doubles, they could be integers, --> they could be strings. --> I'm going to have very similar syntax --> as far as I'll have to declare the type --> that I'm going to store --> and the brackets to indicate that it's multiple values. --> It's an array. --> And then I'm able to assign multiple values to those, --> either right at the time that I create that, --> or as you saw above, --> I can also then sort of individually assign values. --> I get the flexibility to do either way. --> And once I've created this array of strings, --> you're going to see I'm able to use that --> just like I did with the numbers. --> I'm just using the name of that variable. --> It's the days of the week. --> And then I can use that index --> to get that specific value. --> And the big thing to keep in mind here --> is just they start at zero. --> So it's a lot of times not as intuitive. --> You're thinking, oh, the first value in here --> should be one, --> but the first value is really zero. --> So zero, one, two, et cetera. --> Any questions on that part? --> So what's the advantage of using an array --> versus just declaring a regular variable and using that? --> In other words, --> like I could easily have declared day of the week, right? --> I just declared seven days of the week. --> Why would I do that in an array --> versus just declaring seven strings? --> You could take a dynamic route here, --> or any better. --> Just answer some of them. --> Yeah, so basically any time --> that I'm working with related data, --> it's very useful to be able to work with that data --> together as one thing. --> And so that's a common use of arrays, right? --> So since when I'm working with days of the week, --> for example, --> I'm gonna do something related --> with those days of the week, --> storing that in a single variable --> and just being able to use that whole --> set of related data can be very useful. --> Similarly, if I was reading in say grades for students, --> so each student maybe has multiple grades, --> it would be very useful to have all the grades --> for one student in a single variable that I can work with. --> Then I could maybe do some averages --> or I could figure out what's their overall grade, --> that type of thing. --> So anytime you have related data, --> using that data in an array --> is probably gonna be the approach that you'll take --> so that you're working with that data in the same way. --> So let's take an example. --> So we saw looping with for loops --> and we've seen arrays now. --> Let's bring those together and show you. --> So as an example, --> I've got those days of the week --> and I could have worked with those --> sort of individually, right? --> Day one, day two, day three, et cetera. --> But I can also use a loop, --> take advantage of using a loop --> to work with all of the data --> that's stored in that single array variable. --> So here I've got a loop on line 43 --> and I'm gonna start that at zero. --> And what I'll do is I'll just look --> and as long as I haven't reached the end of the array, --> as long as they still have data, --> I'll just continue moving forward to the next element --> and doing something with those. --> So here I'll start at zero --> and I'll check and say, --> as long as I'm not over seven, --> as long as I'm less than seven, --> I'll go ahead and write out that value at that index. --> So I'll write out, --> it'll start out doing days of the week zero. --> Then it'll check, is that less than seven? --> If it is, it'll move my index to one --> and then it would write out days of the week one. --> And so this way with a loop, --> I can very easily take all that related data --> that's in the days of the week array --> and I can run some code for each item that's in that array. --> So this is a very common pattern. --> Now, again, I could easily work --> with those individually, right? --> But typically when you're working with related data, --> you're trying to do some related thing with that data. --> And so I'm able to very easily loop through that array --> and for each element that's in the array, --> I can do something, some operation. --> So here I'm gonna just print out the value --> that's in that element. --> And I'm gonna make sure that I'm still inside the array. --> I haven't gone past the end of it, right? --> So as long as this index is less than seven, --> I'll continue to move to the next item. --> Any questions on that part? --> So I'm just doing that inside a loop --> and basically shorting the amount of code --> that I would write, --> but I'm also making sure that I'm doing the same thing --> for every item that's in that array, okay. --> It turns out this is such a common thing --> that there's actually a shorter way to write this --> as well or a more convenient way. --> So here, what's the challenge with this? --> I have to make sure that I pick the right value here. --> If I accidentally pick a larger value --> or maybe the data in my array changes, --> this is gonna blow up potentially. --> It's gonna have an error, right? --> If I try to read past where that data is at. --> So since this is such a common thing to do --> to be able to read sets of data, --> I can actually take advantage of every array --> actually has information as part of the array --> about how big it is, how many items are in there. --> So I can actually, instead of hard coding that --> or writing that number in, --> I can actually say the name of the array dot length, --> and that will tell me how many things are in that array. --> So the advantage that I'm getting there --> is I don't have to know up front --> or hard code that number. --> I can rely on whatever amount of items are in that array --> I'll just loop. --> And as long as I'm not past the end of that length, --> I can continue looping and print out the current value. --> So it's just the name of that variable --> and then the period, the dot, --> and length is what we're looking for. --> Length will tell us for that array --> how many items are in there. --> Again, either one will work. --> You can do either approach. --> Using that dot length --> is just a little bit more bulletproof --> in the sense that you don't have to worry --> about that number being right. --> C-sharp knows how many items are in that array. --> And so C-sharp knows what the length of that array is. --> And so you can take advantage of that --> and then you don't have to write that hard coded value. --> And then you also get the flexibility --> that if the data in that changes, --> if there's more data than you're expecting or less data, --> you're not gonna have an error. --> Your code is gonna handle that situation. --> Okay, so let's take a look down. --> I'll show you yet another approach, --> another loop that you can do with that as well. --> So we've seen the for loop. --> There's also a for each. --> So in C-sharp, all of the data we're defining up front, --> we have to say what type of data it is, --> what type of data is going in this variable. --> So as a result, when we're looping on through this array, --> C-sharp knows already the type of data that's in there --> and it knows how to loop through that data. --> And so you can actually do this as well. --> You can just use a for each. --> You can say, I wanna get the string values --> from this array. --> So you're declaring a variable that'll hold the value --> for each value in that array. --> So I wanna get a string value, I'll call it day, --> in and then the name of that array. --> And so what's happening here is the runtime. --> C-sharp is actually handling most of the work for you. --> It handles the looping. --> It's handling moving from one item --> in that array to the next. --> And as it moves, it's automatically gonna take --> that current item, assign that into the day variable, --> and then you can just write out the day. --> So again, all these approaches --> that are doing the same thing ultimately, right? --> They're allowing you to loop through an array --> and work with the multiple values that are stored in it. --> You're just getting some different ways to do that. --> And so if you're just working with the value --> and you don't care about the index, --> if all you need to do is go, --> I need to loop through that array --> and work with the values that are in that array, --> then you really don't care about the index --> and all that other sort of overhead, right? --> This for each will handle all of that work for you. --> And basically, we'll just give you, --> it'll loop one time for every item that's in that array. --> It'll automatically assign that value --> of that item into a variable. --> And then you can simply just use that value. --> And any questions on those three different approaches? --> Okay, so you're just getting some different ways --> that you can work with the same set of data. --> And it really, what you use really depends upon --> what you're trying to do with the data. --> If all you need to do is work with the values, --> then this line 59 is gonna provide those values to you --> and they're already set up in a variable --> that you can just simply use. --> So you can actually just write that or read that, --> whatever you need to do with it. --> If you do need to count or you do need to know --> where your current position in that array is, --> then you're gonna wanna keep track of that index. --> And so you maybe wanna do something --> like we're doing on line 51, --> where you're setting up that loop ahead of time --> and you're moving one step at a time through there --> and you're keeping track each time you move --> of what that current position is. --> Why might it matter knowing what position you are? --> So if I have like this days of the week, for example, --> why would it matter? --> Why wouldn't I just be able to use the values? --> Why would I care that this is the value --> from the third position --> or this is the value from the fifth position? --> Can you think of an example --> where that might make a difference? --> So think about this. --> If I had, say I was storing, --> I was gonna store like last names, for example. --> And so I was gonna store last names of athletes --> into a variable, into an array. --> If I just need to display, --> here's all the names of the athletes, --> I wouldn't need the index. --> I could just loop through there --> and just display the values that are in there. --> But maybe the athletes compete in a certain order. --> So I need to know who's the first to compete --> and who's the second to compete, --> who's the third to compete. --> So in that case, I actually do care about the position. --> I need to know if it's the first element --> or the second element or the third element, right? --> So if you do need to know that information, --> then that's why you would need that index. --> If you just need to display, --> here's the names of everybody, all the athletes, --> you don't really need that position. --> So you could just loop through --> and use the foreach to get the values. --> All right, let's take a look at one last thing. --> And we don't use this as often, --> but I do want you to be aware, --> depending on the data you're working with, --> you might run into this. --> So just be aware that arrays actually --> can be multiple dimensions. --> So what I mean by this is --> you can actually have an array of arrays. --> Not super common necessarily, --> it just depends entirely on the data you're working with, --> but sometimes it might be useful. --> So on line 66 here, for example, --> we've got temperatures in Celsius. --> You'll notice that the declaration for that, --> so I've still got the data type --> and then I've got the brackets there, --> but I have a comma in there. --> And that comma is basically, --> if you wanna think about it, --> it's in between the indexes, right? --> So this is basically saying, --> I've got two indexes into my array. --> And if you look at this array, --> so the array is here on line 66, --> goes down to line 69, --> and in between line 67, --> this is the first index in my array, right? --> And then here's that first index. --> So I've got two sets of data --> and then each of those sets of data is also an array. --> So they're individually an array as well. --> And the example we're giving you here --> is that maybe you have temperatures --> and you're grouping them by month, right? --> So the first index in this array --> is gonna be all the temperatures for January --> and then that'll be the individual temperatures --> for days in January. --> Obviously, there's more days in January --> than I'm showing you in here. --> And then the second week of January, --> this might be the second week as well. --> So it's entirely possible if you have related data, --> you can have an array that actually contains arrays. --> So you might wanna say, --> if I might wanna move through --> those individual weeks of January, --> and then I might wanna be able to get the temperatures --> for each day of that week. --> Again, this isn't something that's extremely common, --> but it does happen, --> so I just wanna make you aware that if you see that, --> that's what's happening is that each element --> in that array is actually its own array. --> And in order to be able to get data in there, --> you have to provide two indexes, right? --> So if I wanna get a specific day, --> I'm saying one comma two. --> So that's gonna say line 67 is my zero element, --> line 68 is my one element. --> So that one is telling me go to this element. --> And then within that, go to the second index, right? --> So there's the zero, the one, and the two, right? --> Again, not common, --> just depends entirely on the data you're working with, --> but just be aware that you can hold arrays --> that have other array data. --> So probably the syntax on this one --> is gonna be the most confusing, I feel like, --> when you're looking at the syntax for that. --> The key takeaways are that arrays --> lie for multiple values. --> You still have to declare the data type for those. --> You're gonna declare those using that new keyword, right? --> So that you know to set aside that, --> C Sharp knows to set aside that space. --> You do get the ability to provide data to that array --> and that using loops is a very common pattern --> or a very common way to work --> with the data that's inside your array. --> Let's take a look at an activity --> we're gonna use arrays --> and then we'll be pretty close --> to our final activity for the day here. --> So in this activity, --> we're gonna have you loop through some months, --> an array of months, --> and then we're gonna calculate --> and display the average temperature for the month. --> So we'll have you loop through that month names array, --> display that name of that month, --> and then calculate and display --> the average temperature for that month. --> And sample output we're showing you here. --> So for January, --> we're gonna find the average temperature for January, --> display that, do the same thing for April, right? --> So as we loop through, --> we're gonna do January, April, July, October, --> and then for each of those months, --> we're gonna have to find the average --> of those temperatures. --> And look at the starter codes. --> Let me just move this window for a second here. --> Still hiding behind the window there, there we go. --> And so if you look at the starter code, --> you're gonna see that we're giving you --> some of the data up front. --> So we're giving you the month names, --> we're giving you those temperatures, --> and then our to-do steps --> are basically walking you through --> the pieces that you'll need to write --> in order to be able to do that. --> So to be able to loop through the months, --> display the name of the month, --> calculate, display the average temperature. --> Was there a question in the chat? --> Oh, okay, Hari's just letting us know. --> So Hari, the final activity isn't any new concept. --> It's basically gonna bring together --> all of the stuff we've done throughout today. --> So just take a look and try that activity yourself --> if you won't be with us for that activity. --> I'll message him, let him know that. --> All right, so let's take a look at this activity --> and we'll spend, --> I think it's a little bit more time on this one. --> It's about 15 minutes. --> So we'll go probably till like five after maybe. --> Okay. --> Actually, I don't know if I have contact info for Hari. --> So if one of you could just message Hari --> to let him know about that last activity. --> The final one we'll do is no, not new material. --> It's just gonna be bringing together everything, so. --> I'll message him. --> Perfect, thanks. --> Okay. --> Okay. --> Okay. --> Okay. --> Okay. --> Okay. --> Okay. --> Okay. --> Okay. --> Okay. --> Okay. --> Yeah, ready, go. --> Is there an answer? --> Yes. --> Quick question. --> Is, and we're talking about the answers to this, --> Is there a way to determine the length of an array, like the first array length? --> I know what you're asking. --> I know what you're asking. --> I don't know, get into it faster or get into it faster. --> Yeah, it is kind of a trick question. --> I'll show you when we get to it, but when you have those that have multiple dimensions, --> it's a little trickier to get the length than it is normally. --> I figured it was, but I was like, at the end of it, I was getting ready to start Googling it, --> and I thought, oh wait a minute, maybe I'll just wait and see what you guys say. --> Google's your friend, Google's your friend, absolutely. --> Google, Google. --> Okay, let's take a look here. --> Let's see, am I sharing the right one? --> Okay. --> So one of the things I like, I'm really happy about this class, excited that the questions that you're asking are fantastic. --> And so you're thinking about the right kinds of things, right? --> So here we've got, we're starting out with month names and we've got the temperature there in Fahrenheit. --> And what we're trying to do is display a couple of different things, right? --> So we want to be able to loop through the months and display those. --> And so since we have those variables that month names declared, --> we can actually just loop, do a loop to get the names of those months, right? --> So we can do a for loop and just do something like, you know, I equals zero. --> And then as long as that's less than, you know, the month names that we have. --> It's funny, VSPR Visual Studio is actually trying to write the code for me there. --> So as long as that's less than the length, then we'll go ahead and be able to loop through those. --> So we're just going to start at zero. --> And as long as there are indexes less than that length, we can just increment that or we can move through that. --> So that'll start here at zero. --> And we can just print that name, January, April, July, October. --> So we could do something like console. --> And then we can do write line. --> And then in order to write that out, I'll have to do the name of the month, right? --> So month names. --> And then I'll just use that index value and write that out. --> So as that index moves from zero through that array, I'll be able to write out those names of the month. --> Was there a question in chat? --> No, not a question. --> Oh, perfect. --> OK, so this will allow us to move through those names. --> I think everybody, as I was moving around between the monitors, everybody was able to get this part. --> 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. --> So that's going to handle sort of the first part of this. --> So that covers this. --> Actually, these two rights are looping through as well as displaying the name of that. --> So now the challenge is then how do I get those average temperatures for the months? --> So each of these arrays or each of these elements in that temperature array is going to represent a month. --> So that's going to be our January, our April's line 13, right? --> Line 14 will be July and line 15 will be October. --> So I need to be able to loop through those sets of values. --> And then I also want to be able to loop through the values for each month. --> So the question when you were asking earlier was, hey, I can do dot length here. --> Is there a simple way to do the same thing when I've got the two dimensions? --> It's not quite as simple, right? --> It's actually a little bit trickier, but I'm going to try a different approach. --> I'm actually going to do this. --> This right here, this index is already doing the first part for you, right? --> So this is already going through the months, the four months. --> So this will actually do the same thing. --> It'll actually loop me through the four sets of data. --> So all I need to do is in each set, I need to just get the right values, right, temperature values for that month. --> So if I want to get January and then I'll get April and July and October. --> So what I'll do actually in here. --> Is I'll just loop through the data for that. --> That set of the daily temperatures, right? --> So in here, I'll just do you can call these whatever, you know, whatever you want to. --> The default is going to give me like I and J or something. --> But here I'm going to just loop through there. --> And I can do a couple things. --> One is I could just hard code it, right? --> I could say, well, I know that there's 24 days in there. --> So as long as I don't go over that, I'll be fine. --> And I'll show you the end, the other shortcut or other way you can handle this. --> I think I got a typo up there. --> It's lagging. --> I don't know if you can see it. --> It's lagging just a little bit. --> There we go. --> So what I'm relying on the fact here is I'm actually going to use two loops. --> 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. --> I'm going to say, OK, well, I need to loop four times. --> And then within those, I need to loop 24 times to get all of these days that are in there. --> So I'm going to loop four times, one for my each month. --> And then as I'm looping, I'm going to loop through the set of data for that month. --> So I'm actually getting those two indexes. --> This is going to be my basically row. --> If you want to think about it like this is what row I want of data. --> And then the second J, this is actually going to be my columns. --> So I'll get each day of that month or each temperature for that month one at a time. --> So that's going to allow me to sort of move through that set of data. --> But what I need to be able to do is actually calculate the average. --> So what I'll do is I'm going to say, let me store the total. --> I need to figure out the total temperature for that month. --> And so I'll store something called total temperature. --> If I could spell, I would call it that. --> And I'll just say that that's zero currently. --> And then as I loop, as I move through each of those days, I want to keep adding up that value. --> So here I would say something like, oops, I'm sorry, I'm doing this in the right place. --> Let's see here. --> I think I need to do that. --> Oh, yeah, I'm doing it inside here. --> If I did it in here, it would just change. --> It would be zero for sort of zero for every day. --> So I want to get the total for that month. --> So as I loop through each month, I want to get the total temperature for that month. --> So I'll start it out at zero. --> And then as I move through each day, I'm going to just add that total temperature up. --> So I want to just say total temperature. --> It's trying to write the code for me. --> As I loop through that, I want to say total temperature equals and then I want to get the current temperature. --> So that's going to be the month and then the day. --> Give me that total temperature. --> All right. --> So each month, I'll go ahead and loop through all the days of temperatures I have for that month. --> I'll add those up. --> And then at the end of this, I should have that total temperature for the month. --> So here, if I was to say console, right. --> If I was to write total temperature. --> I'm expecting that that's going to be the total temperature for that month. --> So I'm going to write out the name of the month and then hopefully this writes out the total temperature. --> And I'm actually going to just save that and see if that works. --> That first part. --> So if I run that, let's see if that's going to give me a number. --> So here I'm getting for January, I'm getting a number, April getting a number. --> 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. --> 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. --> All right. --> So let's go ahead and. --> None of that up what's in the chat. --> Oh, yeah. --> 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. --> So so far I am getting the months and I'm getting the total temperature. --> And now I basically here just need to display that average temperature. --> So I'm going to go ahead and say, how do I get that average temperature? --> I'll just bring this little comment up here. --> So this is where I need to get my average temperature. --> So my average temperature. --> It's crazy how that little bit of a delay makes me over type it every time. --> So the average temperature then is going to be. --> Oh, yeah. --> I'm going to store that as a double actually, right, because I'm going to have some decimal points in that. --> And that's just going to be my my total temperature that I just calculated there. --> And then it's just divided by the number right there in there. --> So this will give you my total for those 24 days. --> And then if I divide that by 24, I'll get this average temperature. --> And then I can just write that out as well. --> Right. So just console. --> Right. --> There we go. --> And write that average temperature out. --> And I don't need to write the total out anymore. --> So I'll just comment this line out. --> OK, let's try saving that and running that, see what that gets me. --> And so now I'm getting 51, 55, 69, 64 for my averages. --> Did you share the link for the how to get the index? --> No, I figured if anybody else wants to go ahead, they can do it. --> Yeah, even Google is definitely your friend. --> Right. So there's always going to be those sort of weird things that you very rarely use. --> But when you do need to know them, they're useful. --> 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? --> You're going to see that just like we have dot length, you can actually get the length of those different indexes as well. --> All right, so the big takeaway here, arrays allow you to store multiple data, right, multiple values of data. --> 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. --> And then in this case, you know, do some calculations. --> Right. And just like we saw before, you're not limited to the amount of code that's inside that code block. --> 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. --> But it still works the same way. So it's going to have the four keyword. --> 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. --> Besides the crazy extra array in there. --> Any any other questions about this? Did anybody solve it a different way? --> Okay, you could you could have you could have done it as two loops. --> 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. --> Again, the key thing is your code may not look like my code or may not look like the salt code. --> But the important thing is that if you understand what your code is doing and it works, you get the correct result. --> That's really the key takeaway. Understanding what it's doing and having your code be valid. --> Right. Give you give you the right result and right output. --> 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. --> So we've talked about variables, data types. --> We've learned how to do conditional checks. --> We've learned to do some looping. --> And now we've learned how to store multiple values in a variable. --> So the only thing remaining is bringing those all together. --> Right. So this final activity for the day grades will have a little bit more time on this one. --> I think it's like 20 minutes roughly. --> 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. --> So this activity you're going to see you start with almost no starter code. --> 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. --> So we're going to create some variables. --> We'll practice creating some variables. --> We're going to store some data here. --> We're going to want to store the names for a couple of students. --> And we have sample data that if you don't want to be creative that you can use the sample data. --> But we'll store some variables for at least two students. --> We're going to store three exam scores for each student. --> And so we're going to want to be able to just like we did with the temperature activity, --> we're going to want to be able to loop through those students and display their average score. --> And then we're also going to use that average score to figure out what their grade is. --> So we're going to have to loop to figure that score out. --> And then we'll have to compare that score to decide what letter grade does that student get. --> Here's a sample data we're going to show you just if you don't want to feel particularly creative today. --> So we've got two students here, Samantha and Ethan. --> We've got three exam scores for each of them. --> And then when we run our code, what we're looking for is something like this for our output. --> So we're looking displaying that student's name, what their average score is from those three exams, --> and then what that means their letter grade is going to be based on. --> So given you the opportunity to kind of apply all of these things that we've talked about today. --> And again, if you take a look at starter code, --> it's rolling pretty light for this activity. --> So starter code is going to just give you that solution and project. --> And then some ever helpful comment about this is where your code goes, but not a lot else. --> So you're going to need to create some variables, some arrays to hold that data. --> You'll need to loop through that data, display their name, display their average score. --> And then you'll need to do some kind of conditional, right? --> To figure out what does that mean their letter grade is based on that score that they got. --> Are there any questions at all before we start? --> Okay, so perfect. So we'll do about 20 minutes on this, and that'll take us pretty close to perfect timing. --> We'll give us about 15 minutes to kind of wrap up, review this, and then we'll get out of here for today. --> Okay. --> Okay. --> Okay. --> Okay. --> Okay. --> Any blockers? --> It looks like everyone's kind of working their way through it. --> So does anything, any questions you have, whatever, just let me know. --> All right. --> About like four minutes or so, and then we'll review what we've got. --> So let's take a look at what we had to work with here. --> So we know we need to have some variables that represent some of our data and pull some of that in, right? --> So the first thing that we needed to do there was create some things to store that. --> 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. --> So let's take a look. --> I'm going to go ahead and declare some student names. --> Whoops. --> And I make that an array. --> Let's see. --> Are you able to see my screen? --> Okay. --> For a minute there, it didn't have a little green outline, so I wasn't sure. --> All right. --> And so we're going to create some student names. --> And we know that's going to be string data, right? --> So we'll do our string array. --> 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. --> 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. --> 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. --> It gets confusing sometimes remembering where those curly braces should go or where the semicolons should go. --> So in this case, I'll just fill that out first and then I'll go and put some data in here. --> And then same idea. --> We'll put a couple of students. --> And get that data in there. --> The white space I'm kind of adding around this totally unnecessary. --> It just makes it easier to read. --> So just be aware for the majority of things you'll do. --> C Sharp really doesn't care about the white space. --> It's really more about where the curly braces and where's the semicolon. --> I also need some exam scores, right? --> So we'll do an integer array for those. --> 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. --> And so we'll just call that exam scores. --> And obviously, as I'm going to feel free to interrupt ask questions, I don't have any issues with that at all. --> So I'm going to create an array of exam scores. --> And you'll notice on this with the int array, I'm not even using the new type thing, right? --> I'm just doing int. I'm not even using new int. --> I'm actually going to just give it the data and let it figure out what that means. --> How many rows and columns that need to be in there. --> And so I need to have two sets of data, right? --> So I'm going to have one set of data and then comma my second set of data. --> And then in here, I'll just fill out those scores that I need. --> So I'll just make up some numbers here. --> I think my sample got 64 and like 92 or something. --> And then same idea for this student. --> We'll just give this student some scores. --> So 78, 85 and 89. --> Shane. Yes. --> Is it OK to have those on the same line? --> Oh, absolutely. --> Yeah, absolutely. Great question. --> Yes. So just like everything else, the white space is really just for you and me. --> It's for readability. --> But I could absolutely do this all entirely on one line, right? --> So this is all just just to make it a little bit more readable when human beings are coming in. --> But sometimes, you know, if it's just these two exam scores, this might be perfectly readable that way. --> And again, for the most part, Python, the indentation of the white space matters. --> C Sharp really does not care. Great question. --> So I've got a couple of sets of data there. --> So I've got my student names and my exams. --> Let's see what else I need to do. --> I need a loop, right? Do some loops here. --> So we'll do a for loop and then the same idea. --> I need to be able to loop through those values. --> And as long as that's less than all the student names. --> Length. --> Then we'll go ahead and keep moving that forward. --> And so, again, we're going to just be able to loop through those values in that array to work with that data. --> And I think I'm done with typing. --> So let's switch over to the solution code. --> I don't want to type out the rest of that's a lot. --> It's a lot of typing. --> All right. So let me take a look over here. --> Go ahead and close this one. --> And close that one. --> OK, then we'll just open the solution for this. --> 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. --> Just as kind of a way to review what we've done. --> So if I take a look at this great solution. --> And I'm definitely going to try doing this just off my desktop tomorrow. --> I think this will be quicker for this part for sure. --> Plus, you'll be able to actually see the code a little bit better on my desktop. --> OK, so let me move some zoom windows around. --> All right. Fantastic. So we have the students created. --> We have the scores in the chat. I linked you. --> I know a couple of you looked it up with the multidimensional arrays. --> You can get the the length of those individual indexes here. --> Here I'm just going to actually just provide some values. So I know I have two students. --> I know I have three exams and then I'll just use those values down here to loop. --> So I'll live for my number of students. --> Just like we did with the temperature, I'm going to need to track that total score. --> 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. --> So I'll go ahead and keep that zero originally. --> And then as I loop through their exam scores, I'll go ahead and add that total. --> Keep track of that running total for that student so that I can then get the average for the student. --> So I'm using two indexes here, right? --> The first one represent which student row am I getting of data? --> And then that second index is indicating which exam or which score from that row am I getting? --> So the outside loop is moving through my students, the inside loop is moving through their scores. --> Your visual like I am. So that first loop is going from this row to this row. --> Super dry today. And the I apologize for that. --> And the second loop is going through those scores, individual scores for each student. --> Again, lots and lots of ways that you could do the same code. --> The important thing is that you understand what the code is doing and the code is working. --> Many ways you could have solved the same problem. --> So we'll write out the name of that student here on line twenty seven, loop through their scores. --> And then once we have that total score for them, then we're able to get their average score, right? --> So once we've got their total score, we can write that out. --> Here's your average score. --> And then we can use that average score. --> We can compare that to actually figure out what letter grade they get. --> So if that final score is an eighty one, then we can actually compare that. --> We can say, OK, well, if it's greater than or equal to 90, but less than 100, it's an A. --> If it's between 80 and 90, they're equal to 80 or greater than less than 90. --> That'll be a B. --> And so we'll do each of those checks to figure out what that final score is. --> And then we can write that grade score out for the students as well. --> And then so we can finally go ahead and write out that grade score for those students. --> And so I know we covered a lot of things in this activity, a lot of different pieces. --> Any any questions on any part of this? --> Or did anyone maybe do it differently and run it as an issue? --> Oh, good. --> I was going to ask, is it possible to put different types of data in the same array? --> Or would you just be like, please just create an object at that point? --> Yeah, that's actually a good point. --> So C sharp doesn't let you put multiple or different data types in. --> So when you're declaring the array, you're declaring that as a specific type. --> And so we're so you're declaring that data type. --> 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. --> We'll actually kind of store that in a different way. --> And we'll talk about that tomorrow. --> So by default, when you're creating these things, these arrays in C sharp, just like your variables, you're not mixing types. --> So all of the scores are going to be integers. --> You know, all the student names are going to be string. --> And then, yeah, to your to your point, we'll take a look tomorrow. --> Exactly. Hey, if I have different data types that are related, how do I work with that? --> That'll be exactly what we'll talk about tomorrow. --> So perfect. --> Was there another question? --> Did you have a question, Kelly? --> It's fine if not. --> I just want to be sure we don't have any questions. --> Don't go. --> Kelly may have locked out. --> Oh, it still shows connected. --> But maybe she got disconnected from the session. --> OK, well, we have about four minutes or so left, so we should be OK. --> 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. --> Hopefully, either way, you got some some good grounding, some good fundamentals. --> 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. --> I can speak to the C sharp side a lot better than the Python side. --> But, you know, but I know there are some differences in kind of the way things are handled. --> And you've been asking great questions about that already, I think. --> So today we've kind of covered just sort of all the starter tools that we'll need to dive into our code tomorrow. --> 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? --> And then day three is going to be a lot about unit testing. --> And right now it's XML. --> Do you do you currently use XML? --> I think you use mostly JSON from what I was understanding. --> Is it mostly JSON data? --> Yeah, OK. --> So the core discourse material talks a lot about XML. --> I'll take a look. --> 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. --> 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. --> I'm not sure. --> Oh, OK, OK. --> It's funny. --> The trend has been kind of the other way. --> Right. --> Ditching XML. --> I mean, I prefer JSON, but we'll see what we get. --> Well, if it's C Sharp making your choice, C Sharp is with you. --> C Sharp is definitely JSON. --> But there's a lot of XML legacy stuff. --> You know, C Sharp, just like other languages, has been around for a while. --> So there was a lot of XML support. --> Everybody was going to XML. --> And now the trend is everybody's using JSON instead. --> So that's kind of where the current new stuff is at. --> But otherwise, if you have any questions, I would say thank you for your time today. --> And hopefully this answered a lot of questions. --> 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. --> And then tomorrow we'll kind of build on that. --> 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. --> So no other questions. Have a fantastic day. --> I will see you tomorrow. --> Bye. Thanks.