0% found this document useful (0 votes)
20 views23 pages

Computer Science

This document contains a practical file for Class 12 student Shardul Singh. It includes 7 programming problems with sample code and expected output for each. The problems cover topics like generating terms of an arithmetic progression, random number generation simulating a dice, calculating factorials using loops, summing a series, checking if a number is even or odd using functions, analyzing characters in a string using classes, creating and modifying an employee database table, and reading/writing to a CSV file.

Uploaded by

Shardul Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views23 pages

Computer Science

This document contains a practical file for Class 12 student Shardul Singh. It includes 7 programming problems with sample code and expected output for each. The problems cover topics like generating terms of an arithmetic progression, random number generation simulating a dice, calculating factorials using loops, summing a series, checking if a number is even or odd using functions, analyzing characters in a string using classes, creating and modifying an employee database table, and reading/writing to a CSV file.

Uploaded by

Shardul Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

COMPUTER SCIENCE

PRACTICAL FILE

SHARDUL SINGH
CLASS 12TH A
JAGRAN PUBLIC SCHOOL, NOIDA
ROLL NO. :
PROGRAM 1

Q. Write a program that generates 4 terms of an a.p. by


providing initial and step values to a function that returns first
four terms of the series.

A.
def retseries(init, step) :
return init, init+step, init+2*step, init+3*step
inival=int(input(“Enter initial value of A.P.”))
cd=int(input(“Enter common difference of A.P.”))
print(“Series with first term” , inival, “and common difference”,
cd, “ : “ )
t1, t2, t3, t4 = retseries(inival, cd)
print(t1, t2, t3, t4)

OUTPUT WILL BE AS FOLLOWS:


PROGRAM 2
Q. Write a random number generator that simulates a dice.

A.
import random
min=1
max=6
roll_again = ‘y’
while roll_again==’y’ or roll_again==’Y’:
print(
“Rolling the dice …..”
)
val=random.randint(min, max)
print(“The dice landed on….. : ” , val )
roll_again=input(“Roll dice again ? (y/n) “)
OUTPUT WILL BE AS FOLLOWS :
PROGRAM 3

Q. Write a program to calculate the factorial of the given


number using for loop.

A.
CODE WILL BE AS FOLLOWS:

OUTPUT WILL BE AS FOLLOWS :


PROGRAM 4

Q. Write a program to sum the series:


1/1 + 22/2 + 33/3 +…..+ nn/n

A. CODE WILL BE AS FOLLOWS:

OUTPUT WILL BE AS FOLLOWS:


PROGRAM 5
Q. Write a program using functions to check whether a
number is even or odd.

A. CODE WILL BE AS FOLLOWS:

OUTPUT WILL BE AS FOLLOWS:


PROGRAM 6

Q. Write a program to accept a string and print the number of


uppercase, lowercase, vowels, consonants and spaces in the
given string using Class.

A. CODE WILL BE AS FOLLOWS:


OUTPUT WILL BE AS FOLLOWS:
PROGRAM 6
Q. Create an Employee Table with the fields Empno,
Empname, Desig , Dept, Age and Place. Enter five records into
the table.
i) Add two more records to the table.
ii) Modify the table structure by adding one more field
namely date of joining.
iii) Check for Null value in doj of any record.
iv) List the employees who joined after 2018/01/01.
A.
CODE IS AS FOLLOWS:
i)
ii)
iii)

iv)
PROGRAM 7

Q. Write a program using python to get 10 players name and


their score. Write the input in a csv file. Accept a player name
using python. Read the csv file to display the name and the
score. If the player name is not found give an appropriate
message.
A.CODE IS AS FOLLOWS:
OUTPUT IS AS FOLLOWS :

You might also like