BRIGHT RIDERS SCHOOL
COMPUTER SCIENCE
PRACTICAL RECORD BOOK
GRADE: XI – XII
NAME: SIYAM SHAJI
CLASS: XI SECTION: B
ROLL NO. 26
BRIGHT RIDERS SCHOOL
Post Box No.
Tel. :
CERTIFICATE
This is to certify that the work entered in this journal is the
bonafied work of
Master. SIYAM SHAJI
Roll No. : 26 GR No. : 3664
Class: XI Division: B
Done in the school laboratory during the academic year 2024-
2025 as prescribed by the C.B.S.E, Delhi.
Date:
Teacher in
Charge
(Department)
Examiner:
Principal
INDEX
S. NAME OF THE WORK DATE PAGE REMARKS
No.
Program 1: Input a welcome message and display it.
Source Code:
welcome_message = "Welcome"
print(welcome_message)
Output:
Program 2: Input two numbers and display the larger / smaller
number.
Source Code:
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
if num1 > num2:
print("The larger number is:",num1)
print("The smaller number is:",num2)
elif num1 < num2:
print("The larger number is:",num2)
print("The smaller number is:",num1)
else:
print("Both numbers are equal.")
Output:
Program 3: Input three numbers and display the largest /
smallest number.
Source Code:
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
num3 = int(input("Enter the third number: "))
largest = max(num1, num2, num3)
smallest = min(num1, num2, num3)
print("The largest number is:", largest)
print("The smallest number is:", smallest)
Output:
Program 4: Generate the following patterns using nested loops:
Source Code:
# Pattern-1
print("Pattern-1:")
for i in range(1, 6):
print("*" * i)
# Pattern-2
print("\nPattern-2:")
for i in range(5, 0, -1):
for j in range(1, i + 1):
print(j, end="")
print()
# Pattern-3
print("\nPattern-3:")
for i in range(1, 6):
for j in range(1, i + 1):
print(chr(64 + j), end="")
print()
Output:
Program 5: Write a program to input the value of x and n and
print the sum of the following series:
Source Code:
x = int(input("Enter the value of x: "))
n = int(input("Enter the value of n: "))
# Series 1: 1 + x + x^2 + x^3 + ... + x^n
series_1 = 0
for i in range(n + 1):
series_1 += x**i
print("Sum of Series 1:", series_1)
# Series 2: 1 - x + x^2 - x^3 + ... + (-1)^n * x^n
series_2 = 0
for i in range(n + 1):
if i % 2 == 0:
series_2 += x**i
else:
series_2 -= x**i
print("Sum of Series 2:", series_2)
# Series 3: x + x^2/2 + x^3/3 + x^4/4 + ... + x^n/n
series_3 = 0
for i in range(1, n + 1):
series_3 += (x**i) / i
print("Sum of Series 3:", series_3)
# Series 4: x + x^2/2! + x^3/3! + x^4/4! + ... + x^n/n!
series_4 = 0
factorial = 1
for i in range(1, n + 1):
factorial *= i
series_4 += (x**i) / factorial
print("Sum of Series 4:", series_4)
Output:
Program 6: Determine whether a number is a perfect number,
an Armstrong number or a palindrome.
Source Code:
num = int(input("Enter a number: "))
sum_of_divisors = 0
for i in range(1, num):
if num % i == 0:
sum_of_divisors += i
if sum_of_divisors == num:
print(num ,"is a Perfect Number.")
else:
print(num ,"is not a Perfect Number.")
sum_of_powers = 0
temp = num
num_digits = len(str(num))
while temp > 0:
digit = temp % 10
sum_of_powers += digit ** num_digits
temp //= 10
if sum_of_powers == num:
print(num ,"is an Armstrong Number.")
else:
print(num ,"is not an Armstrong Number.")
if str(num) == str(num)[::-1]:
print(num ,"is a Palindrome.")
else:
print(num ,"is not a Palindrome.")
Output:
Program 7: Input a number and check if the number is a prime
or composite number.
Source Code:
num = int(input("Enter a number: "))
if num < 2:
print(num ,"is neither Prime nor Composite.")
else:
is_prime = True
for i in range(2, int(num ** 0.5) + 1):
if num % i == 0:
is_prime = False
break
if is_prime:
print(num ,"is a Prime Number.")
else:
print(num ,"is a Composite Number.")
Output:
Program 8: Display the terms of a Fibonacci series.
Source Code:
n = int(input("Enter the number of terms: "))
a, b = 0, 1
print("Fibonacci Series:")
for i in range(n):
print(a, end=" ")
a, b = b, a + b
Output:
Program 9: Compute the greatest common divisor and least
common multiple of two integers.
Source Code:
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
gcd = 1
for i in range(1, min(num1, num2) + 1):
if num1 % i == 0 and num2 % i == 0:
gcd = i
lcm = (num1 * num2) // gcd
print("The GCD of", num1, "and", num2, "is:", gcd)
print("The LCM of", num1, "and", num2, "is:", lcm)
Output:
Program 10: Count and display the number of vowels,
consonants, uppercase, lowercase characters in string.
Source Code:
st = input("Enter a string: ")
vowel_count = 0
consonant_count = 0
uppercase_count = 0
lowercase_count = 0
vowels = "aeiouAEIOU"
for i in st:
if i.isalpha():
if i in vowels:
vowel_count += 1
else:
consonant_count += 1
if i.isupper():
uppercase_count += 1
elif i.islower():
lowercase_count += 1
print("Vowels:", vowel_count)
print("Consonants:", consonant_count)
print("Uppercase letters:", uppercase_count)
print("Lowercase letters:", lowercase_count)
Output:
Program 11: Input a string and determine whether it is a
palindrome or not; convert the case of characters in a string.
Source Code:
text = input("Enter a string: ")
if text.lower() == text[::-1].lower():
print(text, "is a Palindrome.")
else:
print(text, "is not a Palindrome.")
converted_text = text.swapcase()
print("String with case converted:", converted_text)
Output:
Program 12: Find the largest/smallest number in a list/tuple.
Source Code:
# For a List
L=[2,5,25,50,20,9]
largest = max(L)
smallest = min(L)
print("Largest number:", largest)
print("Smallest number:", smallest)
#For a Tuple
T=(5,100,25,50,20,9)
largest = max(T)
smallest = min(T)
print("Largest number:", largest)
print("Smallest number:", smallest)
Output:
For the list: For the tuple:
Program 13: Input a list of numbers and swap elements at the
even location with the elements at the odd location.
Source Code:
n = int(input("Enter the number of elements: "))
numbers = []
for i in range(n):
num = int(input(f"Enter element {i + 1}: "))
numbers.append(num)
for i in range(0, len(numbers) - 1, 2):
numbers[i], numbers[i + 1] = numbers[i + 1], numbers[i]
print("Swapped list:", numbers)
Output:
Program 14: Input a list/tuple of elements, search for a given
element in the list/tuple.
Source Code:
# For a List
n = int(input("Enter the number of elements in the list: "))
elements = []
for i in range(n):
item = input("Enter element: ")
elements.append(item)
print(elements)
search_item = input("Enter the element to search for: ")
if search_item in elements:
print(search_item, "found at position", elements.index(search_item) + 1)
else:
print(search_item, "not found in the list.")
# For a Tuple
n = int(input("Enter the number of elements in the tuple: "))
elements = []
for i in range(n):
item = input("Enter element: ")
elements.append(item)
elements = tuple(elements)
print(elements)
search_item = input("Enter the element to search for: ")
if search_item in elements:
print(search_item, "found at position", elements.index(search_item) + 1)
else:
print(search_item, "not found in the list.")
Outputs:
For the list:
For the tuple:
Program 15: 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.
Source Code:
n = int(input("Enter the number of students: "))
students = {}
for i in range(n):
roll_number = input(f"Enter roll number for student {i + 1}: ")
name = input(f"Enter name for student {i + 1}: ")
marks = int(input(f"Enter marks for student {i + 1}: "))
students[roll_number] = {"name": name, "marks": marks}
print("\nStudents with marks above 75:")
for roll_number, details in students.items():
if details["marks"] > 75:
print(details["name"])
Output: