0% found this document useful (0 votes)
327 views

CSV Files

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)
327 views

CSV Files

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/ 14

CSV FILES

PROGRAM
Program 1
with output

Q. A csv file "Happiness.csv" contains the


data of a survey. Each record of the file
contains the following data:
● Name of a country
● Population of the country
● Sample Size (Number of persons who
participated in the survey in that country)
● Happy (Number of persons who accepted
that they were Happy)
For example, a sample record of the file may
be: [‘Signiland’, 5673000, 5000, 3426]
Write the following Python functions to
perform the specified operations on this file:
(I) Read all the data from the file in the
form of a list and display all those
records for which the population is
more than 5000000.
(II) Count the number of records in the
file…………
Program 2
with output

Q. Write a menu drive program to


perform following operations
into worldcup2023.csv
1.Add record
2. Display records
3. Search record (By Team)
4. Exit
The structure of file content is:
[team_id, team, wins, lost, titles]
STACKS
Program
Program 1
with output

Q. You have a stack named BooksStack that


contains records of books. Each book record is
represented as a list containing book_title,
author_name, and publication_year.
Write the following user-defined functions in
Python to perform the specified operations on
the stack BooksStack:
(I) push_book(BooksStack, new_book): This
function takes the stack BooksStack
and a new book record new_book as
arguments and pushes the new book
record onto the stack.
(II) pop_book(BooksStack): This function
pops the topmost book record from the
stack and returns it. If the stack is
already empty, the function should
display "Underflow".
(III) peep(BookStack): This function displays
the topmost element of the stack
without deleting it. If the stack is empty,
the function should display 'None'.
Program 2
with output

Q.write a program to create a


stack called employee, to
perform the basic operations
on stack using list. The list
contains the two values—
employee number and employee
name. the program should
include the options for
addition, deletion, and display
of employee details..

You might also like