0% found this document useful (0 votes)
11 views

Python progamming

This document provides an introduction to Python programming, including its features, uses, and basic concepts such as modules and comments. Python is described as a versatile, high-level language suitable for various applications like data analysis, AI, and web development. The document also includes examples of single-line and multi-line comments, as well as details on the print statement and escape sequences.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Python progamming

This document provides an introduction to Python programming, including its features, uses, and basic concepts such as modules and comments. Python is described as a versatile, high-level language suitable for various applications like data analysis, AI, and web development. The document also includes examples of single-line and multi-line comments, as well as details on the print statement and escape sequences.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PYTHON

PROGAMMING
By Rohit Kushwaha

Python is a popular programming language. It was created by Guido van Rossum, and released in
1991.
What is Programming and Python?

Programming is a way for us to tell computers what to do . The computer is a very dumb machine
and it only does what we tell it to do . Hence we learn to program and tell computers to what we
are very slow at rate - computation. If I ask you to calculate 5+6, you will immediately say 11.
How about 23453453 X 56456?
You will start searching for a calculator or jump to a new tab to calculate the same. This 100 days
of code series will help you learn Python from starting to the end. We will start from 0 and by the
time we end this course, I promise you will be a Job ready Python developer!

What is Python?

 Python is a dynamically typed, general-purpose programming language that supports an


object-oriented programming approach as well as a functional programming approach.

 Python is an interpreted (meaning, source code of a Python program is converted into


bytecode that is then executed by the Python virtual machine) and high-level
programming language.

 It was created by Guido Van Rossum in 1989.

Features of Python

 Python is simple and easy to understand.

 It is Interpreted and platform-independent which makes debugging very easy.

 Python is an open-source programming language.

 Python provides very big library support. Some popular libraries include NumPy,
Tensorflow, Selenium, OpenCV, etc.

 It is possible to integrate other programming languages within Python.

What is Python used for

 Python is used in Data Visualization to create plots and graphical representations.

 Python helps in Data Analytics to analyze and understand raw data for insights and trends.

 It is used in AI and Machine Learning to simulate human behavior and to learn from past
data without hard coding.

 It is used to create web applications.

2
 It can be used to work with databases.

 It is used in business and accounting to perform complex mathematical operations along


with quantitative and qualitative analysis.

Modules and pip in Python!

Module is like a code library which can be used to borrow code written by somebody else
in our python program. There are two types of modules in python:

1. Built in Modules - These modules are ready to import and use and ships with the python
interpreter. there is no need to install such modules explicitly.

2. External Modules - These modules are imported from a third party file or can be installed
using a package manager like pip or conda. Since this code is written by someone else, we
can install different versions of a same module with time.

The pip command

It can be used as a package manager pip to install a python module. Lets install a module
called pandas using the following command

pip install pandas

Python Comments:

A comment is a part of the coding file that the programmer does not want to execute,
rather the programmer uses it to either explain a block of code or to avoid the execution of
a specific part of code while testing.

Single-Line comments:

To write a comment just add a ‘#’ at the start of the line.

Example 1

#This is a 'Single-Line Comment'


print("This is a print statement.")

Output:
3
This is a print statement.

Example 2

Print(“Hello World !!!”) # printing Hello world

Output :

Hello World ! ! !

Example 3:

Print(“Python Program”)

#print(“Python program”)

Output:

Python program

Mulit-Line Comments:

To write multi line comments you can use ‘#’ at each line or you can use the multiline
string:

Example1: The use of ‘#’

#It will execute a block of code if a specified condition is true.


#If the condition is false then it will execute another block of code.
p = 7
if (p > 5):
print("p is greater than 5.")
else:

4
print("p is not greater than 5.")

Output:

p is greater than 5.

Example 2 : The use of multiline string.

"""This is an if-else statement.


It will execute a block of code if a specified condition is true.
If the condition is false then it will execute another block of code."""
p = 7
if (p > 5):
print("p is greater than 5.")
else:
print("p is not greater than 5.")

Escape Sequence characters

To insert characters that cannot directly used in a string, we use an escape sequence
character.

An escape sequence character is a backlash \ followed by the character you want to insert.

An example of a character that cannot be directly used in a string is a double quote inside a
string that is surrounded by double quotes:

print("This doesnt "execute")


print("This will \" execute")

More on print statement:

The syntax of a print statement looks something like this :

print(object(s), sep=separator, end=end, file=file, flush=flush)

5
Other parameters of print statement

1. Object(S) : Any object , and as many as you like. Will be converted to string before
printed
2. Sep=’separator’: specify how to separate the objects. If there is more than on Default
is ‘ ‘
3. End=’end’:specify what to print at the end, Default is ‘\n’ (line feed)
4. File: An object with a write method. Defualt is sys.stdobut parameters 2 to 4 are
optional

You might also like