Class 11 Practical File 2023 - 2024
Class 11 Practical File 2023 - 2024
2023 - 2024
Result:
Thus, the program was executed successfully and the output was verified
Run - 2:
Run - 3:
Result:
Thus, the program was executed successfully and the output was verified.
EX.NO.3 DISPLAY ADDED SUM OF TWO NUMBERS
Python program to input two numbers and add values.
Aim:-
To write a python program to input two numbers and add values
Algorithm:
Step 1: Input the value of num1and num2
Step 2: Add the two values
Step 3: Print the added values
Source code:-
Output:
Result:
Thus, the program was executed successfully and the output was verified.
Result:
Thus, the program was executed successfully and the output was verified.
Algorithm:
Step 1: Input a value n.
Step 2: check condition for i in range (1, n+1)
Step 3: check condition for j in range (1, i+1)
Step 4: print * and use separator.
Step 5: print the output.
Source Code:
n=5
for i in range (1,n+1):
for j in range(1,i+1):
print ("*",end =" ")
print ( )
Output:
Result:
Thus,the program was executed successfully and the output was verified.
Result:
Thus, the program was executed successfully and the output was verified.
Ex.No : 7 GENERATE NESTED LOOP PATTERN - III
Write a Python program to display the following pattern
Pattern - III
A
A B
A B C
A B C D
A B C D E
Aim:
To write a Python program to display left triangle alphabet pattern using nested loop.
Algorithm:
Step 1: Input a value n.
Step 2: check the condition for i in range (n)
Step 3: check the condition for j in range (i+1)
Step 4: print chr (j+65) and a separator
Step 5: print the output
Source Code:
n=5
for i in range (n):
for j in range (i+1):
print (chr(j+65),end=" ")
print( )
Output:
Result:
Thus, the program was executed successfully and the output was verified.
Ex.No : 8 SUM OF SERIES PATTERN -1 (1+ x+ x 2 + x 3 + x 4 … … x n ¿
Write a Python program to display sum of series:
Pattern- I
2 3 4 n
1+ x+ x + x + x … … x
Aim:
To write a Python program to input the value of x and n and print the sum of the
following series:1+ x+ x 2 + x 3 + x 4 … … x n
Algorithm:
Step 1: Input the value of x
Step 2: Input the value of n
Step 3: Initialize s=0 for calculating sum
Step 4: For a in range (n+1)
Step 5: s+=x**a to find sum of series
Step 6: print s
Source Code:
x= float (input ("Enter value of x :"))
n=int (input ("Enter the value of n :"))
s=0
for a in range(n+1):
s+=x**a
print ("sum of series", s)
Output:
Result:
Thus, the program was executed successfully and the output was verified.
Aim:
To write a Python program to input the values of x and n and print the sum of series.
2 3 4 n
(1−x+ x − x + x −… x )
Algorithm:
Step 1: Input value of x
Step 2: Input value of n
Step 3: Initialize s=0 for calculating sum
Step 4: for a in range(n+1)
Step 5: If a%2==0
Step 6: s+=x**a
Step 7: else: b-=**a
Step 8: print sum of series
Source Code:
x= float (input("Enter the value of x:"))
n=int (input("Enter the value of n:"))
s=0
for a in range (n+1):
if a%2==0:
s+=x**a
else:
s-=x**a
print ("Sum of series:", s)
Output:
Result:
Thus, the program was executed successfully and the output was verified
Result:
Thus, the program was executed successfully and the output verified.
2 3 4 n
x x x x
Ex.No : 11 SUM OF SERIES PATTERN - IV ( x + − + … )
2 ! 3 ! 4 ! n!
2 3 4 n
x x x x
Write a Python program to print the sum of the following series x + − + …
2 ! 3 ! 4 ! n!
Aim:
To write a Python program to input the value of x, n and print the sum of the following
series.
Algorithm:
Step 1: Input the value of x
Step 2: Input the value of n
Step 3: Initialize s=x
Step 4: For a in range (i, n+1):
Step 5: fact= fact *a
Step 6: if a % 2==0
Step 7: s+=(x**a) / fact (to find sum of element)
Step 8: else: s-=(x**a) / fact (to find sum of element)
Step 9: print sum of series
Source Code:
x= int(input("Enter value of x:"))
n=int(input("Enter value of n:"))
sum=x
sign=1
for i in range(2,n+1):
fact=1
for j in range(1,i+1):
fact=fact*j
term=((x**i)*sign)/fact
sum=sum+term
sign=sign*-1 # or sign *=-1
print(sum)
print("Sum of first",n, "terms:",sum)
Output:
Result:
Thus, the program was executed successfully and the output was executed successfully
and the output was verified.
Result:
Thus, the program was executed successfully and the output was verified.
Result:
Thus, the program was executed successfully and the output was verified.
Result:
Thus,the program was executed successfully and the output was verified.
Result:
Thus, the program was executed successfully and the output was verified.
Ex.No:16 FIBONACCI SERIES
Write a Python program to display the terms of Fibonacci series.
Aim:
To write a Python program to display the terms of Fibonacci series.
Algorithm:
Step 1: Input integer asking how many terms to be printed
Step 2: Initialize a, b=0, 1
Step 3: s= a + b
Step 4: print (a, b, end=" ")
Step 5: for i in range (n-2):
Step 6: print (a+ b, end=" ")
Step 7: swap the values by a, b=b, a + b
Step 8: sum of digits, s=s + b
Step 9: print sum of terms of series
Source Code:
num = int(input(“Enter no of terms”))
n1, n2 = 0, 1
print(“Fibonacci Series: “, n1, n2)
for i in range(2, num):
n3 = n1 + n2
n1 = n2
n2 = n3
print(n3, end=" ")
print()
Output:
Result:
Thus, the program was executed successfully and the output was verified.
Result:
Thus,the program was executed successfully and the output was verified.
Result:
Thus,the program was executed successfully and the output was verified.
Result:
Thus,the program was executed successfully and the output was verified.
Result:
Thus, the program was executed successfully and the output was verified.
Result:
Thus, the program was executed successfully and the output was verified.
Run 2
Result:
Thus, the program was executed successfully and the output was verified.
Algorithm:
Step 1: Create a empty list
Step 2: Enter five elements for the list
Step 3: Iterate till value to append element in the list
Step 4: If the element is in the list
Step 5: print element found at index and position
Source Code:
mylist=[]
print("Enter 5 elements for the list:")
for i in range(5):
value=int(input())
mylist.append(value)
print("Enter an element to be search:")
element=int(input())
for i in range(5):
if element==mylist[i]:
print("\n Element found at index:",i)
print("Element found at position",i+1)
Output:
Result:
Thus, the program was executed successfully and the output was verified.
Ex. No: 24 INPUT A LIST , FIND THE SMALLEST AND LARGEST NUMBER
Write a Python program to input a list of numbers and find the smallest and largest number
from the list.
Aim:
To write a Python program to input a list of numbers find the smallest and largest
number from the list.
Algorithm:
Step 1: Define find len(list)
Step 2: Find the length by using len( ) function
Step 3: Sort the values in the list
Step 4: Create list and call the function
Step 5: Print the largest and smallest element from the list
Source Code:
def find_len(list1):
length=len(list1)
list1.sort()
print("The largest element is:",list1[length-1])
print("The smallest element is:",list1[0])
print("The second largest element is:",list1[length-2])
print("The second smallest element is:",list1[1])
list1=[12,4,5,2,41,31,10,8,6,4]
largest=find_len(list1)
Output:
Result:
Thus, the program was executed successfully and the output was verified.
Ex. No : 25 CREATE DICTIONARY
Write a Python program, to create a dictionary with roll number, name and marks of n
students in a class.
Aim:
To write a Python program to create a dictionary with roll number, name and marks of n
students in a class and display the names of students who have scored above 75.
Algorithm:
Step 1: Enter number of students
Step 2: Create dictionary for result
Step 3: for i in range (no_of_std):
Step 4: Enter details of students
Step 5: Print result
Step 6: Display names of students who have got more than 75
Source Code:
no_of_std=int(input("Enter number of students:"))
result={}
for i in range(no_of_std):
print("Enter details of student number:",i+1)
roll_no=int(input("Roll no:"))
std_name=input("Student Name:")
marks=int(input("Marks:"))
result[roll_no]=[std_name,marks]
print(result)
for student in result:
if result[student][1]>75:
print("Student name who got more than 75 marks is/are",(result[student][0]))
Output:
Result:
Thus,the program was executed successfully and the output was verified.