You are on page 1of 11

NEW HORIZON SCHOLAR’S SCHOOL,

KAVESAR, THANE (W)

COMPUTER SCIENCE(083)
PRACTICAL FILE
with

2021 – 2022

Submitted By:
NAME: YASH AGARWAL
CLASS/DIV: XII E
Roll No.: 45
Exam Seat Number:
Submitted To: Mrs Aarati Mahajan
Index
SN. Program Signature
1 WAP to input a year and check whether the year is leap year or not.
2 WAP to input 3 numbers and print the greatest number using nested if.
WAP to input value of x and n and print the series of x^n along with its sum.
3
e.g x=2 n=5 (Output:x^0 x^1…x^n and sum)
4 WAP to input a number and check whether its prime number or not.
5 WAP to print Fibonacci series up to n terms, also find sum of series.
6 WAP to print the given patterns.
7 WAP to print a string and the number of vowels present in it.
WAP to input a list of numbers and search for a given number using linear
8
search./ binary search.
WAP that rotates the elements of a list so that the element at first index
9 moves to the second index, the element at second index moves to the third
index and so on and the element at last index moves to the first index.
Write a program to sort a list using bubble sort and produce sorted
10
list./bubble sort for dictionary keys
Write a menu driven program which will have following functions that takes
a number
i) Digisum() – returns sum of digits.
11
ii) rev() – reverse of a number and also print whether a number is
palindrome
or not.
Write function div3and5() that takes 10 elements numeric tuple and return the
12
sum of elements which are divisible by 3 and 5
Write a function that receives two numbers and generates random number
13 from that range. Using this function the main program should be able to print
3 numbers randomly.
Write a python program to maintain book details like book code, book title
14 and price using stacks data structures? (implement push(), pop() and
traverse() functions)
Write a python program to read a file named “article.txt”, count and print the
following:
a) length of the file(total characters in file)
b) total alphabets
15 c) total upper case alphabets
d) total lower case alphabets
e) total digits
f) total spaces
g) total special characters
WAP that copies a text file “source.txt” onto “target.txt” barring the lines
16
starting with a ”@” sign.
A file contains a list of telephone numbers in the following form:
Ashwin 9988776655
17
Shweta 9994445554
WAP to read a file and display its contents in two columns.
WAP that reads characters from the keyboard one by one. All lowercase
18 characters get stored in the file “lower”, all uppercase characters get stored
inside a file “UPPER” and all other characters inside “others”.
Python file/program for interactive binary data file handling (includes
19
insert/search/update/delete operation)
20 Reading and Writing to CSV file.
Write A Program To Integrate SQL With Python By Importing The Mysql
21
Module.
22 Take A Sample Of 10 Phishing Emails And Find The Most Common Words.
23 MySQL Queries I
24 MySQL Queries II
Write A Program To Connect Python With MySQL Using Database
25 Connectivity And Perform The Following Operations On Data In Database:
Fetch, Update And Delete The Data.
QUESTION-1
WAP to input a year and check whether the year is leap year or not.
CODE:

OUTPUT :

QUESTION-2
WAP to input 3 numbers and print the greatest number using nested it.
CODE:
OUTPUT :

QUESTION-3
WAP to input value of x and n and print the series of x^n along with its
sum.
e.g x=2 n=5 (Output:x^0 x^1…x^n and sum)
CODE:

OUTPUT :
QUESTION-4
WAP to input a number and check whether its prime number or not.
CODE:

OUTPUT :

QUESTION-5
WAP to print Fibonacci series up to n terms, also find sum of series
QUESTION 6
A.star pattern
def pypart(n):
myList = []
for i in range(1,n+1):
myList.append("*"*i)
print("\n".join(myList))

n = 5
pypart(n)
OUTPUT:
*
**
***
****
*****
B.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

def contnum(n):

num = 1

for i in range(0, n):

for j in range(0, i+1):


print(num, end=" ")

num = num + 1
print("\r")

n = 5
contnum(n)
output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
C
Row = 6

for i in range(rows):
for j in range(i):
print(i, end=' ')
print('')
output:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
D
rows = 5
b = 0

for i in range(rows, 0, -1):


b += 1
for j in range(1, i + 1):
print(b, end=' ')
print('\r')

output:
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5

QUESTION 7
WAP to print a string and count the number of vowels present in it.
String = input('Enter the string :')
count = 0

String = String.lowerCase()
for i in String:
if i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u':

count+=1
if count == 0:
print('No vowels found')
else:
print('Total vowels are :' + str(count))

OUTPUT:
Enter the string : capital
Total vowels are :3

QUESTION 8
WAP to input a list of numbers and search for a given number using linear search./
binary search.
l = eval(input("Enter a list"))
s = input("Enter a element to be searched")
for i in range(len(l)):
if(i == l[i]):
print(s,"is present in the list at index",i)

OUTPUT:
Enter a list [2,3,4,5]
Enter a element to be searched 4
4 is present at index 2

QUESTION 9
WAP that rotates the elements of a list so that the element at first index moves to the second
index, the element at second index moves to the third index and so on and the element at last
index moves to the first index.
lst=eval(input("Enter a list : "))
print("List before Rotation :",lst)
a=lst[0]
s=len(lst)
for i in range(1,s):
lst[i-1]=lst[i]
lst[s-1]=a
print("List after Rotate :",lst)

OUTPUT
Enter a list : [3,4,5,6]

List before Rotation : [3, 4, 5, 6]

List after Rotate : [4, 5, 6, 3]

QUESTION 10
Write a program to sort a list using bubble sort and produce sorted list./bubble sort for
dictionary keys
dic = eval (input("Enter a dictionary : "))
key = list(dic.keys())

for j in range (len(key)):


for i in range ( len ( key ) - 1) :
if key [ i ] > key [ i + 1 ] :
key [ i ] , key [ i + 1 ] = key [ i + 1 ] , key [ i ]

print(key)

OUTPUT:
Enter a dictionary : {9:"Python",2:"C++",7:"Java",3:"CSS"}
[2, 3, 7, 9]
>>>

Enter a dictionary : {5:"Path",3:"Walla",4:"Portal",7:"Express"}


[3, 4, 5, 7]

You might also like