Get Started with Python in under 10 minutes

A Beginners Guide to Programming in Python

Part I: Setting up the coding environment

You can write Python code on your terminal, VSCode or even on a dedicated IDE like PyCharm. But since you’re a beginner we don’t want to you waste time setting one up. You can do it later. For now, you can look to the cloud for an easy and instant IDE setup.

  1. Choose Python (not Python 2.7).
  2. Name your Repl.
  3. Create Repl.
Follow the GIF if you have any confusions.

Part II: Let’s Write Some Code!

Before you start coding, in any programming language it’s a tradition to get started by writing code to print “Hello World!” So let’s not break tradition and do just that!

1. Let’s print stuff using Python :

The middle section of the repl is where you write your code. The right side is called a console. Think of it as the middle man between you and python. The console is where you’ll do your input/output to your python program.

print('Hello World!')
print("Hello World!")

2. Comments in Python

Comments are used to explain what your line of code does. You can write a comment using the ‘#’ symbol. The ‘#’ tells python to ignore the line and not to execute it. You can even add # symbol before existing lines of code to make it a comment. You can also have multi-line comments by starting and ending it with‘’’. Refer the example below for clarity.

3. Variables in Python

Think of variables like a box, where you store stuff. You can store numbers, characters, sentences and so much more. For now let’s work with numbers, characters, and sentences(strings).

Let’s assign a number to a variable.

Equal to symbol ‘=’ is an assignment operator and is used to assign values to variables.

myVariable = 13
myVariable2 = 12.6969
# To view this in the console pass the above statement inside the print function like this :print(type(myVariable))

Let’s assign a character/string to a variable.

To assign a character to a variable, you must enclose the value of the variable in ‘ ’ (single quotes) or “ “ (double quotes).

char1 = 'a'
string1 = "Musk Cult"

4. Arithmetic Operations in Python

Remember we created number valued variables above? You can perform mathematical operations on them. Let’s see the implementation of some of the basic arithmetic operations in math.

myVariable1 = 6
myVariable2 = 3

Addition + :

myVariable + myVariable2# To see the result on the console :
print(myVariable + myVariable2)

Subtraction - :

print(myVariable - myVariable2)

Multiplication * :

print(myVariable * myVariable2)

Division / :

print(myVariable / myVariable2)

5. Printing variables

Previously we printed the result of the arithmetic operations directly using the print statement. But there’s a better way to do this; store the result in another variable.

result = myVariable + myVariable2
print("The result of addition is :",result)
print("%s is the value of myVar!" % myVar)
print("The result of addition of %s and %s is : %s" % (myVar,myVar2,result))

6. Getting input from the user.

Previously we assigned values to variables ourselves. Instead, we can get the value of the variable from the user. Here’s how :

myVar = input("Enter the First Number : ")
myVar2 = input("Enter the Second Number : ")
myVar = int(input("Enter the First Number : "))
myVar2 = int(input("Enter the Second Number : "))

And that’s pretty much it for the basics. Stay tuned for more tutorials! If you enjoyed the article, make sure you follow the publication for future posts.

Peace Out ✌️

I write about Tech. Algorithms. Programming. And that kinda thing you know?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store