Class 11 - Cs - Record Model Exp - 13-20
Class 11 - Cs - Record Model Exp - 13-20
Aim:
Algorithm:
Program:
def simpleInterest(principal,time=2,rate=0.10):
return(principal*time*rate)
print(simpleInterest(6100,1))
print(simpleInterest(5000,rate=0.05))
print(simpleInterest(5000,3,0.12))
print(simpleInterest(time=4,principal=5000))
Output :
610.0
500.0
1800.0
2000.0
Result:
Aim:
To write a python program to calculate the area of circle, rectangle & triangle,
Algorithm:
Program:
def area_of_circle(radius):
pi = 3.14159
def main():
print("1. Circle")
print("2. Rectangle")
print("3. Triangle")
choice = int(input("Enter your choice (1/2/3): "))
if choice == 1:
elif choice == 2:
elif choice == 3:
else:
if __name__ == "__main__":
main()
Aim:
Algorithm:
Program:
import random
def generate_otp(length=6):
otp = ""
for i in range(length):
otp = otp+ str(random.randint(0, 9)) # Generate a random digit and add to OTP
return otp
# Main program
otp = generate_otp(length)
Output:
Enter the length of OTP (default is 6): 6
Your OTP is: 434792
Aim:
To write a python program that accepts the mass of an object and determines its energy.
Algorithm:
Program:
import math
m=float(input("Enter Mass:"))
c=3*pow(10,8)
e=m*c*c
Output:
Enter Mass:8.95
Result:
Aim:
Algorithm:
Program:
for el in tup:
if tup.count(el)>1:
break
Output:
Result:
Aim:
To write a python program to input the names of n students and store them in a tuple. Also,
input a name from the user and find if this student is present in the tuple or not.
Algorithm:
Program:
lst=[]
for i in range(1,n+1):
lst.append(name)
ntuple=tuple(lst)
if nm in ntuple:
else:
Result:
Aim:
To write a python program to create a dictionary with the roll number, name and marks of n
students in a class and display the names of students who have marks above 75.
Algorithm:
Program:
stu={}
for i in range(1,n+1):
name=input("Enter Name:")
marks=float(input("Marks:"))
key="stu" + str(i)
stu[key]=d
for i in range(1,n+1):
key="stu" + str(i)
if stu[key]["Marks"] >=75:
print(stu[key])
Output:
Enter Name:Rathi
Marks:78
Enter Name:Bala
Marks:98
Enter Name:Zulfy
Marks:65
Enter Name:Sara
Marks:78
Result:
Aim:
To write a python program to create a third dictionary from two dictionaries having some
common keys, in ways so that the values of common keys are added in the third dictionary.
Algorithm:
Program:
dct1={'1':100,'2':200,'3':300}
dct2={'1':100,'2':200,'5':400}
dct3=dict(dct1)
dct3.update(dct2)
if i==x:
dct3[i]=(j+y)
print(dct1)
print(dct2)
Output:
Result: