Python Playbook — 1 : Getting Started

Jainvidip
4 min readJan 18, 2024

--

Welcome to Python Playbook — the ultimate guide for anyone eager to dive into the world of Python programming. Whether you’re a complete beginner or someone brushing up on your skills, this blog series is your ticket to mastering Python in a way that’s practical and, dare I say, fun! We’ll start from the basics, tackle advanced concepts, and together, we’ll make Python an exciting tool in your coding toolbox. Let’s get coding!

I know that you are very excited to start coding but before you start coding there are a few basic terms that you must be familiar with. First and foremost you should know what it is that you are learning.

What is Python?

Python is a programming language, which is a set of rules that allows a computer to perform specific tasks. Throughout this blog series you will learn about python and how you can use it to perform simple and complex tasks.

Next thing you need to know is what is a syntax.

Syntax

Syntax are a set of rules that dictate how programs are written in a specific programming language.

Syntax of a for loop in python

Don't be scared by looking at the image above. This is just an example of a syntax. We will get to loops later in the series.

Now one word that you will read multiple times throughout this series is variable. So you should know what exactly a variable is.

Variable

A variable is a named storage location in the computer’s memory that can hold data, and its value can change during the program’s execution.

# Examples of variables
a = 10
b = 12.4
c = 'Chocolate'

In the above code block you can see examples of variables where a variable (here a) stores a value of 10 and hence acts as a named storage location.

As much as you would love naming the variables whatever you like you unfortunately cannot :( . There are certain naming rules that you need to follow to name your variables.

Python Naming Rules

  • Variable names can consist of letters (a-z, A-Z), numbers (0–9), and underscores (_).
  • Names cannot start with a number.
  • You cannot use Python reserved words (keywords) as variable names (More on this later)
  • Variable names cannot contain spaces
  • Avoid using special characters like !, @, #, $, %, etc., in variable names
  • Avoid using names that conflict with built-in functions or common libraries
  • While being descriptive is good, excessively long variable names can make the code harder to read
# Examples of valid variables
age = 25
total_amount = 100.50
user_name = "John"
# Examples of invalid variables
3students = 5 # Cannot start with a number
my-variable = 7 # Cannot contain a hyphen
class = "Python" # Cannot use a reserved keyword

One word that came up above which you might be unaware of is keywords, so let’s cover that too.

Keywords

Keywords in Python are special words that have predefined meanings in the Python programming language. These words are reserved for specific purposes, and you cannot use them as names for your variables, functions, or other elements in your code.

Some examples include if, else, while, for, def, class, True, False, and None.

Now let me introduce you to a programmer's best friend

Comments

Comments are explanatory notes within the code for human readers which are ignored by the compiler. In Python, comments start with the # symbol.

Comments can help a programmer understand what is happening inside the code. This increases the readability of the code.

# This is a comment
''' This is a
multi-line comment '''

It is said that a good code is one that has same number of lines of comments as lines of code.

''' Since we just learned about comments I thought this is a good way to end
this blog. Today we covered a lot of basic topics and now you are aware of
some of the basic terminology related to python. I hope you are liking the
series so far and will continue to read and practise along as the series
progress further. '''

--

--