0% found this document useful (0 votes)
6 views24 pages

MyPyNotes

Python is a high-level, general-purpose programming language developed by Guido Van Rossum between 1985 and 1990, known for its simplicity and versatility across various platforms. It supports object-oriented programming, is free and open-source, and is widely used in applications ranging from web development to artificial intelligence. Key features include an interactive shell, various data types, operators, and control statements, making it accessible for both beginners and experienced programmers.

Uploaded by

75227sumit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views24 pages

MyPyNotes

Python is a high-level, general-purpose programming language developed by Guido Van Rossum between 1985 and 1990, known for its simplicity and versatility across various platforms. It supports object-oriented programming, is free and open-source, and is widely used in applications ranging from web development to artificial intelligence. Key features include an interactive shell, various data types, operators, and control statements, making it accessible for both beginners and experienced programmers.

Uploaded by

75227sumit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

PYTHON

A PROGRAMMING LANGUAGE
A computer needs step – by – step instructions to complete a task. These instructions are called a
computer program when they are written in some programming language. But before they are
written in any programming language, these steps are written is simple English language. These
are called Algorithms. These instructions are written in a language which the computer
understands and this language is known as Programming language.
What is Python?
Python is a general purpose interactive high level programming language. Which is developed by
Guido Van Rossum during 1985-1990. Rossum named the language Python to honor British
comedy group Monty stands for
IDLE. It is typically used on windows. It has a multi – window text editor with syntax highlighting,
auto-completion, smart indent and other features.
Why Python?
 Easy to learn and use as it has a simple structure and syntax.
 Interactive language which uses an interpreter.
 Portable and can be used on different platforms like Windows, Unix, Linux, Macintosh etc.
WELCOME TO PYTHON

 Object – Oriented programming language and can also be integrated with other languages like C++,
Java etc.
 FOSS(Free Open Source Software) language.
 Faster than other languages.

Want to built a slick website? Develop a video game? Or may create an artificial intelligence? Python’s
got you covered and then some.
Python is HLL, with a ton of applications. It is seriously flexible and accessible, which makes it popular
with some of the world’s biggest and coolest organization- think Google, NASA, Disney, YouTube, Yahoo,
Dropbox….. Even the CIA.
Python shell can be used in two ways-
 Interactive mode
 Script mode
PYTHON FEATURES
Network Satellite Link

PYTHON WORKING IN MANY FIELDS


PYTHON INTERACTIVE MODE & SCRIPT MODE
PYTHON DATA TYPES
Data type Value description

integers - ive, zero, + ive In version 2.x, it holds upto -


231 to 231-1 and 3.x no limit.
long - ive, zero, + ive After python version 3.x this
data type does not exist. Other
programming languages still
using it.
float 2.33, -23.4872 Any decimal value

string ‘a’, “abc”, ‘’’abc de f’’’ Sequence of characters


enclosed by single, double or
triple quotation mark.
Many more datatype used in python.
PYTHON KEYWORDS
words are the words those have a special meaning for the python interpreter. Like:
Keywords

and del from

except import print

while As elif

global or with

class if for

public private protected


PYTHON OPERATORS
A symbol used for specific purpose or operation.
Operator Description Example

+ addition Adds values on both sides of the operand >>> 10 + 20


- Subtraction Subtracts right hand operand from left and >>> 30 – 20
right operand
• Multiplication Multiplies value on either side of the operand >>> 3 * 3

/ division Divides left hand operand by right hand >>> 9 / 3


operand
% modulus Divides left hand operand by right hand >>> 10 % 3
operand and gives remainder
** exponent Performs exponential (power) calculation on >>> 3 ** 2
operands
// integer division Also called floor division – the result is the >>> 9 // 2
quotation in which the digits after the decimal
LOGICAL OPERATORS:
Logical Operator Description Example

== Compares the equality of values or >>> 10 == 20 -> False


expressions, which are equal or not and
returns Boolean values.
!= Compares the values, which are must be >>> 30 != 20
unequal.
< Compares two values, where one value is less >>> 3 < 3
than another value.
> Compares two values, where one value is >>> 9 > 3
greater than another value.
<= Compares two values, where one value is less >>> 10 <= 3
than or equals to another value.
>= Compares two values, where one value is >>> 3 >= 2
greater than or equals another value.
RELATIONAL OPERATORS
Relational Description Example
Operator
and It relates two expressions and returns boolean >>> 10 == 20 and 10 !
value. If both have true, return true otherwise =3 -> False
returns false in all cases.
or It relates two expressions and returns boolean >>> 30 – 20!=1 or 2!=2
value. If anyone have true, return true
otherwise returns false in all cases.
not It inverts result of the expression and returns >>> not(3 > 3)
boolean value.
STATEMENTS
d to check data type of value.
ultiple items in same line, separate them with a comma.
in between words you can add a blank string.
Statements
ways in which a program can be executed-
tial statements
on statements
e(repeated/looping) statements
ntial: in in a program as you have learnt previously, the instructions are executed one after the other in
the order they are written. This is called Sequential statement.
ion: in this form, depending upon the condition, a decision has to be taken. If the condition evaluates to
certain steps are to be executed and if the condition evaluates to false, a different set
are to be executed. There are three types of decision making constructs in python.
t if-else statement if-elif-else statement ne
STATEMENTS
tement: the simple if statement tests a condition and if it is true, performs the following steps, otherwi
nothing.
ax: if <condition>:
statements
e statement: this is similar to the ‘if statement’. In this case when the if part does not executes then
will be executed.
ax: if<condtion>:
statements
else:
statements
f-else statement: multiple conditional parts can be formed by using if-elif-else statement and if non
becomes true then else part will be executed.
ax: if <statement>:
STATEMENTS
elif <condtion2>:
statement
.
.
elif <condition n>:
statement
else:
statement
Iterative/loop/repeative statements: a loop statement allows us to execute a statement or group of
statements multiple times. There are two type of loops in Python.
For loop While loop
While Loop statement: in the while loop, a set of statements will be executed as long as the
given condition is true. It tests the condition before executing the loop body. The loop body could
contain one statement or a block of statements. When the condition becomes false, the control
passes to the statement immediately following the loop. It is also called conditional loop.
STATEMENTS

Syntax: while expression:


statement(s)
For loop: a for loop is used for iterating over a sequence. With the ‘for loop’, we can execute a
set of statements, for each item in a list, tuple, etc. each item in the list is designed to variable
used for iteration and the statements block is executed until the entire sequence is exhausted.
the for loop is also called counting loop.
Syntax: for initials in(keyword) upto_value(end point):
statement(s)
STATEMENTS

Loop control statements: python has three control statements. These are used to change
the normal functioning of the loop.
Break statement Continue statement Pass
statement
DATA STRUCTURES
Almost every program used data. Organizing, managing and storing data is important as it
enables easier access and efficient modifications.
Data structures allow you to store and manage your data. Python has a number of built-in data
structures:
 String
 Lists
 Dictionaries
 Tuples
 Sets
DATA STRUCTURES
There are a number of special characters that can be used in strings.
Escapes sequences: some characters cannot print directly in python. These character are
known as escaped characters. For example, Brian\’s mother
\n represents a new line.
\t represents a tab space… etc.
The in operator can be used to check if a string is part of another string.
Example:
X = ‘I have sound knowledge of python’
for ‘sound’ in X:
print(‘found’)
Note: the not in operator can be used to check if a string is not part of another string.
String can be added together by using + operator, called concatenation.
STRING MANIPULATION
String: A string can be seen as a sequcen of characters which are written within single , double
or tirple quotes. You have already read about them earlier. You can access the characters in a
string by putting the index after the string name in square brackets.
Example: name = ‘Python’
to access the character of name by using index.
name[0]
P
String can be added together (also called concatenation):
print(“spam”+’eggs’)
Strings can also be multiplied by integers. This produces a repeated version of the original
string.
print(“spam”*3)
String can’t be multiplied by other strings. Strings also can’t be multiplied by floats, even if the
floats are whole numbers.
STRING MANIPULATION

String: have many useful functions:


 count(str): returns how many times the str substring appears in the given string.
 upper( ): converts the string to uppercase.
 lower( ): converts the string to lowercase.
 replace(old, new): replaces all occurrences of old with new.
 len(str): returns the length of the string (number of characters).
WORKING WITH LIST
List: lists are used to store multiple elements, each corresponding to an index. They are created using
square brackets.
Example: n =[ ‘Python’,’c’,’c++’]
the names list contains three strings. Each element of he list can be accessed using its index:
print(n[0])
List can be used to represent a collection of data, for example ages of people, monthly growth rates of
stocks, etc.
List can be nested to represent 2D grids, such as matrices:
Example: m=[[1,2,3],[4,5,6]]
print(m[0][1])
A matrix like structure cab be used in cases where you need to store data in row-column format.
Similar to strings, we can use the in and not in operators to check if an element is part of the list.
Example: words=[“spam”,”eggs”,”spam”,”sausage”]
print(“spam” in words)
WORKING WITH LIST

the len( ) function can be used to return the number of elements in a list.
Similar to strings, we can loop through the elements of a list using a loop:
X = [2,4,6,8]
for n in x:
print(n)
n will represent the current list item during each iteration.
SHORT CUTS KEYS IN PYTHON
SCRIPT MODE

F To run program
5
F Python documentation
1
Ctrl +
q To quite IDLE
short cuts of Py lib details visit https://www.python.org or
https://www.UniversalCodebox.com
THANK YOU

You might also like