Summery: Python Tutorial for Beginners. Hope You Enjoy…

What is Python?

Python is one of the easiest programming language that you can learn as a beginner. It is a high-level, general-purpose programming language. Python language was created by Guido van Rossum and released in 1991.

First of all let’s understand the basics…

Basic Arithmetic Operations

Addition of two or more numbers can be easily done by placing the “+” sign in between the numbers.

Addition in Python

We can divide a number by another number by placing the “/” sign in between the numbers.

Division in Python

Also Read: Coding an Information Gathering Tool with Python

Instead of “/” sign if we place “%” sign in between two numbers we can get the remainder of those two numbers.

Getting a remainder in python

If we add two “/” signs (“//”) in between two numbers it will round of the resulting value to the nearest whole number.

Rounding of a number to nearest whole number in python

If you want to calculate the power values of a number you can do it by adding two “*” (“**”) in between the two numbers.

Calculating the power values of a number in python

Hello World

Not like other programming languages, printing a statement in python is very straight forward. You can use the print function to print a message onto the screen.

Hello World In Python

Comments

Python comments are the lines of text included inside a python script. These lines will not be interpreted by Python. Normally we use comments to describe the functionality of the code we wrote. You can add a single line comment by adding a “#” sign in front of your desire comment. (#This is a comment) If you can to add multiple lines of comments you can use triple quotes. (“””This is a comment”””)

Python Comments

Lists

A list is a container which we used to store multiple data. In python lists are written using square brackets “[]”. Data inside a list is ordered and changeable. Also we can have duplicate items inside a list.

players = [71, 72, 73, 74]
print(players)
Python Lists

We can access the items inside the list by referring to the index number. First item inside the list is indexed as 0 second item inside the list is indexed as 1 and so on…

Accessing items in a list in python

We can also assign new values to the items inside the list.

We can also add new items into the list.

But the above method is not permanent. If we once again check players list it results the old list.

To make this permanent we can use .append() method.

Sets

Set is also another python collection data type. Set’s can’t have duplicates. If there are any duplicates only one is printed. These are unordered and unindexed. In python sets are written using curly brackets. “{}”.

names =  {'tutorials', 'overflow', 'python', 'tutorials'}
print(names)
Python Sets

You can not access access items inside a set by referring to it’s index number because sets are unordered the items has no index. But you can can loop through set by using the “for” loop.

Dictionaries

Dictionary is also a python collection data type. These are unordered, changeable and indexed. In python dictionaries are written using curly brackets. “{}”. Dictionaries have keys and values.

classmates = {'Tony':'Boy', 'Emma':'Girl', 'Lucy':'Girl'}
print(classmates)
print(classmates['Emma'])
Python Dictionaries

We can also loop through dictionaries to print out the key and value pairs.

See you from the part 02 of this tutorial.

Also Read: Python Tutorial for Beginners (Part 02)


Leave a Reply

Your email address will not be published. Required fields are marked *