Lab Assignment-07
Lab Assignment-07
NAME: HARSHIT
ROLL NO: B-90(U23CS077)
1) Write a program to demonstrate different data types in python.
a=5
b=5.2
c='c'
d="cars"
e=True
list=[1,2
]
set={1,2}
distnary={1:1,2:
2} touple=(1,2)
print("data type of a
is",type(a)) print("data type
of b is",type(b))
print("data type of c
is",type(c))
print("data type of d is",type(d))
print("data type of e is",type(e))
print("data type of list
is",type(list)) print("data type of
set is",type(set))
print("data type of distnary
is",type(distnary)) print("data type of
touple is",type(touple))
print("2+3=",2+3)
print("26-3=",26-3)
print("26/3=",26/3)
print("reminder(26/3)",26%3)
print("queotient(26/3)",26//
3)
3) Create a list and perform the following methods 1) insert() 2) remove() 3) append()
list=[1,2,3,4,5,6,7,8,9,10]
print("list=",lis
t) #insert
a=int(input("enter position at which you want to insert
num ")) b=int(input("enter what you want to insert "))
list.insert(a-1,b)
print("list=",lis
t) #remove
a=int(input(("enter the element which you want to remove
"))) list.remove(a)
print("list=",lis
t) #append
b=int(input("enter what u want to add at end
")) list.append(b)
print("list=",list)
list=[1,2,3,4,5,6,7,8,9,10]
print("list=",lis
t) #len
print("length of list=
",len(list)) #pop
a=int(input(("enter the position
of element which you want to
remove ")))
list.pop(a-1)
print("list=",lis
t) #clear
list.clear()
print("list=",lis
t)
5) Write a program to create, concatenate and print a string
string="web programming"
print("string=",string)
a=input("enter string which you wnat to add at the
end ") string=string+a
print("string=",string)
a=int(input("enter a num"))
b=int(input("enter another num"))
print("sum of two
num",a,"and",b,"=",a+b)
a=int(input("enter a num"))
if a>0:
print("num is
+ve") elif a<0:
print("num is -
ve") else :
print("num is
neither +ve nor -
ve i.e, zero")
8) Write a python program to find largest of three numbers
a=int(input("enter a num 1: "))
b=int(input("enter a num 2:
")) c=int(input("enter a num
3: ")) if (a>b and a>c):
print(a," is the largest
num") elif (b>a and b>c):
print(b," is the
num") else :
print(c," is the
largest num")
a=int(input("enter a num"))
s=0
for i in
range(1,a,1):
if(a%i==0):
s+=i
if(a==s):
print(a," is a perfect
num") else :
print(a," is not a
perfect num")
12) Python program to calculate grade of a student. Take in the marks of 5 subjects and display the grade.
CODE:-
sum=0
for i in range(1,6,1):
a=int(input("enter marks of subject"))
sum+=a
print("grade(avg) of the student is
",sum/5)
OUTPUT:-