Class - XII: Computer Science Practical File
Class - XII: Computer Science Practical File
Class - XII
Name : _________________________________
Section : ________________________________
Roll No. : ________________________________
Instructions to Follow
1. All content must be copied as it in sequence, there should not be any type
Of cutting.
2 Output must be done neatly on blank page.
3. Use only Blue pen. You can use Black pen only for Output.
4. Cover your files with white paper before the submission.
INDEX
TEACHER SIGN.
S. No. PROGRAM NAME DATE
Write a Python Program to Check Prime Number.
1.
Write a Python Program to Print the Fibonacci
2.
Sequence
Write a Python Program to Find ASCII value of a
3.
Character
4. Write a Python program to print the sum of all
Clements in an array
20.
Create a table ‘Coach’ as per schema given below
21. Insert and display following data in Coach Table
(made in practical 1) using SQL statements
22. List all the coaches with their date of appointment
in descending order using SQL statements. (Refer
coach table of practical 2)
Write a query to display report showing coach
23.
name, Pay, age and bonus (15% of pay) for all
coaches (Refer coach table
Of practical 2)
Output:
1. n_terms = int(input ("How many terms the user wants to print? "))
2.
3. # First two terms
4. n_1 = 0
5. n_2 = 1
6. count = 0
7.
8. # Now, we will check if the number of terms is valid or not
9. if n_terms <= 0:
10. print ("Please enter a positive integer, the given number is not valid")
11. # if there is only one term, it will return n_1
12. elif n_terms == 1:
13. print ("The Fibonacci sequence of the numbers up to", n_terms, ": ")
14. print(n_1)
15. # Then we will generate Fibonacci sequence of number
16. else:
17. print ("The fibonacci sequence of the numbers is:")
18. while count < n_terms:
19. print(n_1)
20. nth = n_1 + n_2
21. # At last, we will update values
22. n_1 = n_2
23. n_2 = nth
24. count += 1
Output:
How many terms the user wants to print? 13
The Fibonacci sequence of the numbers is:
0
1
1
2
3
5
8
13
21
34
55
89
144
Program 3. Write a Python Program to Find ASCII value of a character
Output:
Please enter the String:
"JavaTpoint#
" 34
J 74
a 97
v 118
a 97
T 84
p 112
o 111
i 105
n 110
t 116
# 35
Output:
Sum of all the elements of an array: 15
Program 5. Write a program reverse a string in Python
1. # Reverse string
2. # Using a while loop
3.
4. str = "JavaTpoint" # string variable
5. print ("The original string is : ",str)
6. reverse_String = "" # Empty String
7. count = len(str) # Find length of a string and save in count variable
8. while count > 0:
9. reverse_String += str[ count - 1 ] # save the value of str[count-1] in reverseString
10. count = count - 1 # decrement index
11. print ("The reversed string using a while loop is : ",reverse_String)# reversed string
Output:
('The original string is : ', 'JavaTpoint')
('The reversed string using a while loop is : ', 'tniopTavaJ')
Output:
Enter a number as input value: -6
Number given by you is Negative
Program 7. Write a program Python Program to Find LCM
Output:
Enter first number: 3
Enter second number: 4
The L.C.M. of 3 and 4 is 12
Program 8. Write a program How to append element in the list
Output:
Current names List is: ['Joseph', 'Peter', 'Cook', 'Tim']
Please enter a name:
Devansh
Updated name List is: ['Joseph', 'Peter', 'Cook', 'Tim',
'Devansh']
Program 9. Write a Python program How to Calculate the Area of the Circle using
Python
1. import math as M
2. Radius = float (input ("Please enter the radius of the given circle: "))
3. area_of_the_circle = M.pi* Radius * Radius
4. print (" The area of the given circle is: ", area_of_the_circle)
Output:
Program 11. Write a Python Program to Read a text file line by line and display
filein = open("Mydoc.txt",'r')
for line in filein:
word= line .split()
for w in word:
print(w + '#',end ='')
print()
filein.close()
Sample Output
Program 12. Write a Python Program How to Remove an Element from a List in
Python
output
Program 13 Write a program to remove all the lines that contain the character 'a'
in this file and write other lines into another file.
myfile.close()
newfile.close()
print("Newly created file contains")
print("------------")
newfile = open("nswer.txt","r")
line = ""
while line:
line = newfile.readline()
print(line)
newfile.close()
output
import pickle
#creating the file and writing the data
f=open("records.dat", "wb")
#list index 0 = roll number
#list index 1 = name
#list index 2 = marks
pickle.dump([1, "Wakil", 90], f)
pickle.dump([2, "Tanish", 80], f)
pickle.dump([3, "Priyashi", 90], f)
pickle.dump([4, "Kanupriya", 80], f)
pickle.dump([5, "Ashutosh", 85], f)
f.close()
if i.islower():
lowercase = lowercase + 1
Output:
>>> %Run 'count vowelconsonet.py'
Enter any string :python
Total number of vowel: 1
Total number of consonent: 5
Total number of uppercase letter: 0
Total number of lowercase letter: 6
Coach
Field name Data type Attributes
Coachid Int Primary key
Coachname Varchar(20) Not Null
Age Int Default value 30
Sport Varchar(20) Not null
Dateofapp Date
Pay Float
Gender Char(1) Not null
Solution:
SQL Statement:
Dateofapp date,
Pay float,
Solution:
SQL Statement:
Pay, age and bonus (15% of pay) for all coaches (Refer coach table
Of practical 2)
Solution:
SQL Statement:
Program 24. Write a query to delete all record from table coach
Solution:
SQL Statement:
Name.
Solution:
SQL Statement:
Select dayname(‘2019/06/22’);
SQL Statement: