Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

5 Wap to count the number of record present in student.csv file.

6 Wap to search and print the record of specific file.


7 Wap to read a text file and display the count of vowels and consonants in that file
1 Write python program to find diameter,circumference and area of a circle using
function with a practical example.
2 Write a python program to exchange the values of two numbers with practical example

3 Write a python program to perform the basic arithmetic operations in a menu-driven


program with different functions.
4 Wap to print roll no, names, marks of all the students of a class and store
these details in a text file named marks.txt

WAP to count the number of record present in student.csv file

import csv

with open("C:\\ Users\\narayana\\Desktop\\Student.csv")as f:

csv_reader=csv.reader(f)
row=[]

for rec in csv_reader:

if csv_reader.line_num==0:

continue
row.append(rec)
value=len(list(csv_reader))
print(row)
print(value)

OUTPUT
WAP to search and print the record of specific file

import csv

with open("C:\\Users\\narayana\\Desktop\\Student.csv") as f:

csv_reader=csv.reader(f)
n=input("Enter the name of record:")
for i in csv_reader:
if i[1]==n: print(i)

OUTPUT

WAP to read a text file and display the count of Vowels and consonants in that
file

f=open("C:\\Users\\narayana\\Desktop\\vowcon.txt","r")
c=0
v=0
s1=f.read() l=len(s1)
print(l)
for i in range(l):
if s1[i].isalpha():
if s1[i] in ("a","e","i","o","u","A","E","I","O","U"):
v=v+1
else:
c=c+1
print("Number of vowels:",v)
print("Number of consosnants:",c)

OUTPUT
Write Python Program to find Diameter,Circumference and Area Of a Circle
using function with a practical example.

import math
def cal_Diameter(radius):
return 2 * radius
def cal_Circum(radius):
return 2 * math.pi * radius
def cal_Area(radius):
return math.pi * radius * radius
r = float(input("Enter the radius of a circle: "))
diameter = cal_Diameter(r)
circumference = cal_Circum(r)
area = cal_Area(r)
print("Diameter Of a Circle = %.2f" %diameter)
print("Circumference Of a Circle = %.2f" %circumference)
print("Area Of a Circle = %.2f" %area)

OUTPUT
Write a Python Program to Exchange the Values of Two Numbers with Practical Example

def swap(x, y):


temp = x
x=y
y = temp
print("After swapping")
print("Value of first number :", x)
print("Value of second number :", y)
num1 = int(input("Enter first number :"))
num2 = int(input("Enter second number :"))
print("Before swapping")
print("Value of first number :",num1)
print("Value of second number :",num2)
swap(num1,num2)

OUTPUT

You might also like