A Quick Tour to Python

Prashant Shekhar
5 min readFeb 24, 2021

Hey !! Welcome to a very short and quick tour to Python. As I am keeping it really short to make it a read of not more than 10–15 minutes, so I will be jumping directly into the concepts and the topics Python has.

Why Python?

  • Very simple to learn.
  • It has the best packages for Artificial Intelligence like Pandas, Numpy, Matplotlib, Scikit-Learn, TensorFlow etc. Hey! ignore these packages for now.
  • Easy to do Complex task.
  • Very clean syntax and code.

Keywords In Python :

In very simple words, Keywords in Python are the reserved words for python.

  • So there are total 35 keywords in python 3.8.5.
  • They can not be used as variable name, function name and any other identifiers. They are case sensitive.
  • What are Identifiers?
    Identifiers are the names given to the entities like class, functions, variables etc. Naming of the Identifiers can never begin with digits.

Indentation in Python

In Python we don’t have that curly braces which we use in C,C++ or Java. Here we use indentation which is 4 spaces.

Data Types

Everything in Python has a datatype. Everything in python is an object. Datatype are classes and variables are instance(object) of these classes.

isinstance() function can be used to verify the datatype of any variable.

Strings in Python

  • Simply string is a sequence of Unicode characters.
  • We can use single quotes (‘ Any String ’) or double quotes (“ Any String”) to represent strings.
  • Multiple line strings can be denoted using triple quotes .

Python List

  • List are the super flexible datatype in Python.
  • They are mutable, means they can be edited or appended.
  • All elements in the list are not needed to be of same datatype.
  • Lists are defined in square brackets [].

Python Tuple

  • The only difference between tuple and list is that tuples are immutable and lists are mutable.
  • Tuples are defined in circular brackets ( ).

Python Set

  • Sets are the unordered collection of unique items.
  • Sets are defined in curly braces { }.

Python Output

The are different approaches to print the output in Python.

Python Input

In python we have input function to take input from the user.

Operators in Python

Control Flow if…else Statement

  • If else statement is used for decision making.
  • Anything indent inside the if, else or elif will only be considered if the condition we have passed is True.
  • Any thing other than “0, None and False” are taken as True.

While Loop

The loop will be operated as long as the condition we have passed is true.

Also we can add else after a while loop. If the condition inside while fails it will be executed.

For Loop

Like other programming languages for loop works exactly same in python also.

We take a variable which iterates over the given range. Lets understand with the example.

i is being iterated from 0 to 9 and got printed every time. i is being initialised with 0 then checked if it is less than 10 or not? then 0 got printed and then i got incremented by 1, then got checked if it is less than 10 or not? then it is printed again. And the same process will run unless the condition is false.

For loop in List :

Instead of using range we just use the name of the list and python will iterate through the complete list.

In Basic Python we have two more keywords which we should discuss under the loop section.

Break and Continue

Let us see one example to understand the concept of using break.

After using break we have jumped out of the loop immediately.

Using continue inside the loop will skip all the step written below ‘continue’ and proceed towards incrementing the iterator and then loop continues.

Wow! Congratulations you have just gone through the basics of Python. Now you can grow your more knowledge by solving problems, learning about Data Structures in Python. You can proceed towards learning Web Development Frameworks, Machine Learning etc.

Happy learning! Keep growing.
And
Support each other to grow!

Thanks for Reading :)

--

--

Prashant Shekhar

Data Scientist | Big Data Consultant | Business Automation