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

Python Unit 1

The document is a syllabus for a Python programming course. It outlines 5 units that will be covered in the course: introduction to Python, strings and text files, lists, tuples and dictionaries, design with functions, and object-oriented programming concepts continued. It provides details on the topics that will be covered in each unit such as data types, operators, control flow, file manipulation, string operations, list and dictionary usage, functions, classes, inheritance and exceptions. It also lists a textbook that will be used.

Uploaded by

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

Python Unit 1

The document is a syllabus for a Python programming course. It outlines 5 units that will be covered in the course: introduction to Python, strings and text files, lists, tuples and dictionaries, design with functions, and object-oriented programming concepts continued. It provides details on the topics that will be covered in each unit such as data types, operators, control flow, file manipulation, string operations, list and dictionary usage, functions, classes, inheritance and exceptions. It also lists a textbook that will be used.

Uploaded by

SBS Movies
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

UNIT 1

UCS18601 - PYTHON
Mr. D.SIVA
ASSISTANT PROFESSOR
DEPARTMENT OF COMPUTER SCIENCE
SRM IST, RAMAPURAM

DEPARTMENT OF COMPUTER SCIENCE, SRM IST -


1
RAMAPURAM
Syllabus
UNIT I - INTRODUCTION (15 Hours)
Introduction to Python - The concept of data types; variables, assignments; immutable
variables; numerical types; arithmetic operators and expressions; comments in the
program; understanding error messages. Conditions, boolean logic, logical operators;
ranges; Control statements: if-else, loops (for, while); short-circuit (lazy) evaluation.
UNIT II - STRINGS AND TEXT FILES (15 Hours)
Manipulating files and directories, os and sys modules; text files: reading/writing text
and numbers from/to a file; creating and reading a formatted file (csv or tab-separated).
String manipulations: subscript operator, indexing, slicing a string; strings and number
system: converting strings to numbers and vice versa. Binary, octal, hexadecimal
numbers
UNIT III - LISTS, TUPLES AND DICTIONARIES (15 Hours)
Basic list operators, replacing, inserting, removing an element; searching and sorting
lists; dictionary literals, adding and removing keys, accessing and replacing values;
traversing dictionaries.

DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 2


Syllabus
UNIT IV - DESIGN WITH FUNCTIONS (15 Hours)
Hiding redundancy, complexity; arguments and return values; formal vs actual
arguments, named arguments.Program structure and design. Recursive functions.
Classes and OOP: classes, objects, attributes and methods; defining classes; design with
classes, data modelling; persistent storage of objects
UNIT V - OOPS CONTINUED (15 Hours)
Iinheritance, polymorphism, operator overloading (_eq_, _str_, etc); abstract classes;
exception handling, try block. Graphical user interfaces; event-driven programming
paradigm; tkinter module, creating simple GUI; buttons, labels, entry fields, dialogs;
widget attributes - sizes, fonts, colors layouts, nested frames.
TEXTBOOK
1. Kenneth A. Lambert, The Fundamentals of Python: First Programs, 2011, Cengage
Learning, ISBN: 978-1111822705

DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 3


INTRODUCTION

• Python is a high-level, interpreted and general


purpose dynamic programming language that
focuses on code readability.
• The language founded in the year 1991 by the
developer Guido Van Rossum has the
programming easy and fun to do.

DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 4


HISTORY OF PYTHON
Where was Python created?
Python was conceived in the late 1980s, and its implementation began in December 1989 by Guido van
Rossum at Centrum Wiskunde (Pronounce as viskulu meaning mathematics) & Informatica (CWI) in the
Netherlands as a successor to the ABC language (itself inspired by SETL) capable of exception handling
and interfacing with the Amoeba operating system.
What language is Python written in?
Since most modern OS are written in C, compilers/interpreters for modern high-level languages are also
written in C.Python is not an exception - its most popular/"traditional" implementation is called CPython
and is written in C. There are other implementations: IronPython (Python running on .NET).

DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 5


Where does the Python name come from?
When he began implementing Python,
Guido van Rossum was also reading the
published scripts from “Monty Python's
Flying Circus”, a BBC comedy series from
the 1970s. Van Rossum thought he needed
a name that was short, unique, and slightly
mysterious, so he decided to call the
language Python.
Python has top the charts in the recent years
over other programming languages like C, C++
and Java and is widely used by the programmers.
The language has undergone a drastic change
since its release 25 years ago as many add-on
features are introduced. The Python 1.0 had the
module system of Modula-3 and interacted with
Amoeba Operating System with varied
functioning tools. Python 2.0 introduced in the
year 2000 had features of garbage collector and
Unicode Support.
Python 3.0 introduced in the year 2008 had a constructive design that avoids duplicate modules and
constructs. With the added features, now the companies are using Python 3.5.
The software development companies prefer Python language because of its versatile features and fewer
programming codes. Nearly 14% of the programmers use it on the operating systems like UNIX, Linux,
Windows and Mac OS.
The programmers of big companies use Python as it has created a mark for itself in the software
development with characteristic features like:
Interactive
Interpreted
Modular
Dynamic
Object-oriented
Portable
High level
Extensible in C++ & C
The programmers of big companies use Python as it has created a mark for itself in the software
development with characteristic features like:
Easy-to-learn
Easy-to-read
Easy-to-maintain
Robust
Effective as a Rapid Prototyping Tool
A Memory Manager
Interpreted and (Byte-) Compiled
PYTHON ADVANTAGES - PLUS POINTS
01. Easy to Use.
02. Expressive Language.
03. Interpreted Language.
04. Its Completeness.
05. Cross Plat Form Language.
06. Free and Open Source.
07. Variety of Usage/Applications.
08. Interactive.
09. Modular.
10. Dynamic.
11. Object-oriented.
12. Portable.
13. High level.
14. Extensible in C++ & C.
PYTHON INTERPRETER
PYTHON DISTRIBUTION
A Python distribution is a software bundle, which contains a Python interpreter and the Python standard
library. Installer programs for common operating systems.
Aside from the official Cpython distribution available from python.org,other distributions based on Cpython
include the followings:
POPULAR PYTHON IDEs
Integrated Development Environment(IDE)
:What is an IDE?
An integrated development environment (IDE) is a software application that provides comprehensive facilities
to computer programmers for software development.An IDE normally consists of a source code editor, build
automation tools, and a debugger.Most modern IDEs have intelligent code completion.
What is Python IDE or IDLE?
IDLE (short for integrated development environment or integrated development and learning environment)
is an integrated development environment for Python, which has been bundled with the default
implementation of the language since 1.5.2b1. ... Pythonshell with syntax highlighting.
Python Data Types
Python Data Types
Data types are the classification or categorization of data items. Python supports the following built-in data
types.
1.Scalar Types
int: Positive or negative whole numbers (without a fractional part) e.g. -10, 10, 456, 4654654.
float: Any real number with a floating-point representation in which a fractional component is denoted by a
decimal symbol or scientific notation e.g. 1.23, 3.4556789e2.
complex: A number with a real and imaginary component represented as x + 2y.
bool: Data with one of two built-in values True or False. Notice that 'T' and 'F' are capital. true and false are not
valid booleans and Python will throw an error for them.
None: The None represents the null object in Python. A None is returned by functions that don't explicitly return
a value.
Python Data Types
2.Sequence Type
A sequence is an ordered collection of similar or different data types. Python has the following built-in sequence
data types:
String: A string value is a collection of one or more characters put in single, double or triple quotes.
List: A list object is an ordered collection of one or more data items, not necessarily of the same type, put in
square brackets.
Tuple: A Tuple object is an ordered collection of one or more data items, not necessarily of the same type, put in
parentheses.
3.Mapping Type
Dictionary: A dictionary Dict() object is an unordered collection of data in a key:value pair form. A collection of
such pairs is enclosed in curly brackets. For example: {1:"Steve", 2:"Bill", 3:"Ram", 4: "Farha"}
Python Data Types
4.Set Types
set: Set is mutable, unordered collection of distinct hashable objects. The set is a Python implementation of the
set in Mathematics. A set object has suitable methods to perform mathematical set operations like union,
intersection, difference, etc.
frozenset: Frozenset is immutable version of set whose elements are added from other iterables.
Mutable and Immutable Types
Some of these values can be modified during processing, but contents of others can't be altered once they are
created in the memory.
Numbers, strings, and Tuples are immutable, which means their contents can't be altered after creation.
On the other hand, items in a List or Dictionary object can be modified. It is possible to add, delete, insert, and
rearrange items in a list or dictionary. Hence, they are mutable objects.
Python Number Types:
Python supports three types of numeric data.
Int - Integer value can be any length such as integers 10, 2, 29, -20, -150 etc. Python has no restriction on the
length of an integer. Its value belongs to int
Float - Float is used to store floating-point numbers like 1.9, 9.902, 15.2, etc.
complex - A complex number contains an ordered pair, i.e., x + iy where x and y denote the real and imaginary
parts, respectively. The complex numbers like 2+14j, 2.0 + 2.3j, etc.
Python creates Number objects when a number is assigned to a variable. For example;
a=5
print("The type of a", type(a))
b = 40.5
print("The type of b", type(b))
c = 1+3j
print("The type of c", type(c))
Python Number Types:
Boolean
Boolean type provides two built-in values, True and False. These values are used to determine the given
statement true or false. It denotes by the class bool.
print(type(True))
print(type(False))
None
None is used to define a null value. It is not the same as an empty string, False, or a zero. It is a data type of the class NoneType object.
Assigning a value of None to a variable is one way to reset it to its original, empty state.
Example 1: print(type(None)) <class 'NoneType'>
Example 2:
◦ var = None if var is None:

print("var has a value of None")


else:
print("var has a value")
Python Variables and Assignment
Variables
Variables hold values. In Python, variables do not require forward declaration - all you need to
do is provide a variable name and assign it some value.
rules:
Variable names may contain letters, digits (0-9) or the underscore character _.
Variable names must begin with a letter from A-Z or the underscore _ character. Either
lowercase or uppercase letters are acceptable.
Variable names may not be a reserved word in Python.
Following the rules above, all of these variable assignments are legal:
>>> fish = 11 >>> something_longer_is_fine_2 = 15 >>> _wow_ = 13 >>> a1 = 14
The following variable names are not acceptable.
>>> `ticked = 1 >>> 7days = 'week' >>> day of week = 'Monday' >>> and = 'the winner is?'
Python Variables and Assignment
Assigning Values to Variables
Python variables do not need explicit declaration to reserve memory space. The declaration
happens automatically when you assign a value to a variable.
The equal sign (=) is used to assign values to variables.
The operand to the left of the = operator is the name of the variable and the operand to the
right of the = operator is the value stored in the variable.
example −
counter = 100 # An integer assignment
miles = 1000.0 # A floating point
name = "John" # A string
Python Variables and Assignment
Multiple Assignment
Python allows you to assign a single value to several variables simultaneously.
For example −
a=b=c=1
a,b,c = 1,2,"john"
Python's reserved words

and as assert break


class continue def del
elif else except False
finally for from global
if import in is
lambda None nonlocal not
or pass raise return
True try while with
yield
Python Installation on Windows
Downloading the Python 3 installer
1. Open a new tab on your browser and go to the link:
https://www.python.org/downloads/windows/
2. You’ll see under the heading of Python Releases for Windows, the link for the Latest Python 3 Release –
Python 3.x.x. (The latest right now is Python 3.9.0).
Latest Python 3 Release - Python 3.9.0
3. Scroll to the bottom and under the Files section, you’ll find links for various operating systems and their
versions. Select Windows x86-64 executable installer for 64-bit or Windows x86 executable installer for 32-bit.
Python Installation on Windows
Python Installation on Windows
1. After downloading the installer, all you need to do is to run it by double-clicking on the downloaded file.
Next, a dialog box appears.
2. Make sure to check the 2 boxes at the bottom of the dialog box.
Python Installation on Windows
3. Click Install Now.
Now you’ll have Python 3 installed on your system.
Search for IDLE on your windows search bar and open up IDLE (Python 3.8.2). A window appears on your
screen, this is your Python Shell. This is where you’ll run your code.
Python Interpreter: Shell/REPL
Python is an interpreter language. It means it executes the code line by line. Python provides a Python
Shell, which is used to execute a single Python command and display the result.
It is also known as REPL (Read, Evaluate, Print, Loop), where it reads the command, evaluates the
command, prints the result, and loop it back to read the command again.

Execute Python Script


As you have seen above, Python Shell executes a single statement.

To execute multiple statements, create a Python file with


extension .py, and write Python scripts (multiple statements).

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 29


Python Script/Scripting Mode
Using Script mode is quite easy, you have to write your code in a text file and save the particular file
with a ‘.py’ extension. .py stands for PYTHON. You can use any available text editor.
In a standard Python shell, you can simply click “FILE” then choose “NEW” or press “ctrl+N” to open a
blank script where you can input your code. Saving the code is quite is by pressing “Ctrl+S”. Similarly
running a script in it is as easy as pressing the key “F5”.
(Shell)Interactive mode vs Script Mode

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 30


Python - Basic Operators
Operators are special symbols in Python that carry out arithmetic or logical computation. The value that the
operator operates on is called the operand.

Types of Operator
Arithmetic Operators
Comparison (Relational) Operators
Assignment Operators
Logical Operators
Bitwise Operators
Membership Operators
Identity Operators

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 31


Python Arithmetic Operators
Operator Description Example
+ Addition Adds values on either side of the operator. a + b = 30
- Subtraction Subtracts right hand operand from left hand operand. a – b = -10

* Multiplication Multiplies values on either side of the operator a * b = 200

/ Division Divides left hand operand by right hand operand b/a=2


% Modulus Divides left hand operand by right hand operand and returns b%a=0
remainder
** Exponent Performs exponential (power) calculation on operators a**b =10 to the power 20

//Floor division Floor Division - The division of operands where the result is the 9//2 = 4 and 9.0//2.0 = 4.0, -11//3 = -4, -
quotient in which the digits after the decimal point are removed. 11.0//3 = -4.0
But if one of the operands is negative, the result is floored, i.e.,
rounded away from zero (towards negative infinity) −

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 32


Python Comparison Operators
Operator Description Example
== If the values of two operands are equal, then the condition becomes true. (a == b) is not true.

!= If values of two operands are not equal, then condition becomes true. (a != b) is true.

<> If values of two operands are not equal, then condition becomes true. (a <> b) is true. This is similar to
!= operator.
> If the value of left operand is greater than the value of right operand, then (a > b) is not true.
condition becomes true.

< If the value of left operand is less than the value of right operand, then condition (a < b) is true.
becomes true.

>= If the value of left operand is greater than or equal to the value of right operand, (a >= b) is not true.
then condition becomes true.

<= If the value of left operand is less than or equal to the value of right operand, (a <= b) is true.
then condition becomes true.

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 33


Python Assignment Operators
Operator Description Example

= Assigns values from right side operands to left side operand


c = a + b assigns value of a + b into
c

+= Add AND It adds right operand to the left operand and assign the
result to left operand
c += a is equivalent to c = c + a

-= Subtract AND It subtracts right operand from the left operand and assign
the result to left operand
c -= a is equivalent to c = c - a

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 34


Python Bitwise Operators
Bitwise operator works on bits and performs bit by bit operation. Assume if a = 60; and b = 13; Now
in the binary format their values will be 0011 1100 and 0000 1101 respectively.
Operator Description Example
& Binary AND Operator copies a bit to the result if it exists in both operands
(a & b) (means 0000 1100)

| Binary OR It copies a bit if it exists in either operand. (a | b) = 61 (means 0011 1101)


^ Binary XOR It copies the bit if it is set in one operand but not both.
(a ^ b) = 49 (means 0011 0001)

~ Binary Ones (~a ) = -61 (means 1100 0011 in 2's


Complement It is unary and has the effect of 'flipping' bits. complement form due to a signed binary
number.
<< Binary Left The left operands value is moved left by the number of bits specified by the
Shift right operand. a << 2 = 240 (means 1111 0000)

>> Binary Right The left operands value is moved right by the number of bits specified by the
Shift right operand. a >> 2 = 15 (means 0000 1111)

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 35


Python Logical Operators
Operator Description Example
and Logical AND If both the operands are true then condition becomes true. (a and b) is true.
or Logical OR If any of the two operands are non-zero then condition (a or b) is true.
becomes true.
not Logical NOT Used to reverse the logical state of its operand. Not(a and b) is false.

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 36


Python Membership Operators
Python’s membership operators test for membership in a sequence, such as strings, lists, or tuples. There are
two membership operators as explained below −

Operator Description Example a=2


b = 20
list = [1, 2, 3, 4, 5 ];
in Evaluates to true if it finds a
variable in the specified if ( a in list ):
x in y, here in results in a 1 if x
sequence and false print "Line 1 - a is available in the given list"
is a member of sequence y.
otherwise. else:
print "Line 1 - a is not available in the given list"
not in Evaluates to true if it does x not in y, here not in results in
not finds a variable in the a 1 if x is not a member of
specified sequence and sequence y.
false otherwise.

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 37


Python Identity Operators
Identity operators compare the memory locations of two objects. There are two Identity operators explained
below −

Operator Description Example Example Identity operators in Python


x1 = 5
y1 = 5
is Evaluates to true if the
x2 = 'Hello'
variables on either side
y2 = 'Hello'
of the operator point to x is y, here is results in 1 if
id(x) equals id(y). x3 = [1,2,3]
the same object and
y3 = [1,2,3]
false otherwise.
# Output: True
is not Evaluates to false if the
print(x1 is y1)
variables on either side x is not y, here is
of the operator point to not results in 1 if id(x) is
# Output: True
the same object and not equal to id(y). print(x2 is y2)
true otherwise.
# Output: False
print(x3 is y3)

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 38


Python break statement
The break is a keyword in python which is used to bring the program control out of the loop. The break statement breaks the loops
one by one, i.e., in the case of nested loops, it breaks the inner loop first and then proceeds to outer loops. In other words, we can
say that break is used to abort the current execution of the program and the control goes to the next line after the loop.
The break is commonly used in the cases where we need to break the loop for a given condition.
The syntax of the break is given below.
#loop statements
break;
Example 1
list =[1,2,3,4]
count = 1;
for i in list:
if i == 4:
print("item matched")
count = count + 1;
break
print("found at",count,"location");

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 39


Python continue Statement
The continue statement in Python is used to bring the program control to the beginning of the loop. The continue
statement skips the remaining lines of code inside the loop and start with the next iteration. It is mainly used for a
particular condition inside the loop so that we can skip some specific code for a particular condition.The continue
statement in Python is used to bring the program control to the beginning of the loop. The continue statement skips
the remaining lines of code inside the loop and start with the next iteration. It is mainly used for a particular condition
inside the loop so that we can skip some specific code for a particular condition.
Syntax
#loop statements
continue
#the code to be skipped
Example 1
i=0
while(i < 10):
i = i+1
if(i == 5):
continue
print(i)

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 40


Python Pass
In Python, the pass keyword is used to execute nothing; it means, when we don't want to execute code, the pass
can be used to execute empty. It is the same as the name refers to. It just makes the control to pass by without
executing any code. If we want to byp ass any code pass statement can be used.
It is beneficial when a statement is required syntactically, but we want we don't want to execute or execute it
later. The difference between the comments and pass is that, comments are entirely ignored by the Python
interpreter, where the pass statement is not ignored.
Suppose we have a loop, and we do not want to execute right this moment, but we will execute in the future.
Here we can use the pass.
Example - 1:
for letter in 'srmist':
pass
print("Last Letter :", letter)

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 41


else Clauses on Loops
In most of the programming languages (C/C++, Java, etc), the use of else statement
has been restricted with the if conditional statements. But Python also allows us to use
the else condition with loops.
it is executed when the loop terminates through exhaustion of the iterable (with for)
or when the condition becomes false (with while), but not when the loop is terminated
by a break statement.
Example :1
l=[3,7,9]
for ele in l:
if ele % 2 == 0:
print ("list contains an even number")
break
else:
print ("list does not contain an even number")

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 42


else Clauses on Loops
Example :2
count = 0
while (count < 1):
count = count+1
print(count)
break
else:
print("No Break")

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 43


Python range()
 The range() function is used to generate a sequence of numbers.
The range() type returns an immutable sequence of numbers between the given start integer to the
stop integer.
 There are three ways you can call range() :
range(stop) takes one argument.
range(start, stop) takes two arguments.
range(start, stop, step) takes three arguments.
range() Parameters :
start : It is an integer number that specifies the starting position. The Default value is 0.
stop : It is an integer that specifies the ending position.
step : It is an integer that specifies the increment of a number. The Default value is 1.
Most common use of range() function in Python is to iterate sequence type (List, string etc.. ) with for
and while loop.

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 44


Python range()
 Example : 1 - # printing a number
for i in range(10):
print(i, end =" ")
Output : 0 1 2 3 4 5 6 7 8 9
Example : 2 - printing a natural number from 5 to 20
for i in range(5, 20):
print(i, end =" ")
Output : 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Example : 3 - using range to print number # divisible by 3
for i in range(0, 30, 3):
print(i, end = " ")
Output : 0 3 6 9 12 15 18 21 24 27
Example : 5 - incremented by -4
for i in range(30, 1, -4):
print(i, end =" ")
Output : 30 26 22 18 14 10 6 2

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 45


Python range()
Points to remember about Python range() function :
range() function only works with the integers i.e. whole numbers.
All argument must be integers. User can not pass a string or float number
or any other type in a start, stop and step argument of a range().
All three arguments can be positive or negative.
The step value must not be zero. If a step is zero python raises a
ValueError exception.

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 46


short-circuit (lazy) evaluation
Short-circuit evaluation means that when evaluating Boolean expression like
AND and OR, you can stop as soon as you find the first condition which satisfies
or negates the expression.

Operation Result Description

x or y If x is false, then y else x Only evaluates the second argument(y) if the firs one is
false

x and y If x is false, then x else y Only evaluates the second argument(y) if the first one(x) is
True

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 47


Short circuit evaluation
Example 1 :
x=5
y = 10
if x > 6 or y < 20:
print('OK')

Example 2 :
x=5
y = 10
if x > 6 and y < 20:
print('OK')
Example 3 :
a=0
b=2
c=3
x = a or c
print(x)

04-02-2022 DEPARTMENT OF COMPUTER SCIENCE, SRM IST - RAMAPURAM 48

You might also like