Session 2023-24
Computer Science
Practical File
2023-24
Submitted To:
Submitted By:
Class: XI ‘A’
Computer Science Practical File Class XI ‘A’
Session 2023-24
Index
Computer Science Practical Record
Progra Title Page
m No.
No.
1 Write a Python program to create a simple calculator 3
2 Write a Python program to print the stars pyramid pattern 4
3 Write a Python program to print the pattern for Left triangle of 5
numbers
4 Write a Python program to print a matrix of symbols based on rows, 6
column and symbols
5 Write a Python program to separate, convert to upper case and sort 7
names in a name string
6 Write a Python program to compute area, perimeter and 8
semiperimeter of a circle
7 Write a Python program to the identify and display the type of 9
character entered through a keyboard
8 Write a Python program to give the appropriate message based on 10
temperature
9 Write a Python program to display calendar based on year and month 11
10 Write a Python program to display appropriate message based on age 12
11 Write a Python program to check whether the given number is prime 13
or composite
Submission: 9/9/2023
Teacher Signature:
Program No.1
Computer Science Practical File Class XI ‘A’
Session 2023-24
Aim: Write a Python program to create a simple calculator
Program 1:
# Namit Rathi XI 'A'
# Write Python Program to create a simple calculator
print("*****Simple Calculator*****")
n1=int(input("Enter First number "))
n2=int(input("Enter Second number "))
op=(input("Enter valid Arithmetic Operator(+ or -or *or % or /) "))
print(' ')
if op == '+':
print(n1,"+",n2,"=", n1+n2)
elif op == '-':
print(n1,"-",n2,"=", n1-n2)
elif op == '*':
print(n1,"*",n2,"=", n1*n2)
elif op == '%':
print(n1,"%",n2,"=", n1%n2)
elif op == '/':
print(n1,"/",n2,"=", n1/n2)
else:
print("invalid Operation")
Output 1:
Enter First number 2
Enter Second number 3
Enter valid Arithmetic Operator(+ or -or *or % or /) $
invalid Operation
Output 2:
Enter First number 2
Enter Second number 3
Enter valid Arithmetic Operator(+ or -or *or % or /) %
2%3=2
Output 3:
Enter First number 6
Enter Second number 7
Enter valid Arithmetic Operator(+ or -or *or % or /) *
6 * 7 = 42
Program No.2
Computer Science Practical File Class XI ‘A’
Session 2023-24
Aim: Write a Python program to print the stars pyramid pattern
Program 2:
# Namit Rathi XI 'A'
# Write Python Program to display a pyramid of stars
print("*****Pyramid of Stars*****")
row=int(input("Enter a number "))
print(' ')
for i in range(row):
#Printing space
for sp in range(i,row):
print(' ',end=' ')
#Printing stars
for st in range(i+1):
print('* ',end=' ')
print(' ')
Output 1:
*****Pyramid of Stars*****
Enter a number 6
*
* *
* * *
* * * *
* * * * *
* * * * * *
Output 2:
*****Pyramid of Stars*****
Enter a number 8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
Program No.3
Aim: Write a Python program to print the pattern for Left triangle of numbers
Computer Science Practical File Class XI ‘A’
Session 2023-24
Program 3:
# Namit Rathi XI 'A'
# Write a python program to print a pattern for Left triangle of numbers
row=int(input("Enter a number "))
for i in range(row+1):
for j in range(i):
print(i,end=' ')
print(' ')
Output 1:
Enter a number 4
1
22
333
4444
Output 2:
Enter a number 7
1
22
333
4444
55555
666666
7777777
Program No.4
Aim: Write a Python program to print a matrix of symbols based on rows, column and symbols
Computer Science Practical File Class XI ‘A’
Session 2023-24
Program 4:
# Namit Rathi XI 'A'
# Write a Python program to print a matrix of symbols based on rows,
column and symbols
print("*****Print Matrix*****")
r=int(input("Enter number of rows "))
c=int(input("Enter number of columns "))
s=(input("Enter a symbol that you want to print"))
print(' ')
for i in range(r):
for j in range(c):
print(s,end=' ')
print(' ')
Output 1:
*****Print Matrix*****
Enter number of rows 3
Enter number of columns 4
Enter a symbol that you want to print $
$$$$
$$$$
$$$$
Output 2:
*****Print Matrix*****
Enter number of rows 6
Enter number of columns 2
Enter a symbol that you want to print #
##
##
##
##
##
##
Program No.5
Aim: Write a Python program to separate, convert to upper case and sort names in a name string
Computer Science Practical File Class XI ‘A’
Session 2023-24
Program 5:
# Namit Rathi XI 'A'
# Write a Python program to separate, convert to upper case and sort
names in a name string
print("*****Separate, convert case and sort strings*****")
name_string =str(input("Enter some names separated by space"))
names=[word.upper() for word in name_string.split()]
print ("The String converted to upper case",names)
names.sort()
print ("The sorted names are", names)
for name in names:
print(name)
Output 1:
*****Separate, convert case and sort strings*****
Enter some names separated by space nisha Nitin NAMIT
The String converted to upper case ['NISHA', 'NITIN', 'NAMIT']
The sorted names are ['NAMIT', 'NISHA', 'NITIN']
NAMIT
NISHA
NITIN
Output 2:
*****Separate, convert case and sort strings*****
Enter some names separated by space intellect Heights academy
The String converted to upper case ['INTELLECT', 'HEIGHTS', 'ACADEMY']
The sorted names are ['ACADEMY', 'HEIGHTS', 'INTELLECT']
ACADEMY
HEIGHTS
INTELLECT
Program No.6
Aim: Write a Python program to compute area, perimeter and semiperimeter of a circle
Computer Science Practical File Class XI ‘A’
Session 2023-24
Program 6:
# Namit Rathi XI 'A'
# Write a Python program to compute area, perimeter and semiperimeter
of a circle
print("*****Area, perimeter and semiperimeter of a circle*****")
r=int(input("Enter the radius of a circle"))
pi=22/7;
r_sq=r**2;
area=2*pi*r_sq;
peri=2*pi*r;
semi_peri=pi*r;
print(' ')
print("Area of given Circle is ", area)
print("Perimeter of given Circle is ", peri)
print("SemiPerimeter of Circle is ", semi_peri)
Output 1:
*****Area, perimeter and semiperimeter of a circle*****
Enter the radius of a circle 2
Area of given Circle is 25.142857142857142
Perimeter of given Circle is 12.571428571428571
SemiPerimeter of Circle is 6.285714285714286
Output 2:
*****Area, perimeter and semiperimeter of a circle*****
Enter the radius of a circle 1
Area of given Circle is 6.285714285714286
Perimeter of given Circle is 6.285714285714286
SemiPerimeter of Circle is 3.142857142857143
Program No.7
Aim: Write a Python program to the identify and display the type of character entered
Computer Science Practical File Class XI ‘A’
Session 2023-24
through a keyboard
Program 7:
# Namit Rathi XI 'A'
# Write a Python program to the identify and display the type of character
entered through a keyboard
print("*****Identify and display character*****")
ch=(input("Enter a character"))
print(' ')
if ch>='A' and ch<='Z':
print(ch, " is an upper case letter");
elif ch>='a' and ch<='z':
print(ch, " is a lower case letter");
elif ch>='0' and ch<='9':
print(ch, " is a single digit")
else:
print(ch, " is a special character")
Output 1:
*****Identify and display character*****
Enter a character s
s is a lower case letter
Output 2:
****Identify and display character*****
Enter a character 6
6 is a single digit
Output 3:
*****Identify and display character*****
Enter a character @
@ is a special character
Program No.8
Aim: Write a Python program to give the appropriate message based on temperature
Computer Science Practical File Class XI ‘A’
Session 2023-24
Program 8:
# Namit Rathi XI 'A'
# Write a Python program to give the appropriate message based on temperature
print("*****Message based on Temperature *****")
temp=int(input("What is the temperature Outside??"))
print(' ')
if temp>=0 and temp<=30:
print("Temperature is good outside!! \nyou can go outside and enjoy");
elif(temp<0):
print("It's too cold!! \nBetter remain at home and stay warm");
elif(temp>30):
print("It's too Hot outside!! \nBetter remain at home and enjoy Air-conditioning");
Output 1:
*****Message based on Temperature *****
What is the temperature Outside?? 45
It's too Hot outside!!
Better remain at home and enjoy Air-conditioning
Output 2:
*****Message based on Temperature *****
What is the temperature Outside?? -4
It's too cold!!
Better remain at home and stay warm
Output 3:
*****Message based on Temperature *****
What is the temperature Outside?? 25
Temperature is good outside!!
you can go outside and enjoy
Program No.9
Aim: Write a Python program to display calendar based on year and month
Computer Science Practical File Class XI ‘A’
Session 2023-24
Program 9:
# Namit Rathi XI 'A'
# Write a Python program to display calendar based on year and month
import calendar
print("*****Display Calendar*****")
year =int(input("Enter the year of which you seek calendar"))
month =int(input("\nEnter the month of which you seek calendar(1-12)"))
if month<1 or month>12 :
print("\ninvalid month")
else:
cal=calendar.month(year,month)
print("\n",cal)
Output 1:
*****Display Calendar*****
Enter the year of which you seek calendar 2023
Enter the month of which you seek calendar(1-12) 9
September 2023
Mo Tu We Th Fr Sa Su
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
Output 2:
*****Display Calendar*****
Enter the year of which you seek calendar 1947
Enter the month of which you seek calendar(1-12) 10
October 1947
Mo Tu We Th Fr Sa Su
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Output 3:
*****Display Calendar*****
Enter the year of which you seek calendar 1947
Enter the month of which you seek calendar(1-12) 13
invalid month
Program No.10
Aim: Write a Python program to display appropriate message based on age
Computer Science Practical File Class XI ‘A’
Session 2023-24
Program 10:
# Namit Rathi XI 'A'
# Write a Python program to display appropriate message based on age
print("*****Msg based on Age*****")
name = (input("Enter your name"))
age =int (input("Enter your age"))
if age>=100 :
print("\nDear",name, ", Are you still Alive? \nCongratulations for such a huge
experience!!")
elif age>=18:
print("\nDear", name, ", You are eligible for driving license. \nCongratulations!!")
else:
print("\nDear", name, ", You are not an adult. \nEnjoy your childhood and play!!")
Output 1:
*****Msg based on Age*****
Enter your name Namit
Enter your age 16
Dear Namit , You are not an adult.
Enjoy your childhood and play!!
Output 2:
*****Msg based on Age*****
Enter your name Pt. Shivshankar
Enter your age 102
Dear Pt. Shivshankar , Are you still Alive?
Congratulations for such a huge experience!!
Output 3:
*****Msg based on Age*****
Enter your name Nisha Rathi
Enter your age 40
Dear Nisha Rathi , You are eligible for driving license.
Congratulations!!
Program No.11
Aim: Write a Python program to check whether the given number is prime or composite
Computer Science Practical File Class XI ‘A’
Session 2023-24
Program 11:
# Namit Rathi XI 'A'
# Write a Python program to check whether the given number is prime or composite
print("*****Check for Prime or composite number*****")
n = int(input("Enter a number"))
print(' ')
if n == 2 or n==3 or n==5 or n==7:
print(n, " is a prime number")
elif n==1:
print(n, " is neither prime number nor composite")
elif n%2==0:
print(n, " is a composite number, divisible by 2")
elif n%3==0:
print(n, " is a composite number, divisible by 3")
elif n%5==0:
print(n, " is a composite number, divisible by 5")
elif n%7==0:
print(n, " is a composite number, divisible by 7")
else:
print(n, " is a prime number")
Output 1:
*****Check for Prime or composite number*****
Enter a number 1
1 is neither prime number nor composite
Output 2:
*****Check for Prime or composite number*****
Enter a number 141
141 is a composite number, divisible by 3
Output 3:
*****Check for Prime or composite number*****
Enter a number 24573
24573 is a composite number, divisible by 3
Computer Science Practical File Class XI ‘A’