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

Practical File Class 11

This document is a practical file for Computer Science submitted by Apoorva Bijarniya for the session 2023-24 at Delhi Public School, Ranipur. It includes a detailed index of various programming tasks and their corresponding outputs, covering topics such as loops, conditionals, and data structures in Python. The document serves as a compilation of practical exercises aimed at enhancing programming skills.

Uploaded by

apoorvabijarniya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Practical File Class 11

This document is a practical file for Computer Science submitted by Apoorva Bijarniya for the session 2023-24 at Delhi Public School, Ranipur. It includes a detailed index of various programming tasks and their corresponding outputs, covering topics such as loops, conditionals, and data structures in Python. The document serves as a compilation of practical exercises aimed at enhancing programming skills.

Uploaded by

apoorvabijarniya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 35

DELHI PUBLIC

SCHOOL
RANIPUR,
HARIDWAR

PRACTICAL FILE

COMPUTER SCIENCE
SESSION: 2023-24

SUBMITTED BY: SUBMITTED TO:


APOORVA BIJARNIYA MR. NADEEM
XI-F COMPUTER DEPT.
ROLL NO. 11 DPS RANIPUR
ADMN NO. 2011/0057

INDEX
S.No Program Name Page
No.
1. Program to print the table of a given number. 1

2. Write a program that accepts three numbers from user and display the 2
largest number

3. Write a program to accept a number and display whether the given 3


number is Palindrome or not.

4. Write a program to print the factorial of a number entered by the user. 4

5. Write a program to print the sum of digits of a number given by the user. 5

6. Write a program to print the product of digits of a number given by the 6


user.

7. Write a program to check whether the entered number is Armstrong 7


Number or not.

8. Write a program to print Fibonacci Sequence upto n term, accepted


th
8
from user.

9. Write a program to print the following star pyramid pattern using 9-12
concept of nested loop.
1 1 5
a) 1 2 b) c) d) 1 2 3 4 5
22 4 4 1234
123 333 3 3 3 123
1234 4444 2 2 2 2 12
12345 55555 1 1 1 1 1
1
10. Write a program to print the following pattern using concept of 13-15
nested loop.
* * * * **
** ****
*** ***
**** **
a) * * * * b) * c)

11. Write a program to print the following Alphabetical pattern using 16-17
concept of nested loop.

a) b)
A A
AB BB
ABC CCC
ABCD DDDD
ABCDE EEEEE

12. Find the sum of the following series using concept of nested loop upto n th
18
entered by the user.
1+x+x +x +x +. .......... x
2 3 4 n

13. Write a program to accept a character from the user and display whether 19
it is a vowel or consonant.

14. Write a program to print the sum of First n natural numbers, accept the 20
value of n from user.

15. Write a menu –driven program to compute areas of figures 21

16. Write a program to accept the marks for five subjects and calculate the 22
total marks & percentage and etc…

17. WAP to find the largest and smallest elements in the list of integers 23
entered by the user without using sort() function.

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

19. WAP that returns the largest even number in the list of integers. If there 25
is no even number in input, print “No even number”.

20. WAP that prints the sum of the even indexed elements of L, minus the 26
sum of the odd-indexed elements of L.
21. WAP to print the alternate elements of a tuple T. 27

22. WAP to print every 3rd element of a tuple T. 28

23. Write a python program that inputs two tuples and creates a third that 29
contains all elements of the first followed by all elements of the second.

24. Create a dictionary with the roll number, name and marks of n students 30
in a class and display the names of students who have scored marks
above 75.

25. Create a nested dictionary that stores the marks details along with 31
student names and then prints the output.

PROGRAM 1:

n=int(input("Enter the required number: "))


for i in range(1,11):
print(n,"*",i,"=",n*i)

OUTPUT:
PROGRAM 2:

a=int(input("Enter the first number: "))


b=int(input("Enter the second number: "))
c=int(input("Enter the third number: "))
if a>b and a>c:
print(a,"is the largest number.")
if b>a and b>c:
print(b,"is the largest number.")
if c>b and c>a:
print(c,"is the largest number.")

OUTPUT:
PROGRAM 3:

n=int(input("Enter the required number: "))


s=r=0
p=n
while(n>0):
r=n%10
s=s*10+r
n=n//10
if(s==p):
print("The entered number is a palindrome")
else:
print("The entered number is NOT a palindrome")

OUTPUT:
PROGRAM 4:

n=int(input("Enter the required number: "))


f=1
for i in range(1,n+1):
f=f*i
print("The factorial is: ",f)

OUTPUT:
PROGRAM 5:

n=int(input("Enter the required number: "))


s=r=0
while(n>0):
r=n%10
s=s+r
n=n//10
print("The sum of the digits is: ",s)

OUTPUT:
PROGRAM 6:

n=int(input("Enter the required number: "))


s=1
r=0
while(n>0):
r=n%10
s=s*r
n=n//10
print("The product of the digits is: ",s)

OUTPUT:
PROGRAM 7:

n=int(input("Enter the required number: "))


s=r=0
p=n
while(n>0):
r=n%10
s=s+r*r*r
n=n//10
if(s==p):
print("The number entered is armstrong.")
else:
print("The number entered is NOT armstrong.")

OUTPUT:
PROGRAM 8:

n = int(input("Enter the number of terms: "))


fib_seq = [0, 1]
while len(fib_seq) < n:
next_term = fib_seq[-1] + fib_seq[-2]
fib_seq.append(next_term)
print(f"Fibonacci Sequence up to {n} terms: {fib_seq}")
OUTPUT:
PROGRAM 9 (a):

for i in range(1,6):
for j in range(1,i+1):
print(j,end="")
print()

OUTPUT:
PROGRAM 9 (b):

for i in range(1,6):
for j in range(1,i+1):
print(i,end="")
print()

OUTPUT:
PROGRAM 9 (c):

for i in range(5,0,-1):
for j in range(5,i-1,-1):
print(i,end="")
print()

OUTPUT:
PROGRAM 9 (d):

for i in range(5,0,-1):
for j in range(1,i+1):
print(j,end="")
print()

OUTPUT:
PROGRAM 10(a):

for i in range(1,6):
for j in range(1,i+1):
print("*",end="")
print()

OUTPUT:
PROGRAM 10(b):

for i in range(6,0,-1):
for j in range(1,i+1):
print("*",end="")
print()

OUTPUT:
PROGRAM 10(c):

rows = 5
k = 2 * rows - 2
for i in range(0, rows + 1):
for j in range(k, 0, -1):
print(end=" ")
k=k-1
for j in range(0, i):
print("*", end=" ")
print("")

OUTPUT:
PROGRAM 11(a):

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

OUTPUT:
PROGRAM 11(b):

for i in range(65, 70):


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

OUTPUT:
PROGRAM 12:

s=0
n=int(input("Enter the value of n"))
x=int(input("Enter the value of x"))
for i in range(0,n+1):
s=s+(x**i)
print(s)

OUTPUT:
PROGRAM 13:

char = input("Enter a character: ")


if char.isalpha() and len(char) == 1:
result = "vowel"
if char.lower() in 'aeiou' else "consonant"
print(f"The character {char} is a {result}.")
else:
print("Please enter a valid single character.")

OUTPUT:
PROGRAM 14:

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


s=0
for i in range(1,n+1):
s=s+i
print("sum is" ,s)

OUTPUT:
PROGRAM 15:

print("Choose the shape to find area: 1(circle) 2(rectangle) 3(square)")


n=int(input("Enter your choice "))
if n==1:
r=int(input("enter the radius of the circle:"))
print("the area of the cicle is: ",3.14*r*r)
elif n==2:
a=int(input("enter the length of the rectangle:"))
b=int(input("enter the bredth of the rectangle:"))
print("the area of the cicle is: ",a*b)
elif n==3:
a=int(input("enter the side of the square:"))
print("the area of the cicle is: ",a*a)
else:
print("invalid input ")

OUTPUT:
PROGRAM 16:

a=int(input("Enter your marks in mathematics: "))


b=int(input("Enter your marks in physics: "))
c=int(input("Enter your marks in chemistry: "))
d=int(input("Enter your marks in english: "))
e=int(input("Enter your marks in computer science: "))
tt=a+b+c+d+e
print("The total marks are: ",tt)
p=(tt/500)*100
print("The percantage is : ",p,"%")
if p>= 75:
print("the grade is: A")
elif p<75 and p>=60:
print("the grade is: B")
elif p<60 and p>=45:
print("the grade is: C")
elif p<45 and p>=33:
print("the grade is: D")
else:
print("Reappear ")

OUTPUT:

PROGRAM 17:

L=eval(input("Enter list: "))


ln=len(L)
max=L[0]
min=L[0]
for i in range (1,ln):
if(L[i]>max):
max=L[i]
if(L[i]<min):
min=L[i]
print("largest number is: ",max)
print("smallest number is: ",min)

OUTPUT:
PROGRAM 18:

L=eval(input("Enter a list of integers: "))


print("Original List is:",L)
s=len(L)
if s%2!=0:
s=s-1
for i in range(0,s,2):
L[i],L[i+1]=L[i+1],L[i]
print("List after swapping :",L)

OUTPUT:
PROGRAM 19:

user_input = input("Enter a list of integers separated by spaces: ")


numbers = [int(num) for num in user_input.split()]
even_numbers = [num for num in numbers if num % 2 == 0]
if even_numbers:
print(f"The largest even number is: {max(even_numbers)}")
else:
print("No even number")

OUTPUT:
PROGRAM 20:

user_input = input("Enter a list of integers separated by spaces: ")


L = [int(num) for num in user_input.split()]
sum_even = sum(L[::2])
sum_odd = sum(L[1::2])
result = sum_even - sum_odd
print(f"The result is: {result}")

OUTPUT:
PROGRAM 21:

user_input = input("Enter a tuple of elements separated by spaces: ")


T = tuple(user_input.split())
for i in range(0, len(T), 2):
print(T[i])

OUTPUT:
PROGRAM 22:

user_input = input("Enter a tuple of elements separated by spaces: ")


T = tuple(user_input.split())
for i in range(2, len(T), 3):
print(T[i])

OUTPUT:
PROGRAM 23:

input1 = input("Enter elements for the first tuple separated by spaces: ")
tuple1 = tuple(input1.split())
input2 = input("Enter elements for the second tuple separated by spaces: ")
tuple2 = tuple(input2.split())
tuple3 = tuple1 + tuple2
print("The third tuple:", tuple3)
OUTPUT:

PROGRAM 24:

n = int(input("Enter the number of students: "))


student_dict = {}
for i in range(1, n + 1):
roll_number = input(f"Enter roll number for student {i}: ")
name = input(f"Enter name for student {i}: ")
marks = float(input(f"Enter marks for student {i}: "))
student_dict[roll_number] = {"name": name, "marks": marks}
print("Names of students with marks above 75:")
for roll_number, info in student_dict.items():
if info["marks"] > 75:
print(info["name"])

OUTPUT:

PROGRAM 25:

n = int(input("Enter the number of students: "))


student_dict = {}
for i in range(1, n + 1):
name = input(f"Enter name for student {i}: ")
marks = {"Math": float(input(f"Enter Math marks for {name}: ")),
"Science": float(input(f"Enter Science marks for {name}: ")),
"English": float(input(f"Enter English marks for {name}: "))}
student_dict[name] = marks
print("Student details with marks:")
for name, marks in student_dict.items():
print(f"{name}: {marks}")

OUTPUT:

You might also like