Python for Absolute Beginners Transcripts
Chapter: Course conclusion
Lecture: Review: Variables and types

Login or purchase this course to watch this video and the rest of the course contents.
0:00 One of the first ideas that we explored were variables and assigning values to them. For example, we open the Python REPL and we said x = 42.
0:10 In this language, in Python you have very little ceremony that you have to go through to declare variables and set them up and give them values.
0:18 We don't have to say, we're creating an integer called x or a string called name or anything like that.
0:24 No, we just say the variable name equals the value. But remember, you do have to keep in mind that there is an underlying set of different types
0:33 of variables and data, and they can only interact usually, when they're the same type. For example, we could take a list
0:39 and combine it with another list we could take numbers and do math with them we could take strings and combine them to make larger strings
0:45 but you can't take a number and a string and combine it using the standard operators or anything like that and have that work out
0:53 but here we said x = 42 and y = 19. These are both integers and then we did some math with them and what we got back is another integer, 175.
1:03 We also wanted to create some text type data. In programming, we now know this is called a string. So we're going to say name equals Michael
1:10 and if you were to ask what is the type of name it would say it's a string, of course. If you try to combine them like I indicated before
1:17 you're going to get some kind of error. In this case, type error can only concatenate strings, not integers.
1:23 Though we saw we also have to use f-strings or formatted strings. Generally we want to take different types of data
1:30 and combine them into some kind of final text output high, curly, name, and that variable name gets plopped in there by Python.
1:37 Looks like you just did math, and it has the value of x the value of y, and then you can even put the expression. Remember, it maybe makes more sense
1:44 to assign like a z variable for the x + 7 * y but just to show you can have actual computation and expressions and evaluations in there
1:52 we put that statement in there again and we get this, Hey, Michael, looks like you did math. 42 + 7 * 19 = 175.

Talk Python's Mastodon Michael Kennedy's Mastodon