Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python Concept

The document provides an overview of Python programming concepts, including its features, data types, and control structures. It covers mutable and immutable data types such as lists, sets, dictionaries, tuples, and strings, along with their methods. Additionally, it explains operators, input/output functions, conditional statements, and looping constructs like for and while loops.

Uploaded by

mandeepbaba041
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Concept

The document provides an overview of Python programming concepts, including its features, data types, and control structures. It covers mutable and immutable data types such as lists, sets, dictionaries, tuples, and strings, along with their methods. Additionally, it explains operators, input/output functions, conditional statements, and looping constructs like for and while loops.

Uploaded by

mandeepbaba041
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

PYTHON CONCEPTS:-

BY:- AKASH KUMAR


TABLE OF CONTENT:-
 About Python
-Features
 Variables
 Operators
 Input() and output() function
 Data Types
 Mutable data types
-list [ ]
-sets { }
-dictionary{keys : values}
 Immutable data types
-Tuple()
-string
 Conditional statement
-if else
 Looping statement
- for loop
ABOUT PYTHON:-

 Python is simplest and general-purpose


interpreted, interactive, object-oriented, and
high-level programming language.
 It was created by Guido van Rossum during

1985- 1990.
 Python is Open source.

 Python is platform Independent .

 Python is Object-Oriented

 Python is a Beginner's language.


FEATURES OF PYTHON:-
VARIABLES :-
 Variables can be
define as the name of
memory allocated by
the name.
Or:- it is like a
container that stores
the value assign to it.
Example:-
a=5  a is variable or
memory name
allocated to value 5.
OPERATORS:-
THEY ARE THE SPECIAL SYMBOLS THAT DESIGNATE THAT SOME
SORT OF COMPUTATION SHOULD BE PERFORM.
1. Arithmetic operators :- Operators that are use
to perform arithmetic operations.
Example:- Addition ‘+’
Subtraction ‘-’
Multiply ‘*’
Divide ‘/’
2. Assignment operators :- Operators that used
to assign the value of variable.
Example:- Equals to ‘=‘
=+  a+=b  a= a+b.
‘-=’ , ‘*=’ .
3. Comparison Operators :- Operators the are
use to compare two values or variable.
Example:- ‘==’  used to check equal relation
‘<’, ‘>’  checks greater or lesser relation
‘<=’, ‘=>’  checks greater equal or lesser
equal
4. Logical operator :- Operators that performs
logical operations.
Example:- OR ‘||’  works on ‘or’ gate (having one
true condition, give true result)
AND ‘&&’  works on ‘and’ gate (gives true result,
if
having both conditions true)
5. Identity operator :- Operator use to check
identity like ‘==’ or ‘!=’. Represent by ‘is’ and
‘is not’.

6. Membership operation :- Operator use to


check presence of any variable or value in list or
any data type. Represent by ‘in’ and ‘not in’.
INPUT AND OUTPUT FUNCTION:-
1) Output function :- function use to display
any massage on console screen.
 syntax:-
print()
example:-
print(“any massage”)
2) Input function :- function use to take any
input from user.
 syntax:-
variable_name=input(“massage”)
Example:-
a=input(“Enter any value: ”)
DATA TYPES IN PYTHON:-
MUTABLE DATA TYPES:-
 They are the type of data type that can be
change / modify
1) List :- Can hold multiple data-type values.
 It is defined by [ ],
 It is ordered,
 It allow duplicates
Syntax:-
list_name=[#data]
Example:-
list=[1,2,3,4,5, “hello”, “brother”]
METHODS ON LIST:-
1) .index(#element name):- Use 3) .append(element):- use to
to fine the index number of add any element in list at
required element in list. end.
Syntax:- Syntax:-
a= list_name.index(element list_name.append(element)
name) 4) .pop():- use to remove any
element from list from required
print(list_name.index(eleme value as well from last position.
nt name)) or Syntax:-
print(a) listname.pop(#index no.) from
2) .insert(index no. , element required index
wants to add):- use to insert listname.pop()from last
any element in list at any
5) .remove(element name):- use
position.
to remove element by name.
Syntax:- Syntax:-
list_name.insert(index listname.remove(name)
no. , element)
6) .extend(list to add):- 8) .sort():- use to sort
use to merge two lists element in ascending or
in a single list. descending order.
Syntax:- Syntax:-
lisneme[list in you Listname.sort()in incre.
wants
tomurgeanother].exten Listname.sort(reverse=tru
d(list to be added) e)  in desce.
List1.extend(list2) 9).clear():- use to clear the
all element of a list.
7) .reverse():- use to Syntax:-
reverse the elements Listname.clear()
of list. 10)delet:- use to dlt the list
Syntax:- Syntax:-
listname.reverse() dlt listname
MUTABLE DATA TYPES:-
 They are the type of data type that can be
change / modify
2) Sets :- Can’t hold multiple data-type values.
 It is defined by { },
 It is unordered,
 not allow duplicates
Syntax:-
set_name={#data}
Example:-
set={ “hello”, “brother”, “how", "are”,
“you”}
set={1,2,3,4,5,6,7}
MUTABLE DATA TYPES:-
 They are the type of data type that can be
change / modify
3) Dictionary:- Can hold multiple data-type
values.
 It is defined by {key : value }, key(unique)
 It is unordered,
 not allow duplicates
Syntax:-
dict_name={key : values}
Example:-
Dict={“name” : “Akash”, “class” : 5 , “section” :
“A”}
DICTIONARY METHODS:-
1) To update dictionary
5) To get know the values of
data:-
dictionary:-
dict[“address”]=[“Panchk
Print(dict.values())
ula”]
6) To get know the items of
dict.update([“state”:”Hr”]
dictionary:-
)
Print(dict.items())
2) To print values by their
keys:- 7) To pop element by its
Print(dict[“keyname”]) key:-
3) To get know the name dict.pop(“state”)
of keys:- 8) To pop whole item from
Print(dict.keys()) last in dictionary:-
4) To empty whole dict.:- dict.popitem()
Dict.clear()
IMMUTABLE DATA TYPES:-
 They are the type of data type that can not
be change / modify
1) Tuple:- Can hold multiple data-type values.
 It is defined by ( ),
 It is ordered,
 It allow duplicates
Syntax:-
tuple_name=(#data)
Example:-
a=(“Akash”, “Aditya”, “Atul”)
METHODS ON TUPLE:-
1) To display tuple elements by their indexes:-
Print(a[0]) 0th index
Print(a[1]) 1th index
Print(a[2]) 2th index
Print(a[0:3])
2) To convert tuple into a list:-
listname=list(tuplename)
 now you can performe list methods.
3) To convert list into tuple:-
tuple_name=tuple(list_name)
IMMUTABLE DATA TYPES:-
 They are the type of data type that can not be change
/ modify
2) Strings :- Collection of all characters, numeric and
symbols assign within single, double or triple quotes.
 It is represented within ‘ ’ , “ ”, and “ ”.
Syntax:-
Print(‘#string/massages’)
Print(“#string/massages”)
Print(“‘#string/massages’”)print as massage
written
example:-
print(“gfd3232849”)
METHODS ON STRING:-
1) .isupper() true false result
2) .islower()true false result
3) .formate(“modificaton”)used to modify
4) .find(“any element in string”)give index no.
5) .index (“any element in string”)  give index
no.
6) .isalpha() true false result
7) .isdigit() true false result
8) .isalnum true false result
9) .split()  to convert string into list
CONDITIONS STATEMENT:-
 They are used to make  If elif ladder, used to make
decision between more than two
decision between two statements
conditions. Syntax:-
if condition:
Syntax:-
#body
if condition: elif condition:
#body #body
else:
else: #body
#body example:-
a=5
example:- b=6
a=5 c=9
if a>b && a>c:
b=6 print(a,“ is greater”)
if a>b: if b>a && b>c:
print(b,“ is greater”)
print(a,“ is greater”)
else:
FOR LOOP:-
 Loops are used to do repetitions until given
condition become false.
 This loop is use when we know number of

repetition
 Syntax:-

for variable in
range(start,condition,stepping) :
#body
Range():- Take three parameters
1st as starting point
2nd as condition point
3rd as stepping/increment/decrement
FOR LOOP:-
Example:- to print 5’s table
a=5
for i in range(1,11):
print(a, “*”,i “=”,a*i)

Output:-
5*1=5 5*6=30
5*2=10 5*7=35
5*3=15 5*8=40
5*4=20 5*9=45
5*5=25 5*10=50
WHILE LOOP:-
 Loops are used to do repetitions until given
condition become false.
 This loop is use when we do not know number

of repetition
 Syntax:-

initialization
while condition:
#body
increament/decreament
WHILE LOOP:-
Example:- to print 5’s table
a=5
i=0
While i<=10:
print(a, “*”,i “=”,a*i)

Output:-
5*1=5 5*6=30
5*2=10 5*7=35
5*3=15 5*8=40
5*4=20 5*9=45
5*5=25 5*10=50
FUNCTIONS:-
A functions is a block of code, that only runs
when we call it.
 We can pass data as parameters into

function.
 When a function runs , it takes data as

argument if we declared some parameter


into it.
 Creating a function:-

In python we defined a function by using


keyword “def” before declaring
fn_name
 Calling a function:-

use function name followed by parenthesis.


FUNCTION CREATING AND
CALLING:-
 Function creating:-  Function calling:-
Syntax:- Syntax:-
def fn_name():
#body fn_name(argument)
Example:-
def my_function(): Example:-
print(“hello”) my_function()
print(“how are
u?”)  output:-

hello
how are u?
Thank you

You might also like