A step-by-step guide on getting started with Python as a total beginner.

ยท

6 min read

Before we begin, I want to congratulate you on your decision to learn how to code using Python.

I still remember how I wrote my first piece of code 6 years and all the amazing and cool things I've been able to do with it ever since.

Make sure to keep in mind that it is probably best for you to keep your expectations in check.

Don't expect to make AAA games or state of the art machine learning models in a week.

Programming is not something that you can learn in a single week, it takes consistent effort and dedication over time to get good at it.

With all that being said, let's dive straight in.

In order to write Python code, you'll need to install Python on your system.

Linux and macOS users can skip this step because they come pre-installed with Python.

image.png

Click on the .exe file and follow the instructions.

Make sure to Add python to path by checking this option ๐Ÿ‘‡ image.png

Now you need to install a place where you can write your Python code, just like how you write your essays in Word or Google docs.

We'll be installing VS-Code, one of the best code editors out there and it's free!

Fortunately, Microsoft has this wonderful guide that'll help you out.

image.png

In case you are unable to set up Python on your own system then I recommend using repl, a great way to write and run Python code without any hassle.

Here are the topics you should be focusing

  • Printing statements
  • Variables
  • Operators
  • Conditions
  • Functions
  • Loops

Let's take a closer look.

Printing statements

You can 'print' or output in Python using the print() function.

print('Hello World') will give you an output of Hello World

Variables

These store certain values that can change.

For example, You can declare a variable 'x' with a certain value.

x = 9  #Here 9 is assigned to variable x
y = 'Hello World' #'Hello World' is assigned to y

x = 8 #x has been updated to a new value which is 8

Operators

These carry out arithmetic operations in Python

image.png

Conditions

They look like this ๐Ÿ‘‡

a = 33
b = 200
if b > a:
  print("b is greater than a")
else:
  pass

Think of it as telling Python to do something based on conditions: if this is true, do this; else do something different.

Functions

These are basically blocks of code that can be run when you call them. This helps us write code more efficiently.

In Python, you can make functions using the def keyword.

def myFunction():
  print("Hello")
myFunction()

Loops

These essentially run a piece of code over and over again until a certain condition is met.

There are 2 types of loops in Python:

  • While loops
  • For loops

Let's take a look at them.

Here's what While Loops look like.

i = 1
while i < 6: //While i is less than 6
  print(i) // do 
  i += 1 //this

The output is :

1
2
3
4
5

Here's a For loop

fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
  print(x)

The output:

apple
banana
cherry

The for loops can be a bit tricky to understand, let me try to break it down for you.

'fruit' is the above loop is a temporary variable. It gets a value from the list called 'fruits' starting from "apple" then to "banana" and then "cherry".

All that I explained before was to give you a taste of the basics of Python, having strong fundamentals at this stage is very important.

These are some of the resources I would recommend to you for further learning๐Ÿ‘‡

Programmiz Text-based Python Tutorials

Objected Oriented Programming (advanced) : %[youtube.com/watch?v=MikphENIrOo]

This course on Traversy Media's channel is a great next step for taking your python skills to the next level!

Python Documentation: docs.python.org/3

This is probably the most underrated resource for learning python.

Did you find this article valuable?

Support Pratham Prasoon by becoming a sponsor. Any amount is appreciated!