- Hello everyone, my name is Philip Ballo
and I'm your instructor for UCSD extension.
Today we're gonna learn how to install Python with Anaconda,
as well as learn a small portion of Python programming
with a focus on video game mechanics.
However, before we jump into Python programming,
I wanted to talk a little bit about learning programming
with videos.
I want you all to understand that not everyone is perfect,
and instructors often use tricks to appear
that they are coding perfectly.
Jump cuts, like these, are often used to cut out mistakes
in the video, and we hide the audio cuts with music.
Also, I'm reading from a script and my videos will mostly
be voice over video.
Furthermore, instructors like me, have been coding
for a long time so while it may look perfect on video,
it took years to get at this level.
You are just starting so don't worry about making mistakes
and in fact, I encourage it.
Unless you're working with nuclear missiles,
then I'm just gonna say yeah, just make sure you do
it correctly the first time all right?
So put on your coding gloves and let's get coding.
This first part will be a quick installation tutorial.
We will be coding in something called
an integrated development environment, also known as an IDE.
In this video, we will be using the Spyder IDE that comes
with Anaconda but first we have to install it.
First, search for Python Anaconda,
using your favorite web browser.
Please note that you're not looking for a website
about snakes but rather a software website.
Or you can just go to Anaconda.com.
Download the software on their downloads page, install it
and accept all the defaults.
(soft music)
Open Spyder and you're done.
Part 2, creating a new Python project.
All Python files end with a .py extension.
It cannot run if you double click the file
unless you add a bit of code to it.
For now to see the results of your Python program,
we are gonna run Python in the IDE and view the results
on Spyders console log.
Next, name your project and click on create.
You can change the location of your project folder,
if you want, by clicking on the yellow folder icon.
Go to the project pane and right click
on your project folder then navigate to new then file.
Finally, name your file main.py.
Then save your project folder a new tab should have appeared
in the editor tab named main.py.
Congratulations, you made a new project
and created a Python file.
Part 3, the print statement.
Now that we got statements out of the way,
let's do something.
The first thing that you will learn will
be the print function.
This is a very basic way to see the results
of something right away.
In your main.py file, simply type print, left parentheses,
double quotes, hello world, double quotes
and right parentheses.
Click run on the large screen arrow on the toolbar.
A large window should pop up, click run.
You should see something appear on your console log.
Congratulations, you made a simple print statement.
This is a simple example of an output produced
by a computer.
Finally, we are gonna work on the meat
of Python programming, variables.
When you create a variable,
it is called declaring a variable, you store the value
of the variable with an equal sign and a data type value.
In this video, the data types we will learn
to store include string, also known as text, numbers
and booleans, which are also known as true false values.
To store a string, simply create a variable name,
add an equal sign and a value surrounded by double quotes.
To store a number variable, create a variable name,
add an equal sign and a number without any quotes.
Finally, to store a boolean variable,
create a variable name, add an equal sign
and type either true or false
with the first letter capitalized without any quotes.
As you can see from the variable explorer of Spyder,
you can see the different variables, their values
and their data types.
Well, that was a bit boring, so let's apply what we learned
into something you would probably find in video gaming.
Part 5, applying your knowledge.
If you wanna follow along, copy the following code
into your IDE.
Be sure to pause the video to give you enough time to copy.
Be sure to copy everything perfectly.
As you can see from the code I created basic text game.
In the old days, text base games were popular,
but it required a bit of imagination.
This code will only do two things, open a chest
and have an enemy deal damage to the player.
Focus only on the variables as this is just a simple lesson.
Watch how I change the variables and how the results change
within the console.
I highly suggest playing around afterwards
to see how variables work.
(soft music)
Congratulations, you have taken the first steps
into Python programming.
If you wanna learn more, please check out
the Sally Ride Science website as well
as materials provided with this video.
The materials include a full Python book, so you don't have
to pay for a Python textbook.