0% found this document useful (0 votes)
2 views2 pages

python

Uploaded by

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

python

Uploaded by

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

Experiment No 1

Name:- Rohit Vitthal Desai Roll no:- 06


Class:- SE(AIML) Sem:- 4th Sub:- Pyhton
****************************************************************
Aim:- Exploring basic of python like data types ( string, list, array,
dictionaries, set, tuples) & Control statement
Program 1:- String in Python
# Assingning the string to a variable
a="This is the string 1"
print(a)
b='This is the string 2'
print(b)
c='This is the string 3'
print(c)

Output:-
This is the string 1
This is the string 2
This is the string 3

Program 2:- List in python

#Declaring a list
lst=[6,"A1","Rohit",1+2]
print(lst)

#Adding ele to the list


lst.append(7)
print(lst)

#Deleting ele from list


lst.pop()
print(lst)

#Displaying second ele from list


print(lst[1])

Output:-
[6, 'A1', 'Rohit', 3]
[6, 'A1', 'Rohit', 3, 7]
[6, 'A1', 'Rohit', 3]
A1

Program 3:- Tuple in Python

#Declaring a Tuple
tup=(1,"a","string",1+2)
print(tup)

#Accessing the ele of tuple using index


print(tup[1])

Output:-
(1, 'a', 'string', 3)
a

Program 4:- Set in Python


#Creating a set
stu_id={122,124,126,128,130}
print(stu_id)

#displaying datatypes
print(type(stu_id))

Output:-
{128, 130, 122, 124, 126}
<class 'set'>

Program 5:- Dictionary in Python


#create a dictionary
capital_city={'Italy':'Rome','France':'Paris','England':'London'}
print(capital_city)

Output:-
{'Italy': 'Rome', 'France': 'Paris', 'England': 'London'}

Experiment No 2
Name:- Rohit Vitthal Desai Roll no:- 06
Class:- SE(AIML) Sem:- 4th Sub:- Pyhton
****************************************************************
Aim:- Creating function, classes & objects using python,
Demonstrate exception handling & inheritance

Program 1:- Function in Python

#simple python function


def fun():
print("Welcome to SSPM")

#Driver code to call a function


fun()

Output:-
Welcome to SSPM

Program 2:- Parameterize Function

#Declaring parameterize function


def add(num1:int,num2:int)->int:
num3=num1+num2
return num3

#Driver Code
num1, num2 = 5, 20
ans= add(num1,num2)
print(f"The addition of {num1} & {num2} is : {ans}")

Output:-
The addition of 5 & 20 is : 25

Program 3:- Prime Num

You might also like