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
0:02 were variables and assigning values to them.
0:05 For example, we open the Python REPL
0:07 and we said x = 42.
0:09 In this language, in Python
0:11 you have very little ceremony that you have to go through
0:14 to declare variables and set them up and give them values.
0:17 We don't have to say, we're creating an integer called x
0:20 or a string called name or anything like that.
0:23 No, we just say the variable name equals the value.
0:26 But remember, you do have to keep in mind
0:28 that there is an underlying set of different types
0:32 of variables and data, and they can only interact
0:34 usually, when they're the same type.
0:36 For example, we could take a list
0:38 and combine it with another list
0:40 we could take numbers and do math with them
0:42 we could take strings and combine them
0:43 to make larger strings
0:44 but you can't take a number and a string
0:46 and combine it using the standard operators
0:49 or anything like that and have that work out
0:52 but here we said x = 42 and y = 19.
0:55 These are both integers
0:57 and then we did some math with them
0:58 and what we got back is another integer, 175.
1:02 We also wanted to create some text type data.
1:04 In programming, we now know this is called a string.
1:07 So we're going to say name equals Michael
1:09 and if you were to ask what is the type of name
1:11 it would say it's a string, of course.
1:14 If you try to combine them like I indicated before
1:16 you're going to get some kind of error.
1:18 In this case, type error
1:19 can only concatenate strings, not integers.
1:22 Though we saw we also have to use f-strings
1:24 or formatted strings.
1:26 Generally we want to take different types of data
1:29 and combine them into some kind of final text output
1:32 high, curly, name, and that variable name
1:34 gets plopped in there by Python.
1:36 Looks like you just did math, and it has the value of x
1:39 the value of y, and then you can even put the expression.
1:41 Remember, it maybe makes more sense
1:43 to assign like a z variable for the x + 7 * y
1:46 but just to show you can have actual computation
1:49 and expressions and evaluations in there
1:51 we put that statement in there again
1:53 and we get this, Hey, Michael, looks like you did math.
1:55 42 + 7 * 19 = 175.