Creating a File
Perfect. So, you created a folder now. Next, I want you to create a file, and I think we name it
hello_terminal.py. So we make a Python file.
terminal.py. Okay, so I used the
touch command to create a file. Again, I don’t get any feedback, but I can always check what’s in my folder by typing
ls to list the contents.
And now, after creating this file using
touch and then the name of the file, here it is:
And with the
touch command, you’re creating an an empty file. You could also create a text file or a Markdown file. And for now, it’s just a blank file that has a
And yeah, to really make it a Python file, let’s put some Python code in it. Maybe a
Sure. Before I do this, I’m going to do a different command to just clear the screen, which is just
clear. And that brings me back up to the top, so it’s a bit easier to see what I’m typing. So, nothing happened here.
01:04 If I scroll, you can still see, like, everything’s still there. It really just moves the screen to the top so that you have more space to type and see what you’re typing. Cool. Perfect. That’s handy. Yeah.
Your task was to add
print("Hello, Terminal!") into this file, right? So my file is still here, and then I will say
then I need to use the right quotes:
'print("Hello Terminal"—And there’s, do you want the comma in there? Sure. Maybe let’s put a comma in there. Let’s be correct. Exclamation mark. Okay.
01:39 I said I have to use the right quotes. That’s just because I want to use double quotes in here in the string for Python. I could also swap this around, so I could use double quotes out here and then single quotes inside. Perfect.
So that’s basically like within Python code as well, that you have to be cautious of your quotation marks. And if I just ran this like that, actually—well, I’m going to take a little detour, sorry, Philipp. No, go for it. This is just going to print it out, you see? Like, if I say
echo, it’s a command.
It’s kind of like the
and then I want to put it inside of a file. For this, I can use this symbol (
>) that’s the greater than symbol, I think. Greater than, yeah.
And then give the filename then where I want to put it. So I say
hello_terminal.py, and then press Enter.
Become a Member to join the conversation.