 This is the first tutorial that we're going to explore Python. In particular, we're going to explore the data types of numbers and texts, some variables, and some lists. So let's get stuck into it. Hey crew, it's The Surfing Scratcher here, teacher-surfer programmer, and on this channel I help curious learners just like you along on your learning journeys. This video is a continuation from our From Scratch to Python series, where we started with the Scratch project and we're converting it now into a Python project. So to kick off, let's explore the data types. So over here in the left hand pane, I've just got our Scratch project editor, and you see I've got our variables and our lists here. If I click on these reporter blocks, you'll see that we get a data type, and this data type is a number. And if I click on say text output, you can see we get a text data type. Now in Python, text is actually called string. So I just want you to get familiar with that language, a string. Numbers are just numbers. There are different types of numbers in Python. There's actually two. There's one that's called an int, and an int is an integer, and integers are just whole numbers, and they can also be negative numbers as well. There's a different type of number, and it's called a float. And a float is just a decimal. So 9.0 is actually a float, like 9.1 is. And these can also be negative numbers. Okay. To test that out, I'm just going to go down here in the Python console here. I'm going to type the function type, and just put two brackets there, or parentheses. And I can put the number 9.0 in there and click enter, and see how it tells me that it's a float. Now if I press up on the keyboard, it'll just bring that back. And if I go in and delete that .0 now, and I click enter, you can see that we've got a class of int. It's just telling us that that particular value is an int. So we've just split what we know about numbers into two kinds of numbers, an int and a float. Now I don't want these lines of code to execute, so I'm just going to comment them out just so you can still see them. The next thing I want to talk about is a string. So a string is just a text value. So surfing, scratcher, let's turn that into a string. And the way that you turn text values into strings in Python, and most other programming languages for that matter, is you put them inside double quotes here. So you can use the double quote, or I'm just going to duplicate that line, and you can also put them inside single quotes here. Now this has turned it into a string, and we can just go back down into our console here, and let's get that type function back. I'm just going to paste in surfing, scratcher, and click enter. And you can see that we get the class str, and str is just the shorthand for a string. So strings are pretty important, and we're using both of these data types throughout our project. Now if you want a string to extend over multiple lines, what you'd need to do is put three quotes there. So you can see I've got three quotes now, and the color of our variables and lists here, you can see that they've turned into the string color. If I click enter and I put in three more quotes, as you can see, we've just got our comments back, and anything that I put inside of here, so anything I put inside becomes a string, and that happens over multiple lines as well. So the key questions and the key takeaways is how can you create a string in Python, and what's the difference between an int and a float number in Python? Okay, so we've covered numbers and strings, but on their own, they're not really that useful. What we need to do is find a way to store them. Remember, storing them is a way for the computer when our program runs to be able to remember what we're doing, and that's what variables and lists do. You know that we've got variables and lists in Scratch, and a quick refresher is that a variable is used to store a data type. So to store a text value, or to store an int value or a float value. And over in Scratch, we've got lists that are basically multi-line variables. Now variables work exactly the same in Python, so I can write the variable colon position, and I can assign it a number. So let's just check what the value of colon position is over here, is equal to six, and you can see here, I've used this equal sign as an assignment. Okay, so whenever I want to make colon position, the name of this variable equal to something, we assign it by a single equal sign. Okay, now if I go and click and run this project, and in the console, I ask what is colon position here? It says it's equal to six. Oh, cool. So what you can go ahead and do is you can assign it different values as well. So let's make it 10, and let's just check the value of it. Cool, it's now equal to 10. Just like in Scratch, how you can assign either text or numbers to a variable, you can do the same thing in Python as well. So let's assign a text value to colon position. Let's make colon position equal to the text colon position, and we'll just check that value now. There we go. Now we get the string colon position. Now I'm not going to go into the full ins and outs of a string. You can jump onto YouTube and check out some other tutorials on that. We're just going to continue to press through to convert our Scratch project into this Python project here, and you'll sort of learn some aspects of strings and numbers along the way. Okay, let's check out the last comment here, and we want to talk about lists. So recall that in Scratch, a list is really just a whole group of variables grouped by an index, a number, a position in that list. So here we've got a list called lines, and in position one in lines, we've got a text value. You can see here we've got a string, you could even say. Okay, and we've got 10 items in our lines list. Now over in Python, we kind of combine the variables in lists. So see how we have assigned the number 6 to colon position? Well, we do something similar for a list in Python. So if we want to create a lines list, we need to type lines, and we need to assign to it a new list. And the way that we can assign a new list is just by using two square brackets. This is now a list. To check that out, let's run the program, and down here we'll get the type function back out, and let's type in the lines, and let's check its type. Its type is now a list. Now there are lots of other types of ways to sequence values in Python that we're not going to get into in this series. We're just going to focus solely on lists here. Now usually when you start up a new program, you're going to use some what's called dummy data. Eventually we want our Python program to read the same text file that we're using here in our Scratch program. And if you're not sure what that is, I'll get that up on the screen just now. You can see here that we've got a text file called lines.text, and we've got all the lines that we want to spell. And remember that common position, that variable, is the value of the position in that line, the common position in that line. So what we're going to do, rather than reading this file straight away, because that's a little bit trickier, we're going to create a list. It's a good opportunity to learn about lists. So what I'm going to do now is open up this file, this text file. I'll just double click it. You can see that we've opened up a text editor here. And I'm actually just going to copy all these lines, and then close down the text editor. Let's jump back over to Replet. And then what I'm going to do is just give ourselves some space here. So I'm going to click Enter once. You can see it's put that angle bracket on the same line of indentation as lines. And we're kind of in one indentation here. My indentation level is set to four. So what I'm going to do now is I'm going to hit Command V, or Control V for Windows, and paste in that list. Whoa, okay, that's looking pretty gnarly. What I'm going to do is select all that text where I've got up to Bath, and I'm going to hit Tap. So now it's all on the same line. But there's going to be a huge problem if we click and run this already. And I wonder if you already know what that problem's going to be. But let's just check it out just so you can see. I'm going to run this project and look with just encountered our first error. In the file main.py at line 18, which is here, saying dash colon, should you try and make a dash for the car? We've got an invalid syntax. Okay, so the console is telling us here that we've got an error here, a syntax error. Do you know what this error is? To give you a hint, we've covered it already in this tutorial of what all these should be. Well, we want all these values to be strings, but they're not yet. We need to do something special to convert them into strings. They need to be wrapped in quotes. So what I'm going to do is select the whole line here. And the cool thing in Replet is if you select the whole line and you press the quote button, it will wrap it in single quotes. But our job isn't done yet. What we need to do is get to the end of the line and we need to put a comma there. And that will just signify that, hey, this is the first item in our list. I can do the same for our second line here. I'm going to highlight it, I'm going to highlight it, press the single quote, and then go to the end and press a comma. To spare you the pain of watching me do that for all of them, I'm just going to go through and do that now. And I want you to do the same if you're following along with me. So I've just gone through and magic that. And the last thing I'm going to do here is I'm going to change the name of our variable and make our lines variable all uppercase here. And the reason I'm doing that is this refers to a constant. And a constant means that I don't intend to change this as a variable. Like it's going to stay the same. Once I've said it, I don't want to change it. Of course, I could still change it, but it's just best practice. If you make things uppercase and you would have seen that in some of my scratch tutorials, if you've been following me through the journey, that is just to signify to other people that, hey, this is just going to remain the way it is. Now if I click and run this project, and I type that variable down here into the console, you can see that it outputs our list here of lines, which is exactly what we're looking for. I'm just going to clear that console and I'm going to introduce you to a neat little function that we can use to call on lists, to check the size of them. This function is called len. And we can call len to figure out the length of the thing that we passed to it. And the thing we're passing to it is lines. I'll click enter. And it says that we have 10 there. We can do the same thing for strings. We can see the length of the string serving scratcher and it outputs the in value of 17. I just want to finish up this tutorial mentioning one big gotcha that is sure to trip you up at some point. And that is the difference between single quotes and double quotes. Let's just say you want to have a string value that is possessive. That could be something like dot's bone because dot is a dog. But we've got a problem here because we've got an apostrophe here with a single quote. So that's going to be a problem because our string value is actually just dot and we've got this S bone that's hanging off the edge here. And that's no good for us. So the way that we can go to get around that is to cut that and insert them inside of the double quotes here. So we can use a single quote as many as we like in a side because we're using double quotes. So more often than not, you'll find me using double quotes just for this. There is another way that we can go about that. If you are hell bent on using the single quotes there, you can use what's called an escape value. So you could use a backward slash and then escape the character that you're wanting to include and then continue on writing that and then finish it up. But that's a little bit trickier and we're not going to get too much into these escaping. But I just wanted to share it with you. The rule of thumb for now is let's just use double quotes for strings. All right, congratulations. You should now have a Python file with some lines and all of the lines of text that we're going to read. In the next tutorial, we're going to unpack this set column position in line. We're going to write out first function with all these variables. Explore some looping as well. There's lots to cover. We're going to hit the ground running and I can't wait to see you in it. So until then, I'm off to find a wave. I'll catch you in the next one.