Progrm
Progrm
print(usn,"\t",name,"\t",total,"\t",percentage)
if percentage<35:
else:
print("Result : ")
printResult()
OUTPUT1:
Enter USN : 12
Result :
12 Mark 208 69
OUTPUT2:
Enter USN : 11
Result :
11 James 49 16
def getPersonDetails(self):
def printResult(self):
self.age=(int)(2023-self.year)
print(self.age,"year")
if self.age>65:
else:
S1=Person()
S1.getPersonDetails()
print("age is : ")
S1.printResult()
OUTPUT1:
age is :
3 year
OUTPUT2:
age is :
78 year
n1, n2 = 0, 1
count = 0
if nterms <= 0:
elif nterms == 1:
print(n1)
else:
print("Fibonacci sequence:")
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
OUTPUT:
Enter N? 5
Fibonacci sequence:
3
def binomialCoeff(n, k):
if k > n:
return 0
if k == 0 or k == n:
return 1
factorial = 1
if n < 0:
elif n== 0:
else:
factorial = factorial*i
OUTPUT:
Enter a number N: 5
Enter value of K: 2
lst = []
ele = int(input())
OUTPUT:
mean is 3.0
variance is 2.0
dict = {}
for n in str1:
keys = dict.keys()
if n in keys:
dict[n] += 1
else:
dict[n] = 1
return dict
print(char_frequency(str1))
OUTPUT:
d =dict()
forline intext:
line =line.strip()
line =line.lower()
forword inwords:
ifword ind:
d[word] =d[word] +1
else:
d[word] =1
forkey inlist(d.keys()):
OUTPUT:
mango : 3
banana : 3
apple : 3
pear : 2
grapes : 1
strawberry : 2
kiwi : 1
def DivExp(a,b):
try:
c=a/b
print("Quotient:",c)
except ZeroDivisionError:
print("Division by Zero!")
result=(DivExp(a,b))
OUTPUT:
Division by Zero!
class Complex:
self.real = tempReal;
self.imaginary = tempImaginary;
temp=Complex(0, 0)
return temp;
if __name__=='__main__':
C1 = Complex(3, 2);
C2 = Complex(9, 5);
C3 = Complex(0, 0)
C3 = C3.addComp(C1, C2);
OUTPUT:
Complex number 1 : 3 + i2
Complex number 2 : 9 + i5
def printResult(self):
print(self.usn,self.name,self.total,self.percentage)
if self.percentage<35:
else:
S1=Student()
S1.getStudentDetails()
print("Result : ")
S1.printResult()
OUTPUT1:
Enter USN : 12
Result :
12 Mark 208 69
OUTPUT2:
Enter USN : 11
Result :
11 James 49 16
student James has failed