0% found this document useful (0 votes)
3 views

cs

This document is a practical file submitted by Yuvraj Singh for Computer Science at K.R. Mangalam World School, certifying the completion of required practicals for CBSE Class XI. It includes acknowledgments, programming questions, and their respective answers, covering various topics such as input/output operations, pattern generation, series summation, and basic algorithms. The file serves as a record of the student's practical work and understanding of computer science concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

cs

This document is a practical file submitted by Yuvraj Singh for Computer Science at K.R. Mangalam World School, certifying the completion of required practicals for CBSE Class XI. It includes acknowledgments, programming questions, and their respective answers, covering various topics such as input/output operations, pattern generation, series summation, and basic algorithms. The file serves as a record of the student's practical work and understanding of computer science concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

K.R.

Mangalam World
School, Gr. Noida
Topic - CBSE Practical File

Submitted to : - Ms. Roopal Bansal

Submitted by :- Yuvraj Singh

Class & Section :- XI - A

Roll no. : - 26
Certificate
This is to certify that Yuvraj Singh of class XI-A Has successfully
completed the practical file of the subject Computer science laid down
in the regulations of CBSE for the purpose of Practical Examination
in Class XI, K.R. MANGALAM WORLD SCHOOL in the
academic year 2024-25.

TEACHER IN-CHARGE

PGT(Computer Science)

EXAMINER PRINCIPAL

Name : _________________ Name:


______________________

Signature: Signature:

Date: Date:
Acknowledgement

I would like express my special thanks of gratitude to my subject


teacher who gave me golden opportunity and guidance to create this
practical file. It helped me a lot as i got enriched with information
which help me in future and came to knew about so many new things.
i am reallly thankful to her.

I would also like to thank my parents and friends who helped me to


finalize this practical file within the limited time frame.

Thank you
Question 1

Input a welcome message and display it.

Answer 1

Wel = input("Enter a message : ")

print()

print(Wel)

Question 2

Input two numbers and display the larger / smaller number.

Answer 2

x = int(input("Enter a number : "))

y = int(input("Enter a number : "))

#Checking for larger number

if x > y :

print("The larger number is ", x)

else :

print("The larger number is ", y)

#Checking for smaller number

if x < y :

print("The smaller number is ", x)

else :

print("The smaller number is ", y)


Question 3

Input three numbers and display the largest / smallest number.

Answer 3

x = int(input("Enter a number : "))

y = int(input("Enter a number : "))

z = int(input("Enter a number : "))

#Checking for larger number

if x > y and x > z:

print("The larger number is ", x)

elif y > x and y > z :

print("The larger number is ", y)

else :

print("The larger number is ", z)

#Checking for smaller number

if x > y and x > z :

print("The smaller number is ", x)

elif y > x and y > z :

print("The smaller number is ", y)

else :

print("The smaller number is ", z)


uestion 4

Generate the following patterns using nested loops:

(i)

ns.

n=5

for i in range(1, n + 1):

for j in range(i):

print('*', end='')

print()
(ii)

Answer

i=5

while i > 0:

print("".join(str(j) for j in range(1, i + 1)))

i -= 1

(iii)

Answer

i=1

string = "ABCDE"

while i <= len(string):

print(string[:i])

i += 1
Question 5

Write a program to input the value of x and n and print the sum of the following series:

i)

Answer

x = float(input("Enter the value of x: "))

n = int(input("Enter the value of n: "))

sum_series = 0

i=0

while i <= n:

sum_series += x ** i

i += 1

print("Sum of the series (1 + x + x^2 + ... + x^n) is:", sum_series)

ii)

Answer

x = float(input("Enter the value of x: "))

n = int(input("Enter the value of n: "))

sum_series = 0

i=0

while i <= n:
sum_series += ((-1) ** i) * (x ** i)

i += 1

print("Sum of the series (1 - x + x^2 - x^3 + ... + (-1)^n * x^n) is:", sum_series)

iii)

Answer

x = float(input("Enter the value of x: "))

n = int(input("Enter the value of n: "))

sum_series = 0

i=1

while i <= n:

sum_series += (x ** i) / i

i += 1

print("Sum of the series (x + x^2/2 + x^3/3 + ... + x^n/n) is:", sum_series)

Question 7

Input a number and check if the number is a prime or composite number.

Answer

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

if n < 2 :

print("Neither prime nor compostie number")


elif n == 2:

print("It's a prime number")

else :

for i in range (2,int(n**0.5)+1):

if n % i == 0:

print("It'a a composite number")

Question 8

Display the terms of a Fibonacci series.

Answer

nterms = int(input("How many terms? "))

n1, n2 = 0, 1

count = 0

if nterms <= 0:

print("Please enter a positive integer")

elif nterms == 1:

print("Fibonacci sequence upto",nterms,":")

print(n1)

else:

print("Fibonacci sequence:")

while count < nterms:

print(n1)

nth = n1 + n2
n1 = n2

n2 = nth

count += 1

Question 9

Compute the greatest common divisor and least common multiple of two integers.

Answer

num1 = int(input("Enter 1st number: "))

num2 = int(input("Enter 2nd number: "))

i=1

while(i <= num1 and i <= num2):

if(num1 % i == 0 and num2 % i == 0):

gcd = i

i=i+1

print("Greatest Common Divisor (GCD) is ", gcd)

if num1 > num2:

greater = num1

else:

greater = num2

while(True):

if((greater % num1 == 0) and (greater % num2 == 0)):

lcm = greater
break

greater += 1

print("The Least Common Multiple (LCM) is ", lcm)

Question 10

Count and display the number of vowels, consonants, uppercase, lowercase characters
in string.

Answer

str = input("Type the string: ")

vowel_count=0

consonants_count=0

vowel = set("aeiouAEIOU")

for alphabet in str:

if alphabet in vowel:

vowel_count=vowel_count +1

elif alphabet == chr(32):

consonants_count=consonants_count

else:

consonants_count=consonants_count+1

print("Number of Vowels in ",str," is :",vowel_count)

print("Number of Consonants in ",str," is :",consonants_count)

uppercase_count=0

lowercase_count=0

for elem in str:


if elem.isupper():

uppercase_count += 1

elif elem.islower():

lowercase_count += 1

print("Number of UPPER Case in ",str,"' is :",uppercase_count)

print("Number of lower case in ",str,"' is :",lowercase_count)

Question 11

Input a string and determine whether it is a palindrome or not; convert the case of
characters in a string.

Answer

s = input("Enter a string : ")

if (s==s[::-1]):

print(s, "is a palindrome")

else:

print(s, "is not a palindrome")

Question 12

Find the largest/smallest number in a list/tuple.

Answer

val=eval(input("Enter a list : "))

print("Original list is :", val)

mx = max(val)
mn = min(val)

print("The maximum number in the list :", mx)

print("The minimum number in the list :", mn)

Question 13

Input a list of numbers and swap elements at the even location with the elements at the
odd location.

Answer

val=eval(input("Enter a list : "))

print("Original list is ",val)

s=len(val)

if s % 2!=0:

s=s-1

for i in range (0,s,2):

print(i,i+1)

val[i],val[i+1]=val[i+1],val[i]

print("List after swapping : ", val)


Question 14

Input a list/tuple of elements, search for a given element in the list/tuple.

Answer

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("Element found at Index:", i)

print("Element found at Position:", i+1)

You might also like