Low-level versus high-level
General versus targeted to an application
domain
Interpreted versus compiled
Python was conceived in the late
1980 by Guido van Rossum at Centrum
Wiskunde & Informatica (CWI) in
the Netherlands
Successor to ABC programming language
Python is an interpreted, object-oriented,
high-level programming language with
dynamic semantics.
Python is dynamically typed and garbage-
collected language.
Python's design thinking give emphasis to
code readability with its notable use of
significant whitespace.
Python's simple and easy to learn syntax
emphasizes readability and therefore
reduces the cost of program maintenance
Open Source
Easy to learn
Readable and Maintainable Code
Multiple Programming Paradigms
Compatible with Major Platforms and Systems
Many Open Source Frameworks and Tools
Simplify Complex Software Development
Support many libraries like matplotib,
numpy,pandas,scikit,scipy
For installation on Windows
Download it from
[Link]
Current version of python is 3.10.8
Use python IDE or any text editor to write
program
Python program, sometimes called a script, is
a sequence of definitions and commands.
Ex.. print(“Hello World”) Hello World
Idle
Sublime Text 3
Atom
PyCharm
Thonny
Spyder
Pydev
Rodeo
VS
Create new file and save it as [Link]
[Link]
print(“Hello World”)
print(“Welcome to the L.D. College of Engg.”)
To Run it- open the terminal and change
directory where program is saved
Run using command
python [Link]
Comments can be used to explain Python
code.
# This is a single line comment
print("Hello, World!")
Output of above code is
Hello, World!
Multiline Comment: """ triple quotes """
Objects are the core things that Python
programs manipulate
Objects and operators can be combined to
form expressions
ex.. c =a +b
Type
◦ Scalar
◦ Non-scalar
Types can be categorized into different
category.
Name Type Description
Integer int Whole number such as 0,1,5, -5 etc..
Numbers with decimal points such as
Float float
3.5, -25.5 etc..
String str Set of characters
Boolean bool Logical values indicating True or False
Complex Complex To present complex numbers x = 3+5j
[Link]
print(“Simple data types examples”)
a=5
b=“Hello”
print(“ Value of a=”,+a)
print(“values of b=”,+b)
print(type(a)) # To display types of variable
print(type(b))
Type Basic data types
Text Type str
Numeric Types int, float, complex
Sequence Types list, tuple
Mapping Type dict
Set Types set, frozenset
Boolean Type bool
Binary Types bytes, bytearray
Prefix Interpretation Base
0b (zero + lowercase letter 'b') Binary 2
0B (zero + uppercase letter 'B')
0o (zero + lowercase letter 'o') Octal 8
0O (zero + uppercase letter 'O')
0x (zero + lowercase letter 'x') Hexadecimal 16
0X (zero + uppercase letter 'X')
A Python variable is a reserved memory
location to store values.
Python has no command for declaring a
variable.
Variable is created the moment you first
assign a value to it.
Python use Dynamic Typing
Reassign different type of value to the same
variable
Use type(variable-name) in-built function to
check type of variable
Rules for variable name
A Python variable is a reserved memory
location to store values.
Name can not start with digit
Space not allowed
Can not contain special character
Python keywords not allowed
Should be in lower case
[Link]
print(“Simple data types examples”)
a=5
b=“Hello”
print(“ Value of a=”,+a)
print(“values of b=”,+b)
1a=5 # Error – cannot start with digit
print(type(1a))
Program
x, y, z = "Orange", 23, "Cherry"
print(x)
print(y)
print(z)
print(type(x))
print(type(y))
print(type(z))
int() ‘1’ ‘001001’
int(a,base) int(a,2)
float()
ord()
hex()
oct()
str()
chr()
complex(real,imag)
String is ordered sequence of character
Strings are arrays of bytes representing
Unicode characters.
String can be represented as single, double or
triple quotes.
String with triple Quotes allows multiple lines.
String in python is immutable.
Square brackets can be used to access
elements of the string
String index start with 0
Ex name=‘LDCE’ name[1]=D
To get single character use we use index number
name= “HelloWorld”
print(name[1]) e
Negative Index is used to start from end of string
print(name[-3]) r
Negative index starts from end of string
[Link]
Slicing is used to extract substrings of arbitrary
length. x[start-index : end-index] return string
between starts-index and (end-index)-1
name= “HelloWorld”
To get multiple character, we use range of
index number using colon(:) –exclude last char
print(name[1:7]) elloWo
Using step size, we use range of index number
using colon(: :) –exclude last char
x[start-index : end-index : step-size]
print(name[Link]) elW
To find length of string, use len() method
a = ”LDCE”
print("Length of string=",len(name))
To find length of string, use len() method
Method Name Description
[Link]() Return a copy of the string with its first
character capitalized and the rest lowercased.
[Link]() Return a casefolded copy of the string.
Casefolded strings may be used for caseless
matching.
[Link](width[, fill Return centered in a string of length width.
char]) Padding is done using the
specified fillchar (default is an ASCII space). The
original string is returned if width is less than or
equal to len(s).
[Link](sub[, start[ Return the number of non-overlapping
, end]]) occurrences of substring sub in the range
[start, end].
Ref: [Link]
Method Name Description
[Link](encoding=" Return an encoded version of the string as a
utf-8", errors="strict") bytes object. Default encoding is 'utf-8'
[Link](suffix[, st Return True if the string ends with the
art[, end]]) specified suffix, otherwise return False.
[Link](tabsize Return a copy of the string where all tab
=8) characters are replaced by one or more
spaces, depending on the current column
and the given tab size.
[Link](sub[, start[, en Return the lowest index in the string where
d]]) substring sub is found within the
slice s[start:end].
Ref: [Link]
Method Name Description
[Link](sub[, start[ Return lowest index of sub. but
, end]]) raise ValueError when the substring is not found
[Link]() Return True if all characters in the string are
alphanumeric and there is at least one
character, False otherwise
[Link]() Return True if all characters in the string are
alphabetic and there is at least one
character, False otherwise.
[Link]() Return True if the string is empty or all characters
in the string are ASCII, False otherwise.
[Link]() Return True if all characters in the string are
decimal characters and there is at least one
character, False otherwise.
[Link]() Return True if all characters in the string are digits
and there is at least one character, False otherwise.
Ref: [Link]
Method Name Description
[Link]() Return True if the string is a valid identifier
according to the language definition,
[Link]() Return True if all cased characters in the string
are lowercase and there is at least one cased
character, False otherwise.
[Link]() Return True if all characters in the string are
numeric characters, and there is at least one
character, False otherwise
[Link]() Return True if there are only whitespace
characters in the string and there is at least one
character, False otherwise.
[Link]() Return True if the string is a titlecased string
and there is at least one character,
[Link]() Return True if all cased characters in the string
are uppercase and there is at least one cased
character, False otherwise.
Ref: [Link]
Unicode standard describes how characters
are represented by code points.
A code point is an integer value, usually
denoted in base 16.
In the standard, a code point is written using
the notation U+12CA to mean the character
with value 0x12ca (4,810 decimal).
A character is represented on a screen or on
paper by a set of graphical elements that’s
called a glyph
[Link]
Unicode string is a sequence of code points,
which are numbers from 0 through 0x10FFFF
(1,114,111 decimal).
This sequence needs to be represented as a
set of bytes (meaning, values from 0 through
255) in memory.
The rules for translating a Unicode string into
a sequence of bytes are called an encoding.
[Link]
Python divides the operators in the following
groups:
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Identity operators
Membership operators
Bitwise operators
Operator Example Same As
= x=5 x=5
+= x += 3 x=x+3
-= x -= 3 x=x-3
*= x *= 3 x=x*3
/= x /= 3 x=x/3
%= x %= 3 x=x%3
//= x //= 3 x = x // 3
**= x **= 3 x = x ** 3
&= x &= 3 x=x&3
|= x |= 3 x=x|3
^= x ^= 3 x=x^3
>>= x >>= 3 x = x >> 3
<<= x <<= 3 x = x << 3
Operator Name Example
== Equal x == y
!= Not equal x != y
> Greater than x > y
< Less than x < y
>= Greater than or equal to x >= y
<= Less than or equal to x <= y
Operat Description Example
or
and Returns True if both statements are x < 5 and x <
true 10
or Returns True if one of the statements x < 5 or x < 4
is true
not Reverse the result, returns False if not(x < 5 and
the result is true x < 10)
Operat Description Example
or
is Returns true if both variables are the x is y
same object
is not Returns true if both variables are not x is not
the same object y
Operat Description Example
or
in Returns True if a sequence with the x in y
specified value is present in the object
not in Returns True if a sequence with the x not in y
specified value is not present in the
object
Operato Name Description
r
& AND Sets each bit to 1 if both bits are 1
| OR Sets each bit to 1 if one of two bits is 1
^ XOR Sets each bit to 1 if only one of two bits is 1
~ NOT Inverts all the bits
<< Zero Shift left by pushing zeros in from the right
fill and let the leftmost bits fall off
left
shift
>> Signed Shift right by pushing copies of the leftmost
right bit in from the left, and let the rightmost
shift bits fall
The simplest branching statement is a
conditional.
In Python, a conditional
statement has the form
if Boolean expression:
block of code
else:
block of code
Branching Statement
If
If.. Else
If.. Elif …. Else
Syntax
if Boolean expression:
block of code
Program
a=25
b=10
if a>b:
print("Value of a is higher ")
Syntax
if Boolean expression:
block of code
else:
block of code
Program
a=25
b=10
if a>b:
print("Value of a is higher ")
else:
print("Value of b is higher ")
Syntax
if Boolean expression:
block of code
elif Boolean expression:
block of code
Program
a=25
b=10
if a>b:
print("Value of a is higher ")
elif a==b:
print("Value of a and b are equal ")
Syntax Program
if Boolean expression:a=25
block of code b=10
elif Boolean expression: if a>b:
print("Value of a is higher")
block of code
elif a==b:
else : print("Value of a and b are
block of code equal ")
else:
print("Value of b is
higher")
Set of statements executed until condition is
true
Loop statement
◦ while
◦ for
Loop control statement
◦ break
◦ continue
◦ pass
Ref:[Link]
while statement allows you to repeatedly
execute a block of statements as long as a
condition is true.
Syntax:
while expression:
statement(s)
Example:
count = 1
while (count < 10):
print ('The count is:', count)
count = count + 1
while with else statement : else block
statement executed when condition of while
fully executed or exit without any break
count = 1
while (count <= 10):
print ('Count is:', count)
count = count + 1
else :
print("value of count is higher than 10")
while with break while with continue
print("While statement with print("While statement with
break ") continue ")
count = 1
count = 1
while (count <= 10):
while (count <= 10):
if count==5:
break if count==5:
print ("Count is:", count) continue
count = count + 1 print ("Count is:", count)
else : count = count + 1
print("value of count is
higher than 10") What is output?
while with pass while with continue
print("While statement with print("While statement with
pass ") continue ")
count = 0 count = 0
while (count <= 10): while (count <= 10):
count = count + 1 count = count + 1
if count==5: if count==5:
pass continue
print ("Count is:", count) print ("Count is:", count)
# What is output?
Syntax
for iterating_var in sequence:
statements(s)
Example:
word_list=[1,2,3,'ldce','computer']
for i in word_list :
print(i)
# for loop iterative using sequence index
print("for loop iterative using sequence index")
colleges= ['ldce','cgec','iitram','nirma']
for index in range(len(colleges)):
print("Index :" , index ,end=" ")
print("Current College :", colleges[index])
for with break & else for with continue
word_list= word_list=
[1,'ldce','computer','pds','be' [1,'ldce','computer','pds','be'
] ]
print("for statement with print("for statement with
break ") continue")
for i in word_list : for i in word_list :
if i =='pds' : if i =='pds' :
break continue
print(i)
print(i)
else:
print("After for loop in else
block")
A function is a block of organized, reusable
code which perform related action when it is
called.
Python function
◦ Built in function
◦ User defined function
Function blocks begin with the keyword def
followed by the function name and
parentheses ( ( ) )
Any information(parameter/argument) can be
passed by placing within parentheses
The first statement of a function can be an
optional statement - the documentation
string of the function or docstring.
Code of function
Return statement
[Link]
# program of user defined function
def demo_function():
print("Welcome message from demo function")
return
print("In this program we call demo_function ")
demo_function() # function calling
[Link]
# program of user defined function with one argument
def demo_function(name):
print("Welcome",name,"to the demo function")
return
print("In this program we call demo_function ")
demo_function(“ldce”) # function calling
# program of user defined function with argument
def demo_function(* name):
print("Welcome",name,"to the demo function")
return
print("In this program we call demo_function ")
demo_function(“ldce”,”college”) # function calling
Function Arguments
Default argument
Keyword argument
Positional argument
Variable length argument
# program of default argument
# demo function for default argument
print("Demo function with default argument ")
def demo_function(name="python"):
print("Welcome",name,"to the demo function")
return
print("In this program we call demo_function ")
demo_function() # function calling- call default argument
demo_function("ldce") # function calling with argument
Function Arguments
# program of keyword & positional argument
def demo_function(fname,lname,branch='IT'):
print("Welcome",fname,lname,"to your ",branch," branch")
return
print("Demo function for keyword argument ")
demo_function(fname="Pragneh",branch="computer",lname="Patel
") # function calling using keyword argument
demo_function("Pragneh","computer","CE") # function calling-
Positional argument
print("function calling with keyword and positional argument")
demo_function("Pragneh",branch="computer",lname="Patel")
print("function calling with keyword ,positional and default
argument")
demo_function("Pragneh",lname="Patel")
Pass command line argument in python
[Link][1]
import sys
print('Hello‘,[Link][1])
[Link][0]
Scope of Variables
• Global variables
• Local variables
Four built-in data structures in Python - list,
tuple, dictionary and set
Data Structures
Ordered Sequence of items, represented with
List list
square brackets [ ]
Ordered immutable sequence of items,
Tuple tup
represented with round brackets ( )
Unordered collection of unique items,
Set set
represented with the curly brackets { }
Dictio Unordered key : value pair of objects ,
dict
nary represented with curly brackets { }
Ref:[Link]
[Link]
A list is a data structure that holds an
ordered collection of items
Ex.. List of shopping items
Sequence type
It is represented by square bracket [ ]
List items can be added and deleted
List is mutable data type and supports
duplicate values
List items can be accessed using index and
perform slice operation like string
[Link]
wordlist=['ldce','college','engineering','python','ldce']
print(wordlist) # Print list
print(wordlist[1]) # print list item of 1st index
print("Length of list = ",len(wordlist)) # print length of list
print(wordlist[-1])
print(wordlist[1:3])
Method Name Description
[Link](x) Add an item to the end of the list. Equivalent to
a[len(a):] = [x]
[Link](ite Extend the list by appending all the items from the
rable) iterable. Equivalent to a[len(a):] = iterable.
[Link](i, x) Insert an item at a given position. The first argument
is the index of the element before which to insert,
[Link](x) Remove the first item from the list whose value is
equal to x. It raises a ValueError if there is no such
item.
[Link]([x]) Remove the item at the given position in the list, and
return it. If no index is specified, [Link]() removes
and returns the last item in the list.
[Link]() Remove all items from the list. Equivalent to del a[:]
Ref: [Link]
Method Name Description
[Link](x[, Return zero-based index in the list of the first item
start[, end]]) whose value is equal to x.
[Link](x) Return the number of times x appears in the list.
[Link](key=Non Sort the items of the list in place
e, reverse=False)
[Link]() Reverse the elements of the list in place.
[Link]() Return a shallow copy of the list. Equivalent to a[:].
Ref: [Link]
Program
wordlist=['ldce','college','engineering','python','ldce']
print(wordlist) # Print list
[Link](“pds”)
[Link]()
print(wordlist) # Print list
[Link]()
print(wordlist) # Print list
Program
# Python list Example as as queue
from collections import deque
wordlist=deque(['ldce','college','engineering','python','ldce'])
print(wordlist) # Print list
print("Length of list = ",len(wordlist)) # print length of list
[Link]('computer')
[Link]('pds')
print(wordlist) # Print list
print([Link]())
print(wordlist) # Print list
print([Link]())
print(wordlist)
[Link]
numbers = [] list() # create empty list
for x in range(10):
[Link](x)
print("Numbers :", numbers)
numbers=[x for x in range (10)]
print(numbers)
print("Display list elements using for loop
iteration")
for i in numbers:
print(i)
A Tuple is a data structure that holds an
ordered collection of items
Sequence type
It is represented by round bracket ( )
Tuple is immutable data type hence cannot
modify tuple
Tuple items can be accessed using index and
perform slice operation like string
Tuple can be nested
[Link]
colleges=('ldce','vgec','iitram')
print(colleges)
print("Number of colleges in the tuple Colleges = ",len(colleges))
newcolleges='gecg','gecmodasa','nirma',colleges
print(newcolleges)
print("Number of colleges in the tuple newcolleges = ",len(newcolleges))
print("college names taken from old college are ", newcolleges[3])
print("Last college name fron newcollege tuple is ",newcolleges[3][2])
print(newcolleges[1:3]) # To display elements between 1 to (3-1) index
print(newcolleges[1:]) # To display all the elements start from index 1
print(newcolleges[:]) # To display all the elements
print(newcolleges[::2]) # Use step size of 2 to display alternate item
Set is a unordered collection of hashable
objects with no duplication
Set is unindexed.
It is represented by curly bracket { }
Set items can be added or deleted but cannot
change items
Set support mathematical operations like
union, intersection, difference, and symmetric
difference and supports membership testing
Create empty set using set() function
set() and frozenset()
[Link]
colleges={'ldce','vgec','iitram','ldce'}
print(colleges)
print("Number of colleges in the set Colleges = ",len(colleges))
newcolleges='gecg','gecmodasa','nirma',colleges,'ldce'
print("\n",newcolleges)
print("Number of colleges in the set newcolleges = ",len(newcolleges))
# Check membership in set
print('ldce' in colleges)
[Link]('nirma') # add elements in the set using add method
print(colleges)
[Link]("nirma") # remove elements from set using remove
method
print(colleges)
[Link]('vgec') #remove elements from set using discard method
print(colleges)
Method Name Description
add(elem) Add element elem to the set.
remove(elem) Remove element elem from the set. Raises KeyError if
elem is not contained in the set.
discard(elem) Remove element elem from the set if it is present.
pop() Remove and return an arbitrary element from the set.
Raises KeyError if the set is empty.
clear() Remove all elements from the set.
len(s) Return number of element in the set s
x in s Test x for membership in s.
x not in s Test x for not-membership in s.
copy() Return a shallow copy of the set.
Ref: [Link]
Method Name Description
isdisjoint(other) Return True if the set has no elements in common
with other. Sets are disjoint if and only if their
intersection is the empty set.
issubset(other) Test whether set is subset of the set other.
issuperset(other) Test whether set is superset of the set other.
union(*others) Return a new set with elements from the set and all
others.
intersection(*othe Return a new set with elements common to the set
rs) and all others.
difference(*others Return a new set with elements in the set that are not
) in the others.
symmetric_differe Return a new set with elements in either the set or
nce(other) other but not both.
Ref: [Link]
A dictionary is a unordered collection of
objects/items which is of key-value pair form
It is mutable
It is represented by curly bracket { }
Indexed using key
Key must be immutable type of object
Basic operation are store, delete and modify
value with key in a key:value pair
dict = {}
dict['a'] = 'alpha’
dict['g'] = 'gamma‘
dict['o'] = 'omega
Ref:[Link]
[Link]
# create dictionary using key-value pair
col_dict ={ "college" : "ldce" ,
"branch" :"computer" ,
"subject" : "Python for data Science",
"semester": 5 }
print(col_dict)
print(type(col_dict))
print("Number of items in the dictionary = ",len(col_dict))
# display value of specific key
print(col_dict["branch"])
print(col_dict.get("branch")) # using get method
# Modify specific value
col_dict["subject"]="PDS"
print(col_dict)
# Check for membership- key exits in dictionary or not
using in operator
print("Check for key exits in dictionary :","branch" in col_dict)
print(5 in col_dict)
# Remove value with specific key using pop()
col_dict.pop(“branch”)
Print(col_dict)
# popitem() method removes the last inserted item
col_dict.popitem()
print(col_dict)
# remove item using del method
del col_dict[“semester”]
print(col_dict)
# Copy dictionary using copy() method
col_copy=col_dict.copy()
Print(col_copy)
# Empty dictionary using clear method
col_dict.clear()
print(col_dict)
# Display keys of the dictionary
print(col_dict.keys())
# Display values of the dictionary
print(col_dict. values())
# Python Dictionary Formatting Example
col_dict ={ "college" : "ldce" ,
"branch" :"computer" ,
"subject" : "Python for data Science",
"semester": 5 }
msg = ‘Semeseter= %(semester)d Course=
%(subject)s' % col_dict
print(msg)
Errors can be broadly classified into two
classes:
1. Syntax errors (Parsing error)
Ex.. if a > b
2. Logical errors (Exceptions)
Ex.. 1 / 0
‘2’ + 2
Python Built-in Exceptions:
Ex.. print(dir(locals()['__builtins__']))
try:
print(x)
except:
print("Exception occurred")
# Example for try..with multiple except
try:
print('2'+2)
except ArithmeticError:
print("Type Error in the expression in multiple exception")
except TypeError:
#except (TypeError, ZeroDivisionError):
print("Type Error in the expression in multiple exception")
except:
print("Other error occurred in multiple exception")
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError',
'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError',
'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError',
'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
'Exception', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError',
'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError',
'IndexError', 'InterruptedError', 'IsADirectoryError','KeyError', 'KeyboardInterrupt',
'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'None',
'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError',
'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'RecursionError',
'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopAsyncIteration',
'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError',
'TimeoutError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError',
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning',
'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '__build_class__',
'__debug__', '__doc__', '__import__', '__loader__', '__name__', '__package__', '__spec__', 'abs',
'all', 'any', 'ascii', 'bin', 'bool', 'breakpoint', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod',
'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval',
'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help',
'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map',
'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit',
'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum',
'super', 'tuple', 'type', 'vars', 'zip']
Example
try:
#print('2'+2)
print("This is from try block of try..catch..else")
except:
print("Other error occurred")
else :
print("in the else block of try..catch..else ")
Example for try..except with finally block
try:
print(x)
except:
print("Exception occurred in try...except..finally block")
finally :
print("Finally block in the try..except...finally block")
Raise- keyword is used to raise or throw an
exception
Example
x = -25
if x < 0:
raise ZeroDivisionError("Zero division can occcurred.")
#raise Exception("Sorry, no numbers below zero")
class B(Exception):
pass
class C(B):
pass
class D(C):
pass
for cls in [B, C, D]:
try:
raise cls()
except D:
print("D")
except C:
print("C")
except B:
print("B")
Ref: [Link]
class B(Exception):
pass
class C(B):
pass
class D(C):
pass
for cls in [B, C, D]:
try:
raise cls()
except D:
print("D")
except C:
print("C")
except B:
print("B")
Ref: [Link]
Object oriented programming language
Class is created using class keyword
Example:
class Myclass:
name =‘ldce’
# create object of class
obj1 = MyClass()
# access attributes of class
print([Link])
Contain attributes and methods
_init_ function to assign initial value
class College:
def __init__(self, name,branch ):
[Link] = name
[Link] = branch
c1 = College(“ldce", “computer”)
print([Link])
print([Link])
[Link]
[Link]
ml
[Link]
Reference books of PDS syllabus
Content of this presentation has been
prepared from various sources for teaching
purpose.