Go to python.org and grab Python setup file for your system.
For security reasons, always use official sites to download important setup files. Do not use anonymous FTP servers and torrents. You must be security aware.
While installing Python, make sure that you check PIP and PATH options.
PIP will be used to grab additional modules from Internet with one-line commands, and "having Python in PATH" means that you can run Pythons scripts in terminal/cmd from all parts of system, which will save you a lot of time if you like to work in terminal.
When we are done with installation, we have two options. To use Python shell for short instructions, but better option is to use graphical IDLE - Integrated Development and Learning Environment.
My advice is to use IDLE all the time.
In IDLE, open new file and save it using file name, for example, "playground.py". Just make sure that file extension is ".py"
That is important because you will immediately activate syntax highlighting for python source code, and also, IDLE will pay attention to how you are indenting lines of code, because indentation is important in Python.
Ok, now type this source code in that file you created, and run it with F5. This is line you need to type:
print("Something")
And this is result. Well done.
Something
>>>
Results are in Python Shell, that's why you see arrows. Sure, you can run print("Something")
in Shell, and the thing will work, too. But Shell is not practical for big scripts.
We can print more lines, one after another. Make sure that words inside parentheses are enclosed in quotes.
print("Something")
print("Some string more")
print("3.14")
print("23423423423423")
Let's do something fun. What you see is "for loop" that will print specific number, one after another, in specific range:
for x in range(5):
print(x)
Result:
0
1
2
3
4
>>>
Yes, you see 4 as last number, but we are starting from 0, so in total you have 5 numbers printed.
We will talk more about for loops. Don't worry about that for now.
Let's go to next tutorial.
No comments:
Post a Comment