🥳 GOSKILLS TURNS 10: Get 10 days of free access with code 10YEARS

GoSkills
Help Sign up Share
Back to course

Your First Python Program

Quiz me Quiz Compact player layout Large player layout
Focus video player for keyboard shortcuts
Auto
  • HD
  • 720p
  • 540p
  • 360p
1.00x
  • 0.50x
  • 0.75x
  • 1.00x
  • 1.25x
  • 1.50x
  • 1.75x
  • 2.00x
cc

We hope you enjoyed this lesson.

Get the Python with Excel course for more great video tutorials.

Start free trial

Cool lesson, huh? Share it with your friends

Facebook Twitter LinkedIn WhatsApp Email

  • Lesson resourcesResources
  • Quick referenceReference
  • Transcript
  • Notes

About this lesson

In this lesson, we'll create our first Python program, called hello.py.

Exercise files

Download this lesson’s related exercise files.

Your First Python Program
60.1 KB
Your First Python Program - Solution
55.6 KB

Quick reference

Your First Python Program

In this video we'll create our first Python program, called hello.py

When to use

Do this one time to create your first Python program.

Instructions

In sublime text, create a new file called hello.py (and save it to our C:/python-excel directory).
 

In the text editor, type:

print("Hello World!")

Save the file.

 

In the terminal, make sure you're in the C:/python-excel directory and run the file with this command:

python hello.py

Hints & tips

  • create a file called hello,py
  • print("Hello Word!")
  • to run it: python hello.py
Login to download
  • 00:04 All right, in this video, we're going to create and run our first Python program.
  • 00:08 So I've opened up the Sublime Text Editor.
  • 00:11 To open this thing, just head over to your Windows Start menu and type in Sublime,
  • 00:14 and it'll pop right up.
  • 00:15 And go ahead and click the icon, and this is what you should see.
  • 00:18 So the first thing we want to do is save this file as a Python file.
  • 00:21 So we can head over to File and click Save As.
  • 00:25 And now we just want to navigate to our C drive.
  • 00:28 So I'm going to click This PC, navigate to my C drive.
  • 00:32 And I'm going to find that directory we created in the last video.
  • 00:36 And remember, we called it python-excel, so
  • 00:39 I'm just going to scroll through here till I get the P's.
  • 00:42 And then I see this python-excel, so I can double click it.
  • 00:46 And you can see there's our virt directory.
  • 00:48 And so just right here we can name this anything we want.
  • 00:52 Let's name this hello.py, and then go ahead and click Save.
  • 00:57 And when we do that, we see up here it's saved it as hello.py.
  • 01:01 If we want to navigate back to our Git Bash terminal,
  • 01:04 we can type in the ls command to list the stuff in this directory.
  • 01:08 And we can see, sure enough, here's this hello.py file that we just created.
  • 01:12 And again, there's our virtual environment directory.
  • 01:14 And so that's cool.
  • 01:15 Let me clear the screen.
  • 01:16 All right, so let's head back over to our Sublime Text Editor and
  • 01:19 let's create our first Python program.
  • 01:21 So let's type print and then parentheses in quotation marks.
  • 01:27 And you'll notice when I type one parenthese,
  • 01:30 Sublime automatically puts in the closing parenthese tag.
  • 01:34 So that's kind of cool.
  • 01:35 Same thing with quotation marks, when I type one quotation mark,
  • 01:39 Sublime Text puts in two because you always want to close your tags.
  • 01:43 So inside of here, let's type Hello World, okay?
  • 01:48 So this is a print function.
  • 01:51 It's sort of like a little program that runs inside your program.
  • 01:55 And then inside of the parentheses,
  • 01:57 we can pass any parameters we want into this print function.
  • 02:02 And the parameters we want to pass is this text, these words and
  • 02:06 letters, and specifically Hello World.
  • 02:08 So let's go ahead and save this.
  • 02:10 And when I got the Ctrl and the S key at the same time on my keyboard,
  • 02:13 I think it's Cmd+S if you're on Mac or Linux, and then, or
  • 02:16 you can come up here to File and then just click Save.
  • 02:19 And you'll notice here it says again Ctrl+S, that's just a shortcut.
  • 02:23 So now we've saved this file.
  • 02:25 Now, in order to run this, we need to run this from the terminal.
  • 02:28 And this is the way we're going to run all of our Python programs from here on out.
  • 02:32 So head over to your terminal.
  • 02:33 It's a good idea to keep your terminal just open whenever you're writing
  • 02:36 your code.
  • 02:37 Make sure that you're in your c/python-excel directory.
  • 02:41 Make sure your virtual environment has been turned on.
  • 02:43 If you have since closed this, since we set this up a couple of videos ago,
  • 02:48 you just need to navigate back to that directory.
  • 02:51 And to do that, we use the cd command, change directory, and
  • 02:56 then just type in c/python-excel.
  • 02:59 But like I said, we're already in this directory, and
  • 03:01 we know that because we can see it right there, and so we're good to go.
  • 03:04 So in order to run Python programs, all we have to do is type in python and
  • 03:08 then the name of the file.
  • 03:09 So our file is hello.py.
  • 03:12 So we can run this.
  • 03:14 And when we do, we see it prints out to the screen Hello World.
  • 03:18 So if you see Hello World,
  • 03:19 congratulations, you've created your first Python program.
  • 03:22 Now, granted, this is not a very sophisticated program, but
  • 03:25 it is the first program.
  • 03:26 All coders always write Hello World, it's world famous.
  • 03:29 We've all done it and now you've done it too.
  • 03:31 So congratulations.
  • 03:32 If you're on Mac or Linux and
  • 03:35 this didn't work, try python3 hello.py.
  • 03:40 So that won't work for us because we're on Windows, but Mac or Linux users,
  • 03:44 that may work as well.
  • 03:45 So okay, that's really all there is to running Python programs, very easy.
  • 03:50 Again, you just type in Python and then the name of the file, and that's it.
  • 03:54 So okay, and again, this is a very simple program, but just something to
  • 03:59 get your feet wet and show you how to actually save and run Python programs.
  • 04:04 In the next few videos,
  • 04:06 we're going to spend a little while learning very basic concepts in Python.
  • 04:11 Now, I'm going to assume you don't have any Python experience whatsoever.
  • 04:14 If you do know a little bit of Python, this will be a great refresher.
  • 04:18 If you don't know any Python at all, this will be not too complicated.
  • 04:22 And it shouldn't be too hard to learn these things.
  • 04:24 We're just going to look at very basic concepts to give you an idea of what
  • 04:28 Python is capable of.
  • 04:29 And also to give you the tools in order to write the code that we're going to use
  • 04:33 throughout the rest of the course, connecting our Python with Excel and
  • 04:36 all that good stuff.
  • 04:37 So we'll start to look at those things in the next video.

Lesson notes are only available for subscribers.

Virtual Environment
05m:37s
Python Variables and Print()
06m:01s
Share this lesson and earn rewards

Facebook Twitter LinkedIn WhatsApp Email

Gift this course
Give feedback

How is your GoSkills experience?

I need help

Your feedback has been sent

Thank you

Back to the top

© 2023 GoSkills Ltd. Skills for career advancement