C# for Automation Test Engineers
language: EN
WEBVTT you're gonna get them probably as you go more comfortable. But I know every tab will have the name of the student, so you should not be, you will have, let's say, see my tab, Maria, next to it will be, hey, or other names. Everybody will have their name, so you will be able quickly to jump to tabs and see what people are doing. Okay. Yeah, typically I would just use Zoom as sort of the main window. And then if students need help or as they're working on activities, that's usually why I would pop around between test ops. Yeah, very much. Yeah, mainly your screen and then if they want to see how the time is, you can email, just check in how everybody is doing. Yeah, absolutely. Okay, so, I have so many windows open now. I'm so disposed of. So, as a participant, I see the same way right now. I see your screen on, actually I'm gonna share. I should record this one. Yeah. I pretty much see it the same way as you just had. Okay. As a participant. See, so it's like I have my screen on this side and I can see your screen. Oh, okay. On the left side. Yeah, and there's some other options here, I think, to make it full screen. So, I can see only my screen if I want. So, participants can see other participants' screen or that's just for myself as a trainer? Just for yourself. Okay. They can now see only you and their screen unless you will share. As far as I remember, you know, devs are changing things constantly, so I'm not sure maybe something changed. Okay. But when, let's say, somebody struggles and you want to show them as an example, just share the screen and share the tag of that person that you want to work on. Yeah. So, everybody will see that that makes sense. Yeah, absolutely. Thank you. So, kind of makes sense, right? Yeah, it's pretty straightforward. This is actually nicer than the platform that I use normally where it's more difficult to see and interact with the students' desktops. Yeah, and like I said, most 90% of the participants have issues with their Internet. Otherwise, I never had any problems.
on 2024-03-22
language: EN
WEBVTT Yeah, I can see you. All right. Yeah, it's pretty fast for me, so that's good. Visual Studio, probably. So you will go through the whole process of installation? It's already, everything's already installed. Oh, it is. Yeah, I didn't want to have to. So I installed it, and I opened everything up, and made sure it was all configured and everything. So yeah, we should be getting up. So where do I get all the, probably here maybe. Let's see, Visual Studio. That's code, VS Code, yeah. I put that on there just because it makes some of the files easier to read that we believe we work with. Yeah, so if you go to Visual, just type Visual Studio in the Start menu or the Search menu. Yeah, I already got it. No, that's a different tool. That's what I'm saying. Yeah, there's two different tools. So yeah, Visual Studio, there you go, right there. 2020's in. Yeah, I put the Visual Studio code on there just because some of the files we work with, it's easier to open them in that and see what they look like. But this is the tool we'll be using, Visual Studio 2020. Yeah, it looks pretty good. I mean, I'll probably need to zoom and stuff depending on what the students are doing.
on 2024-03-22
language: EN
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 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 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 might have mistaken 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 that the course was for, 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 gonna see the option there. Yeah, 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 repos. 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, and now 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'm trying 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 eyes. I'm doing this with my eyes. 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 I got or say my eyeglasses are already today, I'm like, yay! So like, Fista 5, how are we doing? Like Fista 5, how are we doing? Five, you're finished already? 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, they sent me calling, just kill me. I'm just like, let me just do it. It's a little bit different, right? 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, there's just 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 that it'll need to create. For example, if you're running a desktop application, versus a web application, is it 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 in 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. Ha ha ha. 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 I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. And then I'm gonna call it Hello World. 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 getting 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 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. 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 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 activities going forward, 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? You're 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 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 has run, something like that. What might be some other examples of things that we would wanna track in a program? The idea of an activity in MES web. That's a good one. That seems very specific. Yeah. So something like the activity ID, right? Yeah, it's a GID. Oh, okay, all right. Oh, let's try to highlight. 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 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 air there when I do that. And a string is gonna just be data like, like character data, like a first name or a file name, paragraphs under 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 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 like, 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 that we look for in anything? 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. Oh, go ahead. Sorry, who was that? Is that Harri again? Vincey. Oh no, good, Maria, I'm sorry. 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, 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 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 then 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. Is 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, and 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. Yeah, it's interesting. I actually picked a larger size machine or more memories so these would open faster, but it still seems a little bit slow. Yes, it seems like everything looks good on my end. 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 about file name 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, we're gonna 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 had 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 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, right, 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, you know, 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 this, 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? Is it compiled 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, and especially 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, and 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 decibels 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. Long is something higher than the second one. 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? So 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? 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 lowercase true is what you're gonna see, or lowercase 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 true and 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. Gotta 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. It knows 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 lowercase. 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 it gonna, the code's still gonna work? The code will still work. But this is just a typical common practice. And if you're looking at other people's code or people are coming to the 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 variables something that makes sense. 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? So just having consistent, well-named variables is only gonna help you later. I could name these G, S, T, H, Z, X, 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 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. And obviously, 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, cache for automation, lesson one, activities. 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, goes with that. 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 should have all your files and everything for you. Yeah, so on the right side, 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 the 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. 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. Yeah. And so here the instructions 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, all 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. It's 11, we're 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. Another minute or so and then we'll take a look. Let me just adjust my zoom, what does here, let's see, hide that. There we go, okay. Let's zoom 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, 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? You 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. Down here, is that gonna do? It's auto sizing this window now. All right, well one second here. 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 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. Or 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 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, semi-colon, 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 rounded 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. Let's just say 220, right? That sounds good. What was the last thing we needed? 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. So as I start to type, for example, true, you see how it's giving me the option to accept that, right? 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 in 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 as 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 semicolon 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 semicolon, right? But does white space matter in Python? Is 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. 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. Semicolons, very important. What else? I want to show you this one. I think that's really it. And then again, the data types. Somebody, I forgot you said this earlier, maybe it was Lisa about, how do I know what 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 did I have for you on this? Let's see. Oh, sure. Do you ever recommend using bar as a data type? 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 and when we start doing that as well. Great question, though. 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 kinda grouped into some categories here, once this opens up. Okay, so they're kinda 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 an 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. 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? And the idea is- Divide by division? 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 changed 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 not? 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 not. 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 not, 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 not in front of it makes it false. If it's false, putting the not 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 nots, 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. 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 time. 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? 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 quiet is 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. That'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 a 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 have available to you 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, I 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. I will stop you. Let's have a remember that crazy sequence, control shift alt H. I think about a minute or so here and then we will take a quick break. 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 a 16 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 because you're getting a 15 minute now and then the 16 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 break. Any questions? I'll see you back in about 15 minutes. 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 review that. Any question? So that's nine to four. 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 17. I totally missed one. I thought you were asking me for my number. Ha ha ha. Oh, okay. 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. Oh, okay, okay. I saw there was a- No, I'm sorry. Oh, no, good, I'm sorry. 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. Ha ha ha. 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 for me well. I mean, if it helps to do it, you're welcome to code along with me, like 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 slightly different code, but very similar ideas. So I don't know if that helps, you're welcome to do that. Yeah, and Kayleen, in college, what we used to do is we used to call 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, whatever 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. My professor was fast. 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. He was just very passionate. So he comes and he went off the subject, and then we had to go back and try to catch up. It's like, well, I know it's. 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 gotta 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, you know, 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 on this is a takeaway. Let me zoom in on my desktop here real quick. 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 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. You have one. Sure. It's on the second one. I would add a question from the computer because I noticed you had an integer sort of 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 the 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 results 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, right? 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- It does look like it. 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. 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 a zero. Well, in this case, it's even, it divides evenly. So you're getting the zero. Any questions that any of the comparison operators, I'm sorry, any question of 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 in 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 is 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-sharp. Yeah, it's actually a keyword, 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 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? Kinda keep scrolling this thing apparently. 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 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. It 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, 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, 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, yeah, 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. Should be 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 equal 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 that. It's a- Sorry, this one. Sorry. Yeah, it's matching exactly to the 9.1. It's exactly what 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'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 stall 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 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 going to 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 going to store value in there. We're going to store this 37.5 value in there. And again, this is what all of your code is going to do. You're going to have data that you want to track, that you're interested in keeping track of, and you're going to 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 want to, based on the value of that variable, I want to do something. So I'm going to check and see if the value of that variable is greater than 37, I want to 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 want to check inside those parentheses. So C sharp is going to 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 going to see on my if statement, I've got curly braces, there's an open and 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 write 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 going to have get executed or run based on the values that we have on 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 going to 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 going to be the body of this. And so that code that's in the body of the if there on line 13 is only going to 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 want to make decisions, right? So for example, in this case, I might want to 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. Oh, it's the fact that we're like 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. Yeah. That's a great call out. Thank you. But the key value we're getting with these, the conditions, 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, 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, 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. So why would we do something like this where we're checking these two conditions versus just the one condition? One example that might be relevant for our stuff is, say we have a CNC instant quote, the part that went through CNC instant analysis, we might check, is it a CNC quote and then also did it successfully go through instant analysis? Yeah. Yeah, 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 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. 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 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, 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 a 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 else's, 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 else's? 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? 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, 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 did 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, 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. Okay, I got you. 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'll 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 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. All right, and if we take a look at the code, let me hop over there real quick. It's not too bad. Once I figure out the lag, I can kind of adjust for it. 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 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, I 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. 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. 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. 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. Oh. 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? Let's 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. 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 a chat, I'm not gonna see it right away, just FYI. 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. Has 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. 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 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 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. 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, right? 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. 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. 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. Oh, 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 in 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 it'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 somewhere else. Yeah, other languages support it. I don't remember if Python does or not. So again, you're perfectly welcome to use the if-else 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 just 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 for our 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, 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. Well, when that's done, we'll take a look. The tricky part with this is 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 day 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 is 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, right? 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 into it. Do you want to other screen, but I can try now. Yes, 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. 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 another break, 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 it'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 yeah or no. Yeah, I'm fine. 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, you're done? Okay. Yeah, let's do that. We'll come back at 145 and then we'll have almost, 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. One, and then one, 145, will be activity. Oh, damn it. 145, 169, 10, 11, 12. 145, 169, 10, 11, 12. One, two, three, four, five, six, seven, eight, nine, 10, 11, 12. Oh no. 145, 169, 10, 11, 12. 145, 169, 10, 11, 12. 145, 169, 10, 11, 12. 145, 149, 10. 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. 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 four 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. 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 a for loop. So the F-O-R, four 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 of 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 four 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. 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? Increment it. 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 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 use 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 this each time is 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 than here than just writing out a number. But anytime 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 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. Oh, fantastic, great example. So basically, anytime you have a set of data, so I was gonna say, as an example, if you have students, and you wanna print out the students' 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. Oh, is there something in the chat? Let's see here. Oh, yeah, perfect example, right? Complete each task and 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 devlog and code. Let's take a look at another kind of loop. So here's a loop, and we'll use this keyword, while. So you're gonna notice here, it's a little bit different. So in the while loop, I'm actually setting some value here, I'm 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 you're 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, right? So here it's inside the loop on line 28, we're actually gonna move the value of K, right? 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, right? 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, right? 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? Zero. 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 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 ever 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 so. 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 to 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, you know, 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, activity 12. 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. 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 and we can talk through it a little bit there. You should share my screen. Go ahead and close out of this. Okay, now we'll put 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 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, right? 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, set a right 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 right version of that, it actually is just gonna 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? So 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 then the final part of that is what's moving the loop. Okay, let's look at, 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 gonna have the while, it's not reading my mouse, there we go. It's gonna 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++ line in here? It'll wait, and then. 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 gonna change somewhere inside that loop. So here we're gonna 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? So we'll continue to 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 this, the end part here, what's our line 29, what's the end part of our loop doing there? Yeah, it's actually 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 gonna 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, so quotes with nothing in that, and then we're actually gonna, at least one time, we wanna message the user to have them enter a command and we'll tell them that they have to enter a queue to quit. And so inside that loop, you're gonna 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 gonna 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 queue, 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 queue, we'll just continue to do whatever work we're gonna 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, 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 queue, 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 wanna do the do while. Hey, Shane. Yes. There's that warning, if that's what you wanna call it, online, your line 39 for sure to M. So the way I understand that is that you don't have to define it empty, you can just say stream. 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 remove 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 gonna 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 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, 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 wanna work with sets of data. A set is actually a thing in Python, right? I need to stop calling it that so I don't confuse you with the Python link. We do have sets. I think we mostly, at least in our framework, cover, use like lists rather than sets. Okay, I just don't wanna confuse the terminology too much because I'm using it just generically as if you have multiple things. So 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 gonna 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. So not just one even number. As I find even numbers, I wanna store them in this single variable so that I can work with them as a related group of data. So you're gonna see, I still have to give it a name, even numbers. I'm still declaring the type of data that I wanna store. So I'm gonna 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 gonna store integer type data in this variable, but I wanna store multiple values in here. And so the brackets is how I'm indicating to C-sharp. There's gonna be multiple values in this single variable. So that's the first thing that's gonna be different. The second thing is gonna be, how do I actually declare how many, how much data I'm gonna store in there? So the second part of this you're gonna see, we're gonna assign to this. And you're gonna 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 wanna 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 gonna store in there. So what I'll do is I have to use the new keyword. So anytime I'm gonna 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 gonna see here, I have to provide a value, a number saying, how many values do I wanna 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 gonna 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 gonna 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, is that different than the elements? Is that, like I see underneath, that is element zero, O equals two, O is four, but it's gonna say zero. Does the new int four 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 gonna 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 say 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? 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 to see that mine's going on me. 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. 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? It's 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 gonna say no. It's gonna 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 wanna declare an array of strings. So I'll have that data type of string. I'm gonna use that same brackets to let C-sharp know there's multiple values coming. I'm gonna call that variable days of the week. And then the same idea, when I assign this, I'm gonna 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. Notice I'm not providing a number here for string. It's actually gonna 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 gonna see also, it's using that same curly brace, so curly brace syntax. Everything inside those curly braces is gonna 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 gonna have very similar syntax as far as I'll have to declare the type that I'm gonna 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 individually assign values. I get the flexibility to do either way. And once I've created this array of strings, you're gonna 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 started zero. So it's a lot of times not as intuitive, right? 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? 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 value and then just add it to it. Yeah, so basically anytime that I'm working with related data, it's very useful to be able to work with that data together as one thing. 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 may 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, 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 I 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, 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 operations. 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. 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. It turns out this is such a common thing that there's actually a shorter way to write this as well or 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 upfront or hard code that number. I can rely on whatever amount of items are in that array, I'll just loop it 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 upfront, 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 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, right? 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 lies 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 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 the 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. 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 upfront. 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. Sorry, here's still the Hari. He may have already left, okay. 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. 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 not new material. It's just gonna be bringing together everything. I'll message him. All right, thanks. Hey Sam. Yes. Quick question. It's in a loop, what does the answer to this, but is there a way to determine the loop of an array, like the first array, like, yes. I know what you're asking. I know what you're asking. I don't know, getting to it faster or getting to the first two. 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, I was getting ready to start Google on it, and I thought, oh wait a minute, maybe I'll just wait and see what he has to say. Now Google's your friend, Google's your friend, absolutely. Yeah. Google, 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, 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 wanna be able to loop through the month 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, VSK or 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 gonna start at zero, and as long as our index is less than that length, we can just increment that, right? We can move through that. So that'll start here at zero, and we can just print that name, January, April, July, October, right? 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? Nope, not a question. Oh, perfect. Okay, 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 we were able to take that array, use the .length and move through that array to get those different name values. So that's gonna handle sort of the first part of this. So that covers this, actually these two, right? So looping through, as well as displaying the name of that. So now the challenge is then how do I get that, those average temperatures for the months? So each of these arrays, each of these elements in that temperature array is gonna represent a month. So that's gonna be our January, our April's line 13, 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 wanna be able to loop through the values for each month. So the question when you were asking earlier was, hey, I can do .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 gonna try a different approach. I'm actually gonna do this. This right here, this index, is already doing the first part for me, 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, temperature values for that month. So if I wanna 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 set of the daily temperatures, right? So in here, I'll just do, you can call these whatever you want to. The default's gonna give me like I and J or something. But here, I'm gonna 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 at the end, the other shortcut or other way you can handle this. Oh, 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 when I'm relying on the fact here is I'm actually gonna use two loops. And since there's four months, and there's also four sets of data, data for each month, I'm just gonna rely on that loop. I'm gonna say, okay, 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 gonna loop four times, one for my each month. And then as I'm looping, I'm gonna loop through the set of data for that month. So I'm actually getting those two indexes. This is gonna be my, basically row. If you wanna think about it, this is what row I want of data. And then the second J, this is actually gonna 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 gonna 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 gonna say, I need to figure out the total temperature for that month. So I'll store something called total temperature. Well, 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 wanna keep adding up that value, right? 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 this, 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 wanna get the total for that month. So as I loop through each month, I wanna 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 gonna just add that total temperature up. So I wanna just say total temperature. It's trying to write the code for me. As I loop through that, I wanna say total temperature equals, and then I wanna get the current temperature. So that's gonna 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 write, if I was to write total temperature, I'm expecting that that's gonna be the total temperature for that month. So I'm gonna write out the name of the month, and then hopefully this writes out the total temperature. And I'm actually gonna just save that and see if that works, that first part. So if I run that, let's see if that's gonna give me a number. So here I'm getting for January, I'm getting a number, April, I'm 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 gonna have to take all those numbers and divide them to get that average, right? So let's go ahead and exit out of that. What's in the chat? Nothing, just continuing the previous conversations. Oh, yeah, so there's a special way when you have the multiple dimensions that you have to get that index, 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 gonna 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 gonna be, I'm gonna store that as a double actually, right? Because I'm gonna have some decimal points in that. And that's just gonna be my total temperature that I just calculated there. And then it's just divided by the number, right? That are in there. So this will give me 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? Look, 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 one out. Okay, 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 in, they can do it. Yeah, I thought it would be by once a day. Yeah, even Google is definitely your friend, right? So there's always gonna 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, if you search on something like, how do I get the index of a multiple, a multidimensional array? You're gonna see that just like we have .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, 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, 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 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 gonna have the for keyword, you're gonna have some condition to start the thing off, something to check to decide how many times it loops, and then be able to move through that loop. Besides the crazy extra array in there. Any other questions about this? Anybody solve it a different way? Okay, you could have done it as two loops. You could have looped through the months and displayed those, and then done a separate set of loops to do the temperature. Again, the key thing is your code may not look like my code, or may not look like the solve code. 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, give you the right result and right output. So we've talked about all of the basic tools that we're gonna 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. So this final activity for the day, grades, we'll 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 gonna 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 gonna create some variables, we'll practice creating some variables. We're gonna store some data here. We're gonna wanna store the names for a couple of students. And we have sample data that if you don't wanna be creative that you can use the sample data, but we'll store some variables for at least two students. We're gonna store three exam scores for each student. And so we're gonna wanna be able to, just like we did with the temperature activity, we're gonna wanna be able to loop through those students and display their average score. And then we're also gonna use that average score to figure out what their grade is. So we're gonna 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 gonna show you just if you don't wanna, feeling 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 gonna be based on. So giving you an opportunity to kind of apply all of these things that we've talked about today. And again, if you take a look at a starter code, it's rolling pretty light for this activity. So starter code is gonna 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, right? So you're gonna need to create some variables, right? You're gonna need 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. It's 15. 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. About like four minutes or so, and then we'll review what we've got. So let's take a look 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 differently or a couple of different ways of doing it, but there's no really right or wrong way here. So let's take a look. I'm gonna 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 gonna create some student names. And we know that's gonna 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 gonna create a new string array of data, and then I'm just gonna create my curly braces for the data that I'm gonna 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 ahead and put some data in here. And then same idea, we'll put a couple of students and get that data in there. The whitespace that 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 whitespace. 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 gonna do an array with a couple of dimensions here. And so we'll just call that exam scores. And obviously as I'm going, feel free to interrupt to ask questions. I don't have any issues with that at all. So I'm just gonna 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 gonna 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 gonna 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 it's 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 what was it? 78, 55 and 89. Shane. Yes. Is it okay to have those on the same line? Oh, absolutely. Okay, as long as they're separated by comma. Yeah, absolutely. Great question. Yeah, 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. This is all just to make it a little bit more readable when human beings are coming in. So sometimes, 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, I can't type. Then we'll go ahead and keep moving that forward. And so again, we're gonna 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 wanna type out the rest of that, that's a lot. That'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. Okay, 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'll 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 gonna 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. Okay, 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 multi-dimensional arrays, you can get the length of those individual indexes. Here, I'm just gonna 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 loop for my number of students. Just like we did with the temperature, I'm gonna need to track that total score, right? So that total as I go through. So as I loop through the students, I wanna get that score for each student so that I can get the average. So I'll go ahead and keep that at 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, right? 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 that your 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 27, 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 81, then we can actually compare that. We can say, okay, 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 there, 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 questions on any part of this? Or did anyone maybe do it differently and run it as some issues? Oh, go ahead. I was gonna 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, so you're declaring that data type. And so you'll see, literally tomorrow, we'll talk about this. When you have data that's related, but it's 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 gonna be integers. All the student names are gonna be string. And then, yeah, 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 wanna be sure we don't get any questions don't go on and answer. I think Kelly may have gotten locked out or something. Oh, it still shows connected, but yeah, maybe she got disconnected from the session. Okay, well, we have about four minutes or so left, so we should be okay. So I know a lot of this, for some of you, it was probably a little bit easier than others because you have more exposure to kind of language. Hopefully, either way, you got 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 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 talking about how do I handle related data, it's different data types, and kind of how do I work with that together. And then day three is gonna be a lot about unit testing. And right now it's XML. Do you currently use XML? I think you use mostly JSON, from what I was understanding. Is it mostly JSON data? Yeah. Okay, so this course 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 seeing in your day-to-day stuff. It could also be that, I am not 100% sure how the new framework is gonna look, but it could be that we may switch to using XML on the C Sharp side of things. We think JSON will look better. I'm not sure. Oh, okay, okay. It's funny, the trend has been kind of the other way, right? So kind of ditching XML. I mean, I prefer JSON, but we'll see what we get. Ha ha ha ha. 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. 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 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, if you have any questions, have a fantastic day. And I will see you tomorrow. You too, good night. Thank you. Bye, thanks.
on 2024-03-22
Visit the C# for Automation Test Engineers course recordings page