Python Notes by Payal
Python Notes by Payal
Ans. Python is a simple general purpose, high level and object oriented programming language.
Python is an interpreted scripting language. Guido van Rossum is known as founder of Python
programming.
Features:-
Python Variables:-
Variable is a name that is used to refer to memory location. Python variable is also known as an
identifier and used to hold value. Variable names can be a group of both letters and digits, but they
have to begin with a letter or an underscore.
Identifier Naming:-
Variable are the example of identifier. An identifier is used to identify the literals and used in the
program.
1. The first character of the variable must be an alphabet or underscore (_).
2. All the character except the first character may be an alphabet of lower-case (a-z), upper-
case (A-Z) underscore or digits (0-9).
3. Identifier name must not contain any white space, or special character (!,@,#,%,^,&,*).
4. Identifier name must be similar to any keyboard define in the language.
5. Example of valid identifier: a123,_n,n_9 etc.
6. Example of invalid identifier: 1a,n%4,n 9 etc.
Object Reference:-
It is necessary to understand now the Python interpreter works when we declare a variable. The
process of treating variable is somewhat different from many other programming language.
Python is the highly object-oriented programming language.
Example:-
print(“payal”)
Output- payal
Example:-
Print(type(“payal”))
Object Identity:-
Id() function
Example:
a=50
b=a
print(id(a))
print(id(b))
Output-
140734982691168
140734982691168
Variable names:-
We have already discussed how to declare the valid variable. Variable names can
be any length can have uppercase(A to Z), lowercase(a to z), the digit (0-9) and underscore character
(_).
Example:-
name=”payal yadav”
age=20
marks=90
print(name)
print(age)
print(marks)
Output:-
payal yadav
20
90
Consider the following valid variables name:-
name=”A”
Name=”B”
naMe=”C”
NAME=”D”
n_a_m_e=”E”
_name=”F”
name_=”G”
na56me=”I”
print(name,Name,naMe,NAME,n_a_m_e,_name,name_,na56me)
Output:- A B C D E F G H I
Example:-
a=10
b=”Hi payal”
c=80.6
print(type(a))
print(type(b))
print(type(c))
Output:-
<type ‘int’>
<type ‘str’>
<type ‘float’>
Numbers:-
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))
print(“c is complex number”, is instance (1+3j, complex))
Output:-
Keyword:-
Python keyword are special reserved words that convey a special meaning to the
compiler/ Interpreter.
Python keywords:-
and:-
it is a logical operator. It is used to check the multiple condition.
A B Y=A and B
false false false
false true false
true false false
true true true
Or:-
It is a logical operator in python. It return true if one of the condition is true.
A B Y =A or B
false false false
false true true
true false true
true true true
not:-
It is a logical operator and inverts the truth value.
A =Ā
false true
true false
Python Literals:-
Python literals can be defined as data that is given in a variable or constant.
1. String literals:-
String is enclosed a text in the quotes. we can use both single as well as double quotes
to create a string.
Type of string:-
There are two types of string support in python.
a) Single-line string:-
String that are terminated with in a single line are known as single line string.
Example:-
Text 1= ‘payal’
b) Multi-line string:-
A piece of a text that is written in multiple line is known as multiple line string.
There are two way to create multiple string.
(i) (\) slash
Example:-
text1= ‘hello \
khushi’
print(text1)
Output:-
‘hello khushi’
2. Numeric Literals:-
Numeric Literals are immutable. Numeric literals can belong to following
four different numerical type.
(i)Integer (ii) float (iii) complex (iv) long integer
Example:-
x=ob1000 # Binary
y=100 # Decimal
z=oq215 #Octal
u=ox12d #Hexadecimal
# float Literal
float_1=100.5
float_2=1.5c2
#complex literal
a=5+3.14j
print(x,y,z,u)
print(float_1,float_2)
print(a,[Link],[Link])
output:-
20 100 141 301
100.5 150.0
(5+3.14j) 3.14 5.0
3. Boolean Literals:-
A boolean literal can have any of the two values. True or False.
Example:
x=(1==True)
y=(2==False)
z=(3==True)
a=True+10
b=False+10
print(“x is=”, x)
print(“y is=”, y)
print(“z is=”, z)
print(“a is=”, a)
print(“b is=”, b)
Output:-
x is True
y is False
z is False
a is 11
b is 10
4. Special Literals:-
Python contains one special literal i.e. None.
Example-
val1=10
val2=None
print(val1)
print(val2)
Output:-
10
None
5. Literal collection:-
Python provides four types of literal collection such as list literals,
Tuple literals, disc literals, set literals.
(a)list:-
List contain item of different data types. List are mutable i.e.
modifiable.
The values stored in list are separated by comma(,) and enclosed with
in square bracket([]). We can store different type of data in a list.
Example-
list=[‘payal’, 2005, 20.3,’yadav’]
list1=[2003,’sharma’]
print(list)
print(list+list1)
Output-
[‘payal’,2005,20.3,’yadav’]
[‘payal’,2005,20.3,’yadav’,2003,’sharma
’
(b) Dictionary:-
Python dictionary stores the data in the key- value pair.
It is enclosed by curly-braces {} and each pair is separated by
the comman(,).
Example-
dict={‘name’:’ravi’,’age’:24,’roll_no’:101}
print(dict)
Output-
{name:’ravi’,’age’:24,’roll_no’:101}
(c) Tuple:-
Python is a collection of different data type.
It is a immutable which means it cannot be modified after creation
It is enclosed by the parenthesis and each element is separated by
comma(,).
Example-
tup=(10,20,”rohit”,[2,3,4])
print(tup)
Output-
(10,20,’rohit’,[2,3,4])
(d)Set:-
Python set is collection of the unordered data set.
It is enclosed by the {} and each element is seprated by the comma(,).
Example-
Set={‘apple’,’grapes’,’guava’,’papaya’}
print(set)
Output-
{‘guava’,’apple’,’papaya’,’grapes’}
OPERATORS
The operator can be defined as a symbol which is responsible for a particular operation b/w two
operands. Operator are the pillars of a program on which the logic is built in a specific programming
language.
Arithmetic operator
Comparison operator
Assignment operator
Logical operator
Bitwise operator
Membership operator
Identity operator
Arithmetic operator:-
Arithmetic operator are used to perform arithmetic operation between two
operands. It included +(addition), -(subtraction), *(multiplication), /(divide),% (remainder),
//(forward) and **(exponent) operator.
Operator Description
+ It is used to add two operands. For example if a=20, b=10 a+b=30
- It is used to subtraction the second operand from the first operand .
if the first operand is less than the second operand , the value result
negative for example- if a=20, b=10 then a-b=10
/ It return the quotient after dividing the first operand by the second
operand . for example a=20, b=10 then a/b=10
* It is used to multiply one operand with the other . for example if
a=20, b=10 then a*b=200
% It return the remainder after dividing the first operand by the
second operand . for example if a=20, b=10 then a%b=0
** It is an exponent operator represented as it calculates the first
operand power to second operand
// It given the float value of the quotient produced by dividing the two
operand.
Comparison operator:-
Comparison operator are used to compare the value of the two
operands and returns Boolean true or false accordingly. The comparison operator are
described in the following table.
operator Description
== If the value of two operands is equal then the condition become
true.
!= If the value of the operands is not equal then the condition
become true.
<= If the first operands is less than or equal to the second operand,
then the condition become true.
>= If the first operands is greater than or equal to the second
operand, then the condition become true.
> If the first operands is greater than the second operand, then
the condition become true.
< If the first operands is less than the second operand, then the
condition become true.
Assignment operator:-
The assignment operator are used to assign the value of the right
expression the left operand. The assignment operator are described in the following table.
operator Description
= It assigns the value of the right expression to left operand.
+= It increases the value of the left operand by the value of the right
operand and assigned the modified value back to left operand. For
example if a=10 and b=20 then a+=b and therefor a=30
*-= It decreases----- a=20, b=10 then a-=b, a=10
*= It multiplies ------a=10, b=20 then a*=b, a=200
%= It devide the value of the left operand by the value of high operand and
assign the remainder back to the left operand .
For example a=20, b=10 then a%=b , a=0
**= a**b= will be equal to a=a//b , for example if a=4 ,b=2, a**=b will assign
4**2=16 to a
//= a//=b will be equal to a=a//b for example if a=4,b=3, a//=b will assign
4//3=1 to a
Bitwise operator:-
The bitwise operator perform bit by bit operation on the value of the two
operands.
Example-
if a=7
b=6
then, binary(a)=0111
binary(b)=0110
hence, a&b=0011
a|b =0111
a^b =0100
~a=1000
operator Description
&(binary and) If both the bit at the same place in two operand are 1
then 1 is copied to the result otherwise 0 is copied
|(binary or) The resulting bit will be 0 if the both bits are zero
otherwise the resulting bit will 1.
^ (binary xor) The resulting bit will be one(1) if both the bits are
different; otherwise the resulting bit will be 0.
~(negation) The left operand value is moved left by the number of
bits present in the right operand.
<<(left shift) The left shift operand value is moved left by the number
of bits present of bits present in the right operand.
Logical operator:-
The logical operator are used primary in the expression evaluation to
make a decision. Python support the following logical operators.
operator Description
and If both the expression are true, then the condition will
be true, if a and b are the two expression, a=true and
b=true therefor a and b=true
or If one of the expression is true, then the condition will
be true, if a and b are the two expression a=true and
b=false then a or b=true
Not If an expression a is true, then not (a) will be false and
vice-verse.
Membership operator:-
Python membership operator are used to check the membership of
value inside a python data structure. If the value of is present in the data structure, then the
resulting value is true otherwise its return false.
operator Description
in It is evaluated to be true if the first operand is found in the
second operand (list, tuple or dictionary)
not in It is evaluated to be true if not found in the second operand
(list, tuple dictionary)
Python Comment:-
Example-
Comperision operator
a=10
b=20
print(‘a<b:’, a<b) Output:-
a<b :true
a>b: false
a<=b :true
a>=b :false
a==b :false
a!=b :true
print(‘a>b:’, a>b)
print(‘a<=b:’, a<=b)
print(‘a>=b:’, a>=b)
print(‘a==b:’,a==b)
print(‘a!=b:’,a!=b)
a) And(&)
Output-
True
False
False
False
b) Or(|)
True | True
True |False
False| True
False| False
Output-
True
True
True
False
c) Not
not True
not False
not 15>13
not((15>13)and(15>2))
not(15>13 and 15<33)
not(15<13 and 15<33)
output-
False
True
False
False
False
True
OR operator:- execution-
Example- 10=1010
bin(10) 3=0011
bin(3) 10&3 1010
10 &|3 |
0011
Output- 11 decimal
‘0b1010’
‘0b11’
11
Output-
‘0b1010’
1
Conditional Statement
Example-
x=100
y=200
if(x>y):
print(“x is less than y”)
Output-
x is less then y
Example-
X=int(input(“enter value of n”))
If(x>0):
Print(“number is positive”)
elif(x<0)
print(“number is negative”)
Output:-
enter value of n:5
number is positive
Example-
Find biggest value of given 2 number from the command line.
output-
enter value of a: 10
enter value of b:8
a is greater
Example-
Find biggest value of given 3 numbers from the command line.
output-
enter value of a: 10
enter value of b:20
enter value of c:15
b is greater
Example-
Find your grade, above 90-grade A+, above 80-grade A, above 70- grade b,
above 60-grade c, otherwise fail.
Grade=int(input(“enter marks:”))
if grade>90:
print(“A+”)
elif grade>80:
print(“A”)
elif grade>70:
print(“b”)
elif grade>60:
print(“c”)
else:
print(“fail”)
output-
enter marks:90
A
Example-
Find given year is leap year or not.
year=int(input(“enter year:”))
if year%400==0:
print(“leap year”)
elif year%100==0:
print(“not leap year”)
elif year%4==0:
print(“year is leap year”)
else:
print(“not leap year”)
output-
enter year:2005
not leap year
LOOP
The flow of program written in any programming language is sequential by default.
Sometimes we may need to alter the program. The execution of a specific code may need to
be executed repeated several number of times.
Types of loops-
While loop:-
Syntax
While expression:
statement
Example-
Print 1 to 5 natural number.
i=1
while i<=5:
print(i)
i=i+1
Output-
1
2
3
4
5
Example
Print write a program to find sum of 10 natural number.
i=1
sum=0
while i<=10:
sum=sum+i
i=i+1
print(sum)
output-
55
Example
write a program to find sum of even number between 1 to 10 natural
number.
i=1
sum=0
while i<=10:
if(i%2==0)
sum=sum+i
i=i+1
print(sum)
output-
30
Example-
Program to print table of given numbers.
output-
5*1=5
5*2=10
5*3=15
5*4=20
5*5=25
5*6=30
5*7=35
5*8=40
5*9=45
5*10=50
Break statement:-
i=1
while i<=5:
print(i)
i=i+1
if(i==3):
break
else:
print(“the while loop executed”)
output-
1
2
Continue statement:-
i=0
while i<=10:
i=i+1
if i==5:
continue
print(i)
PATTERN
* i=1
** while i<=5:
*** print(“*”*i)
**** i=i+1
*****
******
***** i=6
**** while i>=1:
*** print(“*”*i)
** i=i-1
*
Example:-
str=”payal”
for x in str:
print(x)
output-
p
a
y
a
l
Example-
print(“using two argument in range()”)
for i in range(10,20):
print(i, end=’,’)
output-
using two argument in range()
10,11,12,13,14,15,16,17,18,19
Print odd number between 1-100 natural number.
output-
* n=int(input(“enter number:”))
*** for i in range(1,n+1):
**** for j in range(1,i+1):
***** print(“*”,end=” ”)
print()
n=int(input(“enter no of rows:”)) *
for i in range(1,n+1): **
print(“ ”*(n-i),end=” “) ***
print(“*” *i) *****
******
for(col in range(6): * * *
print(“*”,end=” “) * *
else:
print(end=” ”)
print()
1 for i in range(1,6):
12 for j in range(1+i+1):
123 print(j, end=” “)
1234 print();
12345
1
22 for i in range(1,6):
333 for j in range(1,i+1):
4444 print(i, end=” “)
55555 print();
Write a program to display * pattern.
* for i in range(1,6):
** for j in range(1,i+1):
*** print(“*”, end=” “)
**** print()
***** for i in range(4,0,-1):
**** for j in range(1,i+1):
*** print(“*”, end=” “)
** print()
*
1 x=1
23 for i in range(1,5):
456 for j in range(1,i+1):
78910 print(x, end=” “)
x=x+1
print()
Break Statement:-
Wap to use of break statement inside for loop.
for i in range(10):
print(“i value:”,i)
if(i==4)
break
output-
i value: 0
i value: 1
i value:2
i value:3
i value :4
Pass statement:-
for a in ‘python’:
if a==’h’
pass
print(“current letter:”,a)
print(“good bye!)
output-
current letter:p
current letter:y
current letter:t
current letter:h
current letter:o
current letter:n
good bye!
for i in range(1,n):
print(“hello”)
f=1
for i in range(n,0,-1):
f=f*i
print(“factorial of”,n,”is=”,f)
while loop
i=1
while i<=n:
print(“payal”)
i=i+1
i=1
while i<=100:
if i%2==0:
print(i)
i=i+1
Write a program to find sum & avg of n number.
else:
print(“C”)
List is order collection in python. If we want to represent a group of individual object as a single
entity where insertion order preserved and duplicates are allowed then we should go for list.
Output-
[]
<class ‘list’>
list1=[10,20,30,40]
list2=[‘a’,’b’,’c’,’d’]
list3=[True, False]
print(list1)
print(list2)
print(list3)
list=eval(input(“enter list:”))
print(list)
Output-
Output-
list=[“apple”,”banana”,”pine”]
print(list)
Output-
[‘apple’,’banana’,’pine’]
list=[1,2,4,4,3,3,3,6,5]
print(list)
Output-
[1,2,4,4,3,3,3,6,5]
7) Creating a list with mix type of values.
list=[101,’payal’,5.6,True,(1+2j)]
print(list)
Output-
[101,’payal’,5.6,True,(1+2j)]
#empty list
Print(list())
#vowel string
s= ’Be a master’
print(s)
#vowel list
Vowel list=[‘a’,’e’,’I’,’o’,’u’]
Print(list(vowel list))
Output-
[]
[‘B’,’e’,’ ’,’a’,’ ‘,’m’,’a’,’s’,’t’,’e’,’r’]
[‘a’,’e’,’i’,’o’,’u’]
Output-
[‘one’,’two’,’three’]
a,b,c= [Link](‘,’)
a
‘one’
b
‘two’
c
‘three’
Accessing element from the list:-
Example 1:
Accessing of element from using positive index.
list=[“apple”,”banana”,”mango”]
print(list)
print(“accessing a element from the list”)
print(“1st [0]:” , list[0])
print(“1st [1]:” ,list[1])
print(“1st [2]:” ,list[2])
Output-
[‘apple’,’banana’,’mango’]
Accessing a element from the list
1st [0]: apple
1st [1]:banana
1st [2]:mango
Example 2:
Accessing of element from using negative index.
a=[“apple”,”banana”,”mango”]
print(a)
print(“a[-1]:” , a[-1])
print(“a[-2]:” ,a[-2])
print(“a[-3]:” ,a[-3])
Output-
[‘apple’,’banana’,’mango’]
a[-1]:mango
a[-2]:banana
a[-3]:apple
Example 3:
Accessing of element from list using looping.
a=[“apple”,”banana”,”mango”]
print(a)
for i in range(0,len(a)):
print(i,”:”, a[i])
Output-
[‘apple’,’banana’,’mango’]
0:mango
1:banana
2:apple
Example 4:
Accessing of element from a multi-dimensional list.
Output-
Example 5:
Addition of elements in a list.
a=[ ]
print(“blank list:”)
print(a)
[Link] (10)
[Link] (20)
[Link] (30)
print (“after addition of three elements:”)
print (a)
Output-
blank list:
[]
after addition of three elements:
[10.20,30]
Example 6:
Addition of elements from 10-19 in list.
a=[ ]
for i in range (10,20):
[Link](i)
print(a)
Output-
Example 7:
Adding element to the list to a list.
a=[ ]
[Link](i)
print(a)
b=[‘apple’,’boy’]
[Link](a)
print(b)
Output-
Example 8:
Using insert, addition of element specific position.
a=[100,200,300]
[Link](1,400)
print(a)
[Link](2,”your name”)
Output-
[100,200,300]
[100,400,’your name’,200,300]
Example 9:
Addition of multiple elements using extend methods.
a=[1,2,3,4,5]
[Link]([6,7,8])
print(a)
Output-
[1,2,3,4,5,6,7,8]
Example 10:
Removing element from a list . (Remove())
a=[10,20,30,40]
print(a)
[Link](30)
print(a)
Output-
[10,20,30,40]
[10,20,40]
Example 11:
If the specified element not present in list we will get an error message.
a=[10,20,30,40]
print(a)
[Link](40)
print(a)
Output-
[10,20,30,40]
[10,20,30]
Example 12:
Write a program to remove element in python.
a=[10,20,30]
print(a)
[Link]()
print(a)
[Link]()
print(a)
[Link]()
print(a)
Output-
[10,20,30]
[10,20]
[10]
[]
Example 13:
Order list element of list:- (reverse())
a=[10,20,30,40]
print(“before reversing list items”)
print(a)
[Link]()
print(“after reversing list item”)
print(a)
Output-
Example 14:
a=[‘a’,’b’,’c’,’d’]
print(“before reversing list items”)
print(a)
[Link] ()
print(“after reversing list items”)
print(a)
Output-
Example 15:
Syntax-
str=’payal’
print(list(reversed(str)))
print(‘p’,’a’,’l’,’u’)
rng=range(1,5)
print(list(reversed(rng)))
list=[1,2,4,3,5]
print(list(reversed(list)))
Output-
[‘l’,’a’,’y’,’a’,’p’]
[‘u’,’l’,’a’,’p’]
[4,3,2,1]
[5,3,4,2,1]
sort():
syntax:- [Link](key=…,reverse=…)
Example 16:
x=[2,5,3,90,12]
[Link]()
print(x)
Output-
[2,3,5,12,90]
Example 17:
Reverse using sort()
num=[70,50,60,1,20]
[Link](reverse=True)
print(num)
Output-
[70,60,50,20,1]
Example 18:
Concatenation (+)
x=[10,20,30]
y=[40,50,60]
z=x+y
print(z)
Output-
[10,20,30,40,50,60]
Example 19:
Repetition operator (*)
x=[10,20,30]
z=x*3
print(z)
Output-
[10,20,30,10,20,30,10,20,30]
Tuple
Tuple is a collection of python objects separated by commas. Tuple is exactly same as list expect that
is immutable.
Properties:-
Example-
I. Create a tuple
thistuple=(“dca”,”dca”,”dcaa”,”pgdca”)
print(“thislist) Note:- Allow Duplication
Output-
(‘dca’,’dca’,’dcaa’,’pgdca’
thistuple=(“apple”,”banana”,”mango”)
print(len(thistuple)
Output-
thistuple=(‘apple’,’banana’,’charry’)
print(thistuple[1])
Output-
banana
IV. Negative Index-
thistuple=(‘apple’,’banana’,’charry’)
print(thistuple[-1])
Output-
Cherry
V. Range of index-
thistuple=(“apple”,”banana”,”orange”,”cherry”,”kiwi”)
print(thistuple(2:5)
Output-
(‘orange’,’cherry’,’kiwi’)
x=(“apple”,”banana”,”cherry”)
y=list(x)
y[i]=”kiwi”
x=tuple(y)
print(x)
Output-
‘apple’,’banana’,’cherry’,’kiwi’
VIII. Convert the tuple into a list, add “orange”, and convert other document building blocks.
When you create pictures, charts, or diagrams, they also coordinate back into tuple.
thistuple=(“apple”,”banana”,”cherry”)
y=list(thistuple)
[Link](“orange”)
thistuple=tuple(y)
print(thistuple)
Output-
(‘apple’,’banana’,’cherry’,’orange’)
Output-
(‘banana’,’cherry’)
X. Unpack Tuple:-
fruits=(“apple”,”banana”,”cherry”)
a,b,c=fruits
print(a)
print(b)
print(c)
Output-
apple
banana
cherry
fruits=(“apple”,”banana”,”cherry”,”mango”,”strawberry”)
(green,yellow,*red)=fruits
print(green)
print(yellow)
print(red)
Output-
apple
banana
[‘cherry’,’mango’,’strawberry’]
thistuple=(“apple”,”banana”,”cherry”)
for x in thistuple:
print(x)
Output-
apple
banana
cherry
XIII. Check length using while loop.
thistuple=(“apple”,”banana”,”cherry”)
i=0
while i<=len(thistyple):
print(thistuple[i])
i=i+1
Output-
apple
banana
cherry
tuple1=(“a”,”b”,”c”)
tuple2=(1,2,3)
tuple3=tuple1+tuple2
print(tuple3)
Output-
‘a’,’b’,’c’,1,2,3
fruits=(“apple”,”banana”,”mango”)
multiply=fruits*2
Print(multiply)
Output-
‘apple’,’banana’,’mango’,’apple’,’banana’,’mango’
SETS
Set is a class treated as data type. A set data type represent unorder collection of elements or to
represent a group of unique value as a single entitiy then we should go for set data type.
Properties:-
Example-
thisset={“apple”,”banana”,”mango”}
print(thisset) note:-refresh page change result
Output-
{‘apple’,’banana’,’mango’}
thisset={“apple”,”banana”,”cherry”,”apple”}
Print(thisset)
Output-
{‘apple’,’cherry’,’banana’}
thisset={“apple”,”banana”,”cherry”}
Print(len(thisset))
Output-
output-
{‘apple’,’banana’,’mango’}
{1,3,5,7,9]
{flase,True}
Tuple()
Syntax: <class ‘set’>
myset={“apple”,”banana”,”mango”}
print(type(myset))
Output-
<class ‘set’>
thisset=set((“apple”,”banana”,”cherry”))
print(thisset)
Output-
{‘cherry’,’apple’,’banana’}
Access Items:
thisset={“apple”,”banana”,”cherry”}
for x in this set:
print(x)
Output-
Apple
Banana
cherry
thisset={“apple”,”banana”,”cherry”}
print(“banana” in thisset)
Output-
True
Add()-
thisset={“apple”,”banana”,”mango”}
[Link](“orange”)
print(thisset)
Output-
{‘banana’,’apple’,’mango’,’orange’}
Add set()-
thisset={“apple”,’banana”,”cherry”}
tropical={“pineapple”,”mango”,”papaya”}
[Link](tropical)
Output-
{‘apple’,’cherry’,’pineapple’,’mango’,’papaya’}
thisset={“apple”,’banana”,”cherry”}
mylist={“kiwi”,”orange”}
[Link](mylist)
print(thisset)
Output-
{‘banana’,’cherry’,’apple’,’orange’,’kiwi’}
thisset={“apple”,’banana”,”cherry”}
[Link](“banana”)
print(thisset)
Output-
{‘apple’,’cherry’}
set1={“a”,”b”,”c”}
set2={1,2,3}
set3=[Link](set2)
print(set3)
Output-
{‘b’,2,’a’,1,’c’,3}