Thursday, April 18, 2019

Python tutorial part 1 - Setting up

In this article, we will be setting up a Python workspace and learning to make a simple program.

To start you need to download python, I recommend you go here as it is the official python website.

After you’ve installed Python, go here to download PyCharm which is what I will be using during these tutorials.

Once PyCharm is installed launch the program and set up a workspace to your liking. Once that is done Create a new project.

Hacking A Rise Screenshot-52

Then choose a name for the project, for this tutorial, I named mine HelloWorld.

Hacking A Rise Screenshot-51

Once you’ve named the project click “Create” this will the new project.

Making a python file

Hacking A Rise Screenshot-53

In the sidebar navigate down to the scripts folder, right-click any file

click New and then Python File. It will ask you to input a name for the file, once you have done so click “OK”

Congratulations you made a Python File, now onto the fun stuff.

Let’s get started

First I usually started with my imports, this includes os, sys, and time.

import os

Import sys

import time

These allow for more functionality in the file.

The Print() function prints anything in quotes in the parentheses to the terminal, this is what we will be learning.

Hacking A Rise Screenshot-56

This is what your file should look like, you have to have quotation marks in the parenthesis or else you will get an error when you run it.

To run the file click Alt+Shift+F10Hacking A Rise Screenshot-58

Then click the file with the name you gave.

It will output to the console saying “Hello World”. Now you may want a delay before it runs the code, this is where the Time import comes in.

The time.sleep() command allows you to pause the code for a set amount of time, If you put a 3 in the parentheses then the code will pause for 3 seconds.

time.sleep(3)

Hacking A Rise Screenshot-60

Now when you run the file it should now take 3 seconds before it says “Hello World”.

This concludes the tutorial for python, I will be making a new tutorial every day, the next tutorial will be about if statements and Strings.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.