Python Basic

Python is a powerful, high-level and general-purpose programming language. This is used in creating software, web designing, data analytics, creating software prototype. Python is dynamically typed and garbage-collected. It supports integrated programming paradigms, including procedural, object-oriented, and functional programming. Python is often described as a “rich library” language due to its comprehensive standard library which makes developer’s life easy in code. Python language simple syntax and object-oriented approach is focused to help coder write intelligible, insightful code for small and complex projects. Python is simple easy-to-use syntax makes python an excellent language to start for beginners.

Python was fabricated by Guido van Rossum within the late 1980 at Centrum Wiskunde & Informatica (CWI) within the Netherlands as a successor to fundamentals artificial language, that was intended by SETL, capable of exception handling and interfacing with the Amoeba OS. Its implementation began in Dec 1989.

Python interpreters are supported for mainstream operating systems. A International group of programmer develops and maintains CPython, a free and open-source. A not-for-profit organization, the Python Software Foundation, manages and directs resources for Python and CPython development.

Advantage of Python Programming:

  • Free to use and open-source programming language.
  • Easy to understand because of simple syntax and coding style as compared to other programming language like C++, JAVA and C#.
  • Platform independent in nature.
  • This programming language can be used as a server side scripting.
  • Due to rich library Python is simple to code.
  • Python is very much supportable to almost all the database.
  • Python is used to handle data analytics and perform complex mathematical calculation.
Python Syntax:
print(“Hello, Python! This is my first program”)
Why Python Programming:
  • Python is a Platform independent means it works for all operating System(Mac, Unix/Linux, Windows, Raspberry Pi, etc).
  • Python language syntax is similar to the English language.
  • Python has standard library that allows developers to write the complex logic programs with fewer lines of code as compared to other programming language.
  • Python debugging and Exception handling is very easy.

Python is entirely object oriented programming language, and not “statically typed”. In python declaration is not needed before using the variable, or type. Every variable in Python is an object. Variables means to assign memory locations for storing values. This means that when we create a variable it assign some space in memory.

Data available in memory is possible to have many type. For example Employee id will be possible to stored in either numeric or alphanumeric but Employee mobile no is always in numeric case. Managing these category python has standard data types for simplicity of programming and the storage method for each of them.

Python is having 5 standard data type:

  • Numbers
  • String
  • List
  • Tuples
  • Dictionary

Let’s understand each variable in detail:


a = 10

b = -10

Value present in a, b is a form of signed and and non signed “Int” which is also called as Integer.

Python supports four different numerical types −

  • int (signed integers) Ex:  10, -10
  • long (long integers, they can also be represented in octal and hexadecimal) Ex: 0xDAEBACFE, 76226726L
  • float (floating point real values) Ex:  a=1.4, 3.3 …
  • complex (complex numbers) Ex:  a= 10j which is a complex variable
Python String are declared with “str” keyword as a contiguous set of characters represented in the quotation marks(‘str’). advantage of python it permits either pairs of single or inverted comma. Subsets of strings are captured using the slice operator ([ ] and [:] ) with indexes beginning at zero within the starting of the string and dealing their approach from -1 at the top. The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetition operator.
str = 'Hi Rai Gurukul!!'

print str         (Prints full string print)

str[1]              (Prints 2nd character of the string)

print str[3:9]  (Prints characters starting from 4th to 9th print)

str[4:]             (Prints string starting from 5th character)

print str * 3   (Prints string 3 times)

print str + “RAI”  (Prints concatenated string)

Value of string is stored in array format means index start from ‘0’.
H is assigned to 0th Place, i assigned to 1st place and so on.

Hi Rai Gurukul!!


ai Guru

ai Gurukul!!

Hi Rai Gurukul!!Hi Rai Gurukul!!Hi Rai Gurukul!!

Hi Rai Gurukul!!RAI

Python Tuple is a sequence data type  which is “immutable” which means “never-changing” once declared.
Veg = ( 'Flower', 7 , 2.5, 'Cabbage', 6 , 70.2 )
by this way we are declaring tuple. will cover about tuple in detail in further part of the session.
Python List is a sequence data type  which is “mutable” which means “possible to change” once declared.
Veg = [ 'Flower', 7 , 2.5, 'Cabbage', 6 , 70.2 ]
List is declared in-between square braces. for more detail  refer List topic.
Python’s dictionaries are like a hash table type which is mutable in nature.
Employee = {'Fname': 'drew','ID':73, 'Team': 'IT'}
Dictionaries are enclosed by curly braces ({ }) and values can be assigned and accessed using square braces ([]). For more detail refer dictionary topic.





Working with HTTP requests is not a simple task in any computer programming language. If you know about Python, it comes with two in-built modules urllib and urllib2 to handle HTTP-related operations. Both the modules come with a different set of functionalities and many times they need to be used together. The main drawback of using urllib is bit confusing because the documentation is not clear and we need to write a lot of code to make even a simple HTTP request. To make these things handy to use a third-party library known as requests. It’s not an in-build module; we install it using the pip command. The requests module is available and most developers prefer to use it instead of urllib and urllib2. It is an Apache2 licensed HTTP library powered by urllib3 and httplib.

The requests module allows us to send HTTP requests using python. And the HTTP request returns a Response Object with all the response data like content, encoding, status, etc. When one makes a request to a URI and it returns the response. Python requests module provides inbuilt functionalities for managing both the request and response. To play with the web the python-requests are a must whether it is hitting APIs, downloading entire Facebook pages, and much more cool stuff one will have to make a request to the URL. The requests module plays a major role in dealing with REST APIs and Web Scraping.

How do we install the requests module in python?

The first step is to install the package using the pip command and module name. 


pip install requests

After the installation, we will use this module’s functionality. There are many functions and
class which are explained below.

To Make Request:
Python requests module has several built-in methods to make HTTP requests to specified URIs using the GET, POST, PUT, DELETE, PATCH, OR HEAD requests.

How we make GET request:

The requests module provides the in-built method called get() for making a GET request to a specified URI. It takes 3 arguments url, parameters, and args. The GET method is used to retrieve information from the given server using a given URI.


requests.get(url, params={key: value}, args)


import requests r = requests.get("") print(r) print(r.content) 



b'{\n "current_user_url": "",\n "current_user_authorizations_html_url": "{/client_id}",\n "authorizations_url": "",\n "code_search_url": " {query}{&page,per_page,sort,order}",\n "commit_search_url": " {query}{&page,per_page,sort,order}",\n "emails_url": "",\n "emojis_url": "",\n "events_url": "",\n "feeds_url": "",\n "followers_url": "",\n "following_url": "{/target}",\n "gists_url": "{/gist_id}",\n "hub_url": "",\n "issue_search_url": "{query} {&page,per_page,sort,order}",\n "issues_url": "",\n "keys_url": "",\n "label_search_url": "{query}&repository_id= {repository_id}{&page,per_page}",\n "notifications_url": "",\n "organization_url": "{org}",\n "organization_repositories_url": "{org}/repos {?type,page,per_page,sort}",\n "organization_teams_url": "{org}/teams",\n "public_gists_url": "",\n "rate_limit_url": "",\n "repository_url": "{owner}/{repo}",\n "repository_search_url": " {query}{&page,per_page,sort,order}",\n "current_user_repositories_url": "{?type,page,per_page,sort}",\n "starred_url": "{/owner}{/repo}",\n "starred_gists_url": "", \n "user_url": "{user}",\n "user_organizations_url": "",\n "user_repositories_url": "{user}/repos{?type,page,per_page,sort}",\n "user_search_url": " {query}{&page,per_page,sort,order}"\n}\n'