KEMBAR78
Class 12 Computer Science Programs | PDF
0% found this document useful (0 votes)
278 views5 pages

Class 12 Computer Science Programs

The document contains Python programs demonstrating various functionalities, including calculating the sum of two numbers, generating multiplication tables, calculating factorials, and computing simple interest. It also includes file handling examples, such as counting lines in a text file and writing records to a binary file. Each program is presented with its respective function and input prompts.

Uploaded by

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

Class 12 Computer Science Programs

The document contains Python programs demonstrating various functionalities, including calculating the sum of two numbers, generating multiplication tables, calculating factorials, and computing simple interest. It also includes file handling examples, such as counting lines in a text file and writing records to a binary file. Each program is presented with its respective function and input prompts.

Uploaded by

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

S.no. Topic Date Pg. no.

Remarks
PYTHON PROGRAM
▪ Working With Functions

# PROGRAM 1: -
@ To find sum of two numbers.

def sum(x,y):

s=x+y

print(s)

return(s)

x=int(input("Enter Number 1:"))

y=int(input("Enter Number 2:"))

sum(x,y)

# PROGRAM 2: -
@ To write table of any two numbers.

def table():

a=int(input("Enter No:"))

for i in range(1,11):

b=a*i

print(a,"X",i,"=",b)

table()
n=int(input("Enter No:"))

f=1

for i in range(1,n+1):

f=i*f

print(f)

fact()

# PROGRAM 5: -
@ To calculate simple interest.

def Loop_SI(x,y,z):

s=(x*y*z)/100

print("Simple interest =",s)

ch="yes"

while ch=="yes":

a=int(input("Enter Amount:"))

b=int(input("Enter Rate:"))

c=int(input("Enter Time:"))

Loop_SI(a,b,c)

ch=input("Do you want to continue? (yes/no):")

if ch=="no":

break
▪ File Handling

# PROGRAM 1: -
@ to calculate number of lines in a text file .

def calc_lines():

f=open("diary.txt","r")

b=f.readlines()

c=len(b)

print(c)
f.close

calc_lines()

# PROGRAM 2: -
@ to enter multiple records in binary file.

import pickle

def write():

f=open("bin.dat","wb")
record=[]

while True:

roll=int(input("Enter Roll:"))

You might also like