YTread Logo
YTread Logo

Lecture 1: Introduction to CS and Programming Using Python

Apr 17, 2024
Alright, welcome to the first 6100 L conference, that's our new issue. My name is Anna Bell, they are two separate names. Name Hanah. Surname Belle. Super conf

using

, but I've been lecturing here in the ECS department for probably almost 10 years. Now, and I've been doing the introductory course for a while, I'm very happy to be teaching this full semester version of 6100a, so today what we're going to do is go over a little bit of the administrative information for the course and then we'll dive right into some ideas about high level computers, how they work and then we'll start to dive into some basics of Python, so we'll start coding right away, so I highly encourage you, since you're in this class, to download the slides from the conference beforehand to take notes and run the code when you do.
lecture 1 introduction to cs and programming using python
Some of the

lecture

s are interactive so we will have breaks so there will be a place where you can take a break to actually code and that's important uh I call them utri breaks that's important to make sure that you're actually practicing what you're doing. We are learning right now. um the main idea of ​​the

lecture

s is yes, I will teach something, but there will also be opportunities for questions and for uh, guys, to try some

programming

on the spot, even if you don't end up writing a program that we start talking about. I'll finish it and we can all talk about it together and I'll show you something. traps and things like that, there will be a lot of opportunities to practice in this class at various degrees of granularity and then there are also a lot of opportunities that I have in the handouts to practice more at home and through a lot of different resources as well, the reason I do The emphasis on participation and practice is because part of the reason you are here is because you want to learn how to program, but you don't know how to program yet and

programming

is actually a skill, right? math or reading is something you have to practice, you can't just watch me write a bunch of lines of code and then when it's time to take the quiz you automatically know how to do it, you have to do it. often more and more, until it becomes sort of second nature, so the three most important things you'll get from this class are conceptual knowledge, obviously, we're going to learn some computer science ideas, programming skills, and problem solving. problems, that is, problem-solving skills.
lecture 1 introduction to cs and programming using python

More Interesting Facts About,

lecture 1 introduction to cs and programming using python...

Lectures and exams basically help you with your knowledge or test your knowledge of the concepts and help you gain knowledge of the concepts. The finger exercises give you the programming skills and the problem sets help you with problem solving basically if you are given an English version, you know a problem in English, how do you go from that to thinking about what concepts of computer science I can apply and then how do I take those computer science concepts and actually do the programming? What are some of the topics we will address? We'll be covering, we'll be at the center of this learning computational thinking, so in the future when you encounter a problem, your first thought may be: how do I solve this mathematically or how can I force a correct manual solution to this problem?
lecture 1 introduction to cs and programming using python
I apply computing to help me solve this problem and throughout these lectures you'll see some examples of how we apply computing to a problem that you may have already seen and perhaps solved mathematically, which is great, obviously, to get to that. We're going to learn the Python programming language, once we have the basics down, we'll look at how we can start structuring our code to make it look a little bit better, so that we don't have a bunch of code lying around in a um in a file let's go. to start organizing our code and see how we can make it readable and modular and then towards the uh uh uh not in this lecture but in a couple of lectures and as a theme throughout this uh this class, we're going to look at some algorithms, no They're very complicated, but they're kind of the basic algorithms for a lot of algorithms that you might see in the future if you decide to take more computer science classes, finally, towards the end.
lecture 1 introduction to cs and programming using python
In the class we will look at algorithmic complexity, which basically means that we are going to start asking or trying to answer the question: how do we know that the programs we write are efficient? We can write programs, but how do we know they are efficient? They are fast and how do we know they are not? You know, they take up all the computer memory, so things like that, comparing different algorithms that do the same thing, with each other, so if there are no questions again, like I said. Much of this information is already in the booklet and more, we can get off to a good start, so let's start by talking about knowledge.
Declarative knowledge is a statement of fact and many of us probably in mathematics and in the past have worked with declarative knowledge, but this is not how computer science class works, this is not how this class works, in computer science, what What we do is that we work with imperative knowledge, which is basically a recipe for how to do something and when we program, all we do is write a recipe for the computer to do something, that's all, so here's a numerical example, um, the first statement is declarative, uh, statement, true, uh, the square root of a number If we give it to a computer, it won't know what to do with it.
What we have to do is tell the computer how to find the square root of a number and then tell us what it is. the square root of that number is and then the computer needs a recipe, so the recipe is really simple to find the square root of a number is steps 1, two, 3, so what we do is we say we want to find the root square of 16 obviously we know it's four, but the computer doesn't, so we give it an initial guess, let's say the guess is three, how do we go from there so that the steps we follow are step one if um 3 * 3 9 is close enough to 16 we can stop, it's not close enough for me, so let's move on to step two, otherwise we're going to make a new assumption by averaging G, which is our original assumption three and which is 16 out of 3, correct. 16 was the square root we wanted to find, so our next guess is 4.17.
Okay,

using

the new estimate, we repeat the process until we are close enough to go back to step one, which is the first part of the process. We find that the estimate squared 4.17 square is 17.36% and 16 divide 4.17 correct, that gives us our new assumption 4.35 okay, next step, using the new assumption we repeat the process so 4.35 squar is 16277 0277 is close enough to I could be happy with this. I might stop there because we're within plus or minus one, so I'm fine with that, but if we wanted to be within plus or minus one time 10 the negative like six or seven or something like that, then we would continue the process, so I really would. what we had there is an algorithm right, it's a sequence of steps step one step two step three there's some kind of control flow right, we had a place where we said if this is so, you know if if the guest is close enough then you know that we can stop otherwise We do something else, we had another control flow where we said repeat this correctly, so we don't go linearly, but we change the flow and lastly, there is a way to stop correctly, we don't want the algorithm. to go on forever we would like to stop at some point and the stopping point I was a little vague about it but it could be, you know, when we were within more or less one of the actual answer, so the correct recipes are basically algorithms, right? my grandmother was basically teaching algorithms when she was teaching me how to bake a cake, right, she didn't call it that, but she was actually um and so even the recipes have the same structure, there's a sequence of steps, there's a flow of control like If you don't have an egg, use egg substitute or repeat this, you know, repeating sticking a toothpick in to see if it comes out clean every minute or something and then there's a bad way to stop right when the toothpick comes out. clean, you take it out of the oven and you eat it, so computers are machines that run these algorithms, they're actually dumb, right?
Computers are not very smart, they don't make decisions on their own, they just follow these sequences of steps that we "Computers are good at storing lots of data, right, we can't really do that, but computers can store gigabytes of storage, even terabytes, and computers can perform operations very, very quickly, which is something we can't do well." They're good at those two things, but they're not very smart, they can't make decisions unless they're told to make the decisions, so really the computer just does what you tell it to do and that's one of the big things. ideas I have.
I want you to come out of this lecture with the computer only doing what you tell it to do correctly, the sequences of steps that you tell it to do, that's the only thing that follows, so a quick little story just to make you appreciate it. uh, programming the Python programming language before you start with it is, so before the 1940s we had these things called fixed program computers, like a pocket calculator, it's an example of where each button was an operation that you could know on the small screen. you could use parentheses to put a bunch of different operations together, but there was no way to store all of these operations together to, you know, then enter different inputs for that same sequence of operations, you had to enter them in each entry of those sequences. of operations every time, um after the 1940s, stored programs, computers, computers came into play and they could store instructions to do things like data, and there was a special program called an interpreter that executed these instructions and knew how to follow simple sequences. of steps when the program told it to go to a different location, it did, so basically it was executing these instructions and, um, the instructions it did were arithmetic and logical, so addition, subtraction, things like that, simple tests like checking the equality between two values ​​and data in motion, so taking this value and putting it in a different memory location, I just wanted to give you a very brief overview and this is not very precise, but it gives you an idea of ​​how exactly things happen , um, low level, um, uh. in the computer, so the computer basically has memory where things are stored, it has an arithmetic logic unit that performs operations, it knows how to add things, subtract things, multiply things, compare things and then it has the control unit where this counter is program.
This is where you put a program, so see how it works. This is a program and up here is our memory, so we have a bunch of memory locations 3 4 5 6 3 4 5 7 and in each of these memory locations we have some. the pre-stored values, you know, are preloaded, so when we run this program for the first time, what ends up happening is um. The interpreter sees that the first instruction adds the values ​​at 3456 and 3457, so he goes to these memory locations, here he takes the three and the four. and he sends them to the arithmetic logic unit. The ALU knows how to do addition, so it adds 3 + 4 seven and sends the result here.
We never told you to store that result anywhere, but the next instruction says to store the value you just got. we come back from the ALU at this memory location 34 58, so the next step basically takes that 34 uh, that seven and stores it in memory location 3458. Super tedious, all we did was add 3 + 4, we do that again, uh, we add 7 the values ​​in 7889. and 7890 then it goes to memory, it takes the five and the two sends it to the ALU, the ALU calculates it as seven brings it back and then we store it in location 7891, okay, and then all we've done is two additions. um and then the next instruction says to compare the values ​​in memory locations 3458 and 78 91, so let's compare seven with seven, the ALU again does this comparison and says, well, seven and seven are equivalent, so you already know. true or whatever you want to return um to The Interpreter and then the last instruction here that we have is to print the result of that comparison, so we print true because they were the same again, super high level, but it kind of gives you an appreciation by programming languages ​​these days, right, this is very tedious to write if we were to write programs this way, um Alan Turing long ago showed that you can compute anything with an even more basic set of primitives, not with sums. subtraction, but instead with one tape you would have six Primitives move the tape to the left move the tape to the right read the value on the tape put a value on the tape um delete the value from the tape and there is nooperation and so, since you showed this, what the The result of what actually was, um, is down here.
Anything computable in one language is computable in any other programming language, so if we had something, you know, some program written in Java that basically boils down to something super long, but something that is made up of these. six Primitives, that means that if we have reduced this program to these six Primitives, we can rebuild the same program in a completely different language and that is really powerful, it is a really cool statement, now we are not going to work with those Primitives, we are going to use Python Primitives, which are more convenient and allow us to do many more things in much less time.
I'm going to do a little comparison as we talk about Python Primitives with English, so in English, some of the primitives can be um words or we can even make letters or characters, but you know we can, we can say they're words, um, you know, with characters we can build words with words, we can build sentences with sentences. we can build stories with stories we can build books and things like that in programming um in programming languages ​​Primitives are numbers um sequences of characters uh they operate like addition multiplication division um uh checking for equality checking that something is greater than things like that so once we have these Primitives in a language can start to develop the syntax of the language, so in English having something as noun and noun noun doesn't make any sense, right, cat, dog, child, doesn't make much sense, it's not syntactically valid, but noun, verb, noun is tactically valid, similarly in In programming languages ​​we can have two objects next to each other, so here this is a sequence of characters H and I and this is the number five right next to it of that sequence of characters, but that doesn't make any sense, what does it mean to have? this sequence of characters and that number right next to it has no meaning in Python; instead what we have to do is add an operator between these two objects, so here we add a little star operator between the character sequence High and the number five and in Python the meaning of this is I want to repeat the character sequence High hello five times, so this would basically give me high high high high high so once we have um sentences in correct English and and and uh Expressions that are syntactically valid, we can now talk about the static semantics of the language, so in English saying something like I'm hungry is syntactic.
Ally is correct, but it's not syntactic, uh, static, no sorry, it's not, it doesn't have good static semantics, right? which means, uh, that has no meaning because r is for "you know" or plural similarly in programming languages ​​and this will differ depending on the programming language you use. Here you know, in the previous slide we saw that you can use the star operator between the sequence of characters and the number and that meant repeating that sequence many times, but if we use one more operator between the sequence of characters and a number it has no meaning in Python, then you have a static semantic error even though it's syntactically valid, we have operator, sorry, object, object operator, so far we've been able to find really nice parallels with English, right, the English language and the English language. programming, but this is where things break. down when we talk about the semantics of a language, then in English you can have many different meanings, right, the chicken is ready to eat means, let's eat this chicken, um or the chicken is ready to eat, it means that the chicken wants to eat something, true, programming languages ​​there. there are no multiple meanings for a program that you write because the professional because the computer the machine the language follows the set of instructions to the letter there is no ambiguity about what you need to do right, you just follow the instructions and do what you need to do until the end until it comes to, you know, the show ends, so shows only have one meaning, but the problem is that it may not be the meaning that you intended it to have and that's when things start to go wrong. syntactic errors in our program spelling errors and indentation errors things like that and those are easy to detect.
Static semantic errors are probably 90% easy to spot, but the problem comes with correct semantics, the meaning you intended this program to have may not be it. what it's actually doing and that's where most of my mistakes happen and that's where I get super frustrated when I program and that's probably where you guys will get super frustrated too because you write a program that you think is doing one thing but instead That's what fails. immediately or it runs forever and doesn't really stop or terminate but gives you the wrong answer, it's not what you expected and we'll talk about this in a few lectures so when writing programs, we're basically writing sequences of definitions and commands. and we will write them in a file editor or in a shell.
The first one today at least we're going to write to the shell directly and half of tomorrow we're going to write to the Shell um because we're not really writing anything uh we're not really writing many lines of code um we're just going to be I'm just going to show you some really quick stuff. um uh quick ones that we can see with the Python programming language, so I hope everyone has installed the programming environment. This is the code editor, so tomorrow we will start working here, but for today we are just going to work on the shell and even in the future. um, you can still type commands in the shell.
I find the Shell very useful if there's something really quick that I want to check that I don't want to write, you know, writing a program and then running it, it's like a simple command. that I want to check to make sure it's doing what I think it's doing before I insert it into my code editor, so here we have this right, so mine is, I guess I'm using the White theme just because I find it easier for guys, see, this is the file editor, and this is just a bunch of expressions, yeah, a bunch of code that we're going to write today and we're going to write it in the shell today, so it's all on the right side okay, so what exactly do we do when we write a program on its basis?
We are going to create objects within our programs and we are going to manipulate them. That's it, that's what programming is mainly about. its core now when we create objects is important, this is something that we're going to come back to again and again in a kind of more high level setup, but now what I want you to understand is that when we create an object, the object has a type, okay and the type that an object has tells Python the things you can do with that object, so here are two examples: the number 30 is a number, the type, we'll talk about that in a moment. the type is an integer it is an integer but basically what are the things that we can do with this integer with this number we can add it to another number we can subtract it from another number we can take it to another power we can take some other number to this power of 30 on the right, a lot of math as you'd expect, so it's pretty straightforward, what's up with this one here, this quote?
It is called a string and it is a sequence of characters, the quotes tell Python that it is a sequence of characters and the characters that are part of it are uppercase, lowercase and lowercase. The type of things I can do with this string are not the same. I'm allowed to do well with a number if I tried to take Anna and divide it by the sequence of characters. Bob, uh, Python would complain a lot, because you can't split a string by another string, not a sequence of characters. There's no point breaking it up by another sequence of characters in a similar way.
I can't bring Anna to any power. I can't multiply uh or I can't multiply by itself things like that, but the kind of things I'm allowed to do. in a sequence of characters is different from the kind of things I can do in a number, so the things I can do with a sequence of characters is that I can tell well what is the character in the first position what is the character in the middle how much How long does it last is the correct character sequence, how many characters do I have? Now you can see that the type of object is really important.
Python uses it to know the types of operations you can do with it, so there are actually scalar objects and these are Python's primitives, numbers and truth values, and there are non-scalar objects that we're not talking about yet. , we will talk about them in some lectures, but they have some kind of structure, so, for example. a list of numbers has a structure because there is a number at the beginning of the list, there is a number at the end of the list, things like that, but a number itself does not have a structure, it is just the number, so what are the types of scalar objects what are the types of The Primitives in Python integers then the number five Z negative 100 a million float is another type represents all real numbers so three you know 3.27 2.0 is a float because it has a decimal number although for us that just means two, but for Python, if you put 2.0, it says it's a negative float type 3.14159 things like that torus is boolean, it represents truth values ​​and there are only two possible values ​​that a boolean type has, true and false, and it has let it be capital T true and capital T oh sorry capital F false and the last one is this type uh nun uh uh type is literally called type nun and it only has one special value none, we're not going to talk about it for a moment, but we will do it at some point in the future, so to find out the type of an object when you create that object, you use the type command so we can say something like type parentheses and this is a command and inside the parentheses you say what you want . to find the type of then if we do type seven it tells me that it is an INT um and if you want to do the same command again I press the up arrow and it automatically puts what I wrote before and then if I want to do type of 0.0 it is a float because there is a decimal point so this is basically what I said so we type this into the shell and the shell tells us what the output is so just to reiterate int float bu and nontype are types. of objects and there can be many different objects that you can create of that type, so if you think about it, inside and float, we basically have an infinite number of objects that we can create of those types, because we can have zero 1 two three 100 200 300 a million right there and all the negative ones there are almost you know an infinite number of values, uh, objects that we can create of internal type float, but there are only two, the true values, true or false, and those that are not of type , there's only one, none right, so that's the type and these are the possible values ​​possible objects that we can create, try it so you can just shout out the answers uh, there's nothing to write unless you want to check it yourself, so , what is the type of 1234 int type of 8.99 float type of 9.0? true bu type and perfect false bu type if you ever wonder what the type of something is, write it here.
They're just doing it right. The guy is Bull. The lowercase T type is true. It's a mistake. I just wanted to point it out to reiterate the fact that capitalization is important in Python, this is our first mistake, by the way, guys, very exciting. The error is a name error and these are the messages associated with it. You also know that it's something special in Python when it's color coded. things for you to see T uppercase true F uppercase false are uh, this dark blue here, whereas anything that's not special in Python is just black, so the type is a special command, this is a float, so you see that They're color coded, okay?
So once we create objects, one thing we can do with these objects is cast them to a different type. Now this is a little bit, maybe confusing because we're not actually changing the object once we've created it, so once we create it. the integer three is in memory, if we convert that integer to a float version, we are creating a new object in memory, we don't change the three, the three already exist, we just get the float version and store it. as a new object in memory, so when we float three, this is a command that gets for me the float version of the integer three, okay, that will give me 3.0, so for example, right, this is what had float three at the start. it's 3.0 if I do int of 5.2 it truncates it and gives me the integer portion of this float if I do int of 5.9 it still truncates it and gives me the integer version of this float it doesn't round up well I'm just asking for the integer version of this of this float some operations like round is an operation that we can do um it has an implicit conversion so if I round 5.9 I'll actually round it to 6.0 and then convert it to an integer so Notice that it doesn't give me the result, put 6.0 and then it round up to just six.
Well, that's basically what I said in the example, so let's try this. WhichGive it a name that has nothing to do with the program you are in. I write um because you're going to want to read these shows again at some point in the future or others may want to read your shows at some point in the future, so here's an example of a good show. It's basically four assignment statements that do some calculations the first. The program line is not really a line, it is called a comment. You can have as many of these as you want.
They start with a hat hash. It's a line that starts with a hash and is basically text that you type that helps you. or others figure out what the code is supposed to do and we usually comment out large chunks of code at a time, not line by line, so we have these four equal assignment statements, so here I am defining the variable called Pi bound to the value here, so it's not the division, but 3.14159 variable called radius bound to this float 2.2 and then I have a variable called area which is bound to the result of this expression.
Okay, so when Python sees my pi and my radio, it grabs them from memory and replaces them. them with the values ​​evaluates the expression takes that value that we evaluate to 15 points, whatever it is, and joins the 15 points to the name area, same with the circumference code style, it's something we'll actually look at in your problem. sets, so I just wanted to quickly talk about that. Here's a show that has really bad style. Actually, that shouldn't be me, it should be, you know, terrible or something, but in case you haven't noticed, it's the same program as on the previous slide, but if I gave you this program from the beginning it would probably you wouldn't know what he's doing, he's reusing 355 over 1 13 twice here, he's using only A and C as variable names, his description is doing calculations, it's pretty bad.
It's a little better. I've recognized that 355 over 113 is used twice, so I'm saving it as a variable, but my variables are still single characters and my comments are pretty bad. I'm basically telling you what the code does. please don't do that um we can see that a is equal to P*R*R right I see that I am multiplying p by r 2 I don't need to read that in English right what I would like to see is a comment like that here I am commenting to you I know a code snippet and someone who doesn't want to read this code snippet just reads the comment and I already know that I'm calculating the area in circumference using an approximation for pi, that's a pretty good comment and good descriptive. names and all that so that once we create an object we can create a variable, sorry once we create an object and bind it to a variable we can change the bindings so we can take the name of that variable and bind it at a completely different value, this might not be the case.
It's going to be somewhat useful right now, but it's going to be useful when we introduce control flow into our programs, so to rebind a variable, that means we're going to take the name, we're going to lose the binding to the previous value, and we're going to go back. to bind it to a new value, so I'll show you what this looks like in memory. I'm going to use this kind of cloud image to represent what happens behind the scenes every time we write programs and it's like a little animation to help you understand line by line what's going on, so here we have pi equals 3.14 , so the green 3 14 is my value in the memory cloud, that's the memory, that's my value in the memory and it's tied to this name Pi, so this is the name of my variable, the radius of the next line is equal to 2.2, same as I have 2.2 as my value in memory, my object and radius is the name of that object.
The area is equal to Pi * radius squ, so what happens behind the scenes? Calculate this value. true, it doesn't store the expression, it stores the value resulting from the calculation and then saves it, or binds it to the name area, okay, everything is fine, so far we have seen this code before, great, now what happens when we do this? radius is equal to radius plus one in mathematics, that would say that 0 is equal to 1, but here we are not in mathematics, we are in computer science and this is perfectly valid, we are following the rule just when we have a task that says look at the side right first and we evaluate it and then we link it to the left side, so if we look at the right side first to the right, we see the radius.
What is the value? 2.2, we see that we added one 3.2. We keep that in memory and then we see. the assignment now save it with the name radius okay so we can only have one variable assigned to a value at a time right this isn't math this is computer science so you can only have the radius point to one thing At the same time with this line of the code radius is equal to radius + one, we have lost the link to 2.2 this object in memory and we have recovered it to the value 3.2, okay, and that is perfectly fine. 2.2 is now in memory, we can't go back to it unless we say maybe the radius is equal to 2.2, it just gets stored in memory and then you might collect it or retrieve it using garbage collection or something like that , but for now we can't go back to that, what is the value of the area at the end of these?
The lines well, according to this, they are 15.1 1976, so it's using the old value of 2.2 for the radius and that's fine because the program never said, uh, it never had a line that said recal calculate the area after change the radius. Just follow silly line by line. Don't know. Hey, if I change the radius, the user might want the area to be changed. It doesn't make those connections, it just follows the instructions and that's fine, if we wanted to change the area, we would have to copy this line and paste it. after we've changed the radius and then the area will change as well, does that make sense?
It's an important part of this lecture. Okay, great, the big idea here is that our lines are evaluated one after the other, we won't skip. We're not repeating things, that's something we'll learn later, but for now, line by line, here's a little UT Tri it . These three lines are executed in order. What are the values ​​of the variables U meters and feet on each line? So how about in the first line what is the value for meters after running the first line 100? What about the feet? So at the end of the first line there is no value for the feet yet.
How about after the second line 3 28.8? about the value of 100 meters yet and what happens after the third line. I'm changing the meters to 200 exactly yes, the meters are 200 but the feet are still 328 dot 08 and this is something I want to show you today and we're going to use this Python tutor a lot more in the future. The Python Tutor is a nice website that allows you to walk through your code step by step so that on every line you run you can see the values ​​of all the variables in the code - a very useful debugging tool.
I hope you'll try it today and on Monday maybe for finger exercises if you're having trouble and you know you can use it for testing to help you debug, but we Can I show you it's pretty simple? Here because it's just a step by step, so we move forward, so the red says the line that I'm going to execute. The green is the line I just ran, so I just ran 100 meters, so here. I have my meters variable with the value 100 step below so I simply ran the feed equals this so now I have a variable called feat with a value of 3 28.8 meters still 100 and then the meters 200 feet were left 32808 okay, so obviously this is pretty simple. program to run the Python tutor, but you can imagine using it um in uh um in more complex setups, how about one more?
This is my last example. I want you to try to write a program that swaps the values ​​of X and Y originally. and I'll draw this memory diagram real quick, so we have this is our memory, we have is associated with two and AND is associated with one, but I only use commands like this correctly, so the code here is buggy, which means it's wrong, it's got a bug because well, let's move forward a little bit. little by little yals x what do I do when uh Y is equal to X here yes exactly Y is going to move from two to one now what happens when I do x is equal to y yes , right and now everything is messed up because I can't get it back, so if you didn't understand this, you can click on Python Tutor and just follow step by step on your own, but how can we fix this problem? a third variable yeah that's a great idea yeah we can create a third variable so that X is one and y is one uh Y is two so we can create a third variable what do you want the variable to be equal to X or Y and, yes, either? um I did it and so let's do it um so here I have a temporary variable called temp and I made it equal to two and now what can I do?
Which one can I reassign now? x is equal to y or Y is equal to I will join one and now what do I do? Yeah, now I can safely reassign X to Temp so I can say that x is equal to Temp because temp points to two and I want we can write the code so no let's see we didn't write it here but you know it on your own or you can write it here if you want or we can do it together so X. equals oops x = 1 Y = 2 right um and then we can have the temperature that we wanted to assign to whatever and it was correct, so we say that the temperature is equal to Y and if you want to check the values ​​of the variables, you can just call the names correctly so that X is 1 Y is 2 and the temperature should be whatever Y be 2 okay so far so now I'm at the step here I think that's right I just created this and then the last thing I need What I do is lose the link of X at any temperature that is correct, so I want to do this operation here, which means I want to assign X to be equal to Temp now, so now X is 2 Y is one, what did I do?
Yes, let's make this happen. sometimes we can start over okay, so y equals temp or sorry, sorry, temp equals y y equals x y is one X is one and then x is equal to temp Y is 1 X is 2 okay, so it's okay if things go wrong, they will go wrong. We can start over in this particular case by redefining our variables and trying everything again, so that's what the shell is for, that's what I use it for and that's what we'll use it for in the future, um. just to do quick things like this, you know, and also things like checking types and other commands that we've done before, okay, any questions before we do the summary, was this the right pace or was it too fast or okay? ?
Okay, a thumbs up is good, so let's do a quick recap. We saw that we can create programs by manipulating objects. We created objects in Python and saw that objects have a particular type. The type that the object has tells Python the things we can do with that object right object um, we can combine objects into expressions and these expressions are evaluated or reduced to a particular value, objects or values ​​can be stored in variables and These variables allow us to access these values ​​with nicer names later in our program. and then we can also write clearer, more readable programs, so the equal sign.
I showed them a couple of differences between mathematics and computer science. The equal sign was a notable difference. The equal sign in mathematics. it's declarative and the equal sign in computing is a task, you're basically saying this is associated with this right and we're not doing any kind of equality in computing um and yeah, computers do what you tell them to do, that's kind of big thing, the most important thing here, line by line, it runs starting from the top, it goes line by line so far we haven't seen anywhere where the computer makes a decision, but in the next lecture we will see how we can insert decision points. in our programs, um, for the computer, you know, it runs a set of code or another set of code, okay, so that's the end of today's lecture.
Thank you all for joining. I'll see you on Monday.

If you have any copyright issue, please Contact