0% found this document useful (0 votes)
27 views17 pages

CS Record File (By Rahil)

Uploaded by

Rahil YT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views17 pages

CS Record File (By Rahil)

Uploaded by

Rahil YT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

COMPUTER SCIENCE

PRACTICAL RECORD FILE

SUBMITTED BY:

NAME: Rahil Tekwani


CLASS: 11-B
Academic Year: 2024-2025
CERTIFICATE

Roll No: 30

This is to Certify that, Master Rahil Tekwani of Grade 11, Sec B


has carried out the Record File Programs in Computer Science
as prescribed by the Central Board of Secondary Education,
New Delhi during the Academic Year, 2024 – 2025.

Teacher-In Charge : Mr. Yadav Janardan Singh

Date :

Internal Examiner External Examiner


INDEX
QUESTION 1

print("1. Area and perimeter of a circle")


print("2. Area and perimeter of a rectangle")
print("3. Convert temperature from °F to °C and vice versa")
print("4. Calculate simple and compound interest")
choice = int(input("Enter a choice (from 1 to 4): "))
if choice == 1:
r = int(input("Enter the radius: "))
area = 3.14*r*r
perimeter = 2*3.14*r
print("The area is: ",area)
print("The perimeter is: ",perimeter)
elif choice == 2:
l = int(input("Enter the length: "))
b = int(input("Enter the breadth: "))
area = l*b
perimeter = 2*(l+b)
print("The area is: ",area)
print("The perimeter is: ",perimeter)
elif choice == 3:
c = int(input("Enter the temperature in °C: "))
ctof = ((9/5)*c + 32)
print("The temperature in °F is: ",ctof)
f = int(input("Enter temperature in °F: "))
ftoc = (f-32)*5/9
print("The temperature in °C is: ", ftoc)
elif choice == 4:
P = int(input("Enter the principle amount: "))
R = int(input("Enter the rate of interest: "))
T = int(input("Enter time (in years): "))
SI = (P*R*T)/100
print("The Simple Interest is: ",SI)
n = int(input("The number of times it is compounded: "))
CI = P*(1 + R/n)**(n*T)
print("The Compound Interest is: ",CI)
else:
print("Invalid choice")
QUESTION 2

import math
print("1. Check whether a number is even/odd")
print("2. Check whether a number is prime/composite")
print("3. To calculate the factorial of the given number")
print("4. To print the multiplication table of a number")
choice = int(input("Enter a choice (from 1 to 4): "))
if choice == 1:
num = int(input("Enter a number: "))
if num % 2 == 0:
print("The number is even")
else: print("The number is odd")
elif choice == 2:
num = int(input("Enter a number: "))
for i in range(2,num):
if num % i == 0:
print("The number is not prime")
break
else:
print("The number is prime")
elif choice == 3:
num = int(input("Enter a number to find its factorial: "))
fact = math.factorial(num)
print("The factorial of the given number is: ",fact)
elif choice == 4:
num = int(input("Enter a number: "))
for i in range(1,11):
print(num,"X",i, "=",num*i)
else:
print("Invalid choice")
QUESTION 3

print("1. To read the age of a person and check whether a person is eligible to vote or not")
print("2. To read the height and weight of a person and to calculate their BMI")
print("3. To calculate the HCF and LCM of two numbers")
print("4. To find the largest among the 3 numbers")
choice = int(input("Enter a choice (from 1 to 4): "))
if choice == 1:
age = int(input("Enter your age: "))
print("Your age is: ", age)
if age >= 18:
print("Eligible to vote")
else: print("Not eligible to vote")
elif choice == 2:
h = float(input("Enter your height (in m): "))
print("Your height is (in m): ",h)
w = float(input("Enter you weight (in kgs): "))
print("Your weight is (in kgs): ",w)
BMI = w/h**2
print("Your BMI is: ",BMI)
elif choice == 3:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
for i in range(2,num1 + 1):
if num1 and num2 % i == 0:
HCF = i
print("HCF of these numbers is: ",HCF)
LCM = (num1*num2)/HCF
print("LCM of these numbers is: ",LCM)
elif choice == 4:
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
num3 = int(input("Enter the third number: "))
if num1 > num2 > num3:
print(num1, ">", num2, ">", num3)
elif num2 > num1 and num3 > num1:
print(num2, ">", num3, ">", num1)
elif num3 > num1 and num1 > num2:
print(num3, ">", num1, ">", num2)
elif num2 > num1 > num3:
print(num2, ">", num1, ">", num3)
else:
print(num3, ">", num2, ">", num1)
else:
print("Invalid choice")
QUESTION 4

print("1. To print the sum of the first 'n' natural numbers")


print("2. To print the sum of all odd numbers upto 'n'")
print("3. 1 - x + x^2 - x^3 + x^4.......x^n")
print("4. x + x^2/2! - x^3/3! + x^4/4!.....x^n/n!")
choice = int(input("Enter a choice (from 1 to 4): "))
if choice == 1:
num = 1
sum = 0
n = int(input("Enter any number: "))
while num <= n:
sum = sum + num
num = num + 1
print("Sum of Natural Numbers : ", sum)
elif choice == 2:
num = int(input("Enter any number: "))
sum = 0
for i in range(1,num + 1):
if num % 2 == 1:
sum += i
print("Sum of odd numbers: ", sum)
elif choice == 3:
x = int(input("Enter the value for x: "))
n=x
result = 0
for i in range(n + 1):
result += (-x) ** i
print(result)
elif choice == 4:
import math

x = int(input("Enter the value for x: "))


n=x
result = 0
for i in range(1, n + 1):
result += (-1) ** (i + 1) * (x ** i) / math.factorial(i)
print(result)
else:
print("Invalid choice")

QUESTION 5
i) n = int(input("Enter a number: "))
for i in range(1, n + 1):
for j in range(1, i + 1):
print("*", end=" ")
print()

ii) n = int(input("Enter a number: "))


for i in range(n):
for j in range(n - i):
print(j, end=" ")
print()

iii) n = int(input("Enter a number: "))


for i in range(1, n + 1):
for j in range(i):
print(chr(65 + j), end=" ")
print()

QUESTION 6
print("Print number of digits and sum of the digits")
print("To check whether a number is armstrong or not")
print("To check whether a number is a palindrome or not")
print("To check whether a number is perfect or not")
choice = int(input("Enter a choice (from 1 to 4): "))
if choice == 1:
num = input("Enter a number: ")
count = 0
for i in num:
if i.isdigit():
count += 1
print("The number of digits in this number is: ",count)
j = int(input("Enter a number: "))
sum = 0
while j > 0:
sum = sum + j % 10
j = j//10
print(sum)
elif choice == 2:
num = int(input("Enter a number: "))
sum = sum(num ** 3)
for digit in str(num):
if num == sum:
print(f"{num} is an Armstrong Number")
else:
print(f"{num} is not an Armstrong Number")
elif choice == 3:
num = input("Enter a number: ")
revnum = num[::-1]
if num == revnum:
print("The number is a palindrome")
else:
print("The number is not a palindrome")
elif choice == 4:
num = int(input("Enter a number: "))

divisors_sum = 0
for divisor in range(1, num):
if num % divisor == 0:
divisors_sum += divisor

if divisors_sum == num:
print(num, "is a perfect number.")
else:
print(num, "is not a perfect number.")
else:
print("Invalid choice")

QUESTION 7
number = int(input("Enter a number: "))
words = []
units = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
tens = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
if number == 0:
print("zero")
else:
if number >= 100:
hundreds = number // 100
print(units[hundreds], "hundred")
number %= 100

if number >= 20:


tens_digit = number // 10
print(tens[tens_digit - 2])
number %= 10
elif number >= 10:
print(teens[number - 10])
number = 0
if number > 0:
print(units[number])

QUESTION 8
string = input("Enter a string: ")
num_alphabets = 0
num_uppercase = 0
num_lowercase = 0
num_digits = 0
num_vowels = 0
num_consonants = 0
num_special_chars = 0
num_spaces = 0
for char in string:
if char.isalpha():
num_alphabets += 1
if char.isupper():
num_uppercase += 1
else:
num_lowercase += 1
elif char.isdigit():
num_digits += 1
elif char.isspace():
num_spaces += 1
else:
num_special_chars += 1
for char in string:
if char.isalpha() and char.lower() in "aeiou":
num_vowels += 1
elif char.isalpha():
num_consonants += 1
print("Number of Alphabets:", num_alphabets)
print("Number of Uppercase Letters:", num_uppercase)
print("Number of Lowercase Letters:", num_lowercase)
print("Number of Digits:", num_digits)
print("Number of Vowels:", num_vowels)
print("Number of Consonants:", num_consonants)
print("Number of Special Characters:", num_special_chars)
print("Number of Spaces:", num_spaces)

QUESTION 9
print("1. Reverse a string")
print("2. Check if a string is a palindrome")
print("3. Print words in a sentence")
print("4. Print words with 'A' in a sentence")
choice = int(input("Enter your choice (from 1 to 4): "))

if choice == 1:
string = input("Enter a string: ")
reversed_string = ""
for char in string:
reversed_string = char + reversed_string
print("Reversed string:", reversed_string)
elif choice == 2:
string = input("Enter a string: ")
reversed_string = ""
for char in string:
reversed_string = char + reversed_string
if string == reversed_string:
print("The string is a palindrome.")
else:
print("The string is not a palindrome.")
elif choice == 3:
sentence = input("Enter a sentence: ")
words = sentence.split()
for word in words:
print(word)
elif choice == 4:
sentence = input("Enter a sentence: ")
words = sentence.split()
for word in words:
if "A" in word or "a" in word:
print(word)
else:
print("Invalid choice.")

QUESTION 10
print("1. Store numbers in a list")
print("2. Print smallest and largest numbers")
print("3. Reverse the list elements")
print("4. Swap first half elements with second half")
print("5. Swap even and odd elements")
print("6. Multiply odd numbers by 3 and even numbers by 6")
print("7. Exit")

choice = int(input("Enter your choice: "))

if choice == 1:
numbers = []
while True:
num = int(input("Enter a number (0 to stop): "))
if num == 0:
break
numbers.append(num)
print("Numbers added to the list:", numbers)
elif choice == 2:
if not numbers:
print("List is empty.")
else:
smallest = numbers[0]
largest = numbers[0]
for num in numbers[1:]:
if num < smallest:
smallest = num
if num > largest:
largest = num
print("Smallest number:", smallest)
print("Largest number:", largest)
elif choice == 3:
if not numbers:
print("List is empty.")
else:
reversed_numbers = []
for i in range(len(numbers) - 1, -1, -1):
reversed_numbers.append(numbers[i])
numbers = reversed_numbers
print("Reversed list:", numbers)
elif choice == 4:
if not numbers:
print("List is empty.")
elif len(numbers) % 2 == 0:
half_length = len(numbers) // 2
for i in range(half_length):
temp = numbers[i]
numbers[i] = numbers[i + half_length]
numbers[i + half_length] = temp
print("Swapped first and second halves:", numbers)
else:
print("List length must be even for swapping halves.")
elif choice == 5:
if not numbers:
print("List is empty.")
else:
for i in range(0, len(numbers), 2):
temp = numbers[i]
numbers[i] = numbers[i + 1]
numbers[i + 1] = temp
print("Swapped even and odd elements:", numbers)
elif choice == 6:
if not numbers:
print("List is empty.")
else:
for i in range(len(numbers)):
if numbers[i] % 2 == 0:
numbers[i] *= 6
else:
numbers[i] *= 3
print("Multiplied odd numbers by 3 and even numbers by 6:", numbers)
elif choice == 7:
print("Exiting...")
else:
print("Invalid choice. Please try again.")

You might also like