Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
57 views

CS Lab Assignment

Computer Science lab Assignment for class 12

Uploaded by

sacm291
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)
57 views

CS Lab Assignment

Computer Science lab Assignment for class 12

Uploaded by

sacm291
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/ 2

Lab Assignment

1. Write a program to define a function COUNT( S ) that accept a string and count total number of
uppercase characters, lowercase characters and digits present in it.

2. WAP to enter a list of words and define a function LASTOFF( ) that accept the list and create a new
list with last character removed from each word.
Example : if L = [„BOOKS‟, „ARE‟, „BEST‟], then after program N = [„BOOK‟, „AR‟, „BES‟]

3. Write a program to define a function COUNT( T ) that accept a nested tuple of numbers and count the
total numbers present in each element.
For Ex: If T = ((2, 1, 9), (5, 6, 1, 8), (8, 3, 1, 5)), then output should be:
element 1 = 3
element 2 = 4
element 3 = 4

4. Write definition of a method/function AddOddEven(VALUES) to display sum of odd and even


values separately from the list of VALUES.
For example, If the VALUES contain [ 15, 26, 37, 10, 22, 13 ]
The function should display
Even Sum: 58
Odd Sum: 65

5. Write the definition of a function Sum5(L) in Python, which accepts a list L of integers and displays
the sum of all such integers from the list L which end with the digit 5.
For example, If the list L is passed [ 125, 15, 13, 35, 23]
then the function should display the sum of 125, 15, 35, i.e. 175 as follows :
Sum of integers ending with digit 5 = 175

6. Write a program to define a function MarksDetails( ) that accept a dictionary of n elements having
student name as key and total marks as value. Print the entire dictionary content along with the name
of the student having highest marks.

7. WAP to define a function LShift (L,n) that accepts a list Arr of numbers and a number n by which all
elements of list are shifted to left.
For example,
L= [10, 20, 30, 40, 12, 11] and n=2.
Output: Arr=[30,40,12,11,10,20]
8. Write a function CountLine() in python to count the number of lines in a text file „myfile.txt’ which
ends with alphabet ‘a’or „i‟.

9. Define a function displayWords ( ) in Python to read the contents of the text file “India.txt” and
display and count words “India” or “india” present in it.

10. Write a function Disp_Word ( ) in python to read lines from a text file „SAMPLE.TXT‟ and display
those words which are less than 5 characters long.

11. A binary file “Stusent.dat” has structure [AdmNo, Name, Marks],


Write a user defined function CreateFile () to input data for a record and add to Student.dat.

12. A binary file “Stusent.dat” stores the records having their structure as [AdmNo, Name, Marks] ,
Define a function ReadData ( ) to read and display the records of the students whose marks is greater
than 400.

13. A CSV file “StdRecords.csv” has structure [AdmNo, Name, Marks], Write a user defined function
CreateCSV () to input data for a record and add to StdRecords.csv.

14. A CSV file “EMPDETAILS.CSV” stores the records having their structure as
[EMPNo, EName, SALARY], Define a function DISPLAY ( ) to read and display the records of the
employee‟s whose salary is less than 30000.

15. Coach Amit Kumar stores the races and participants in a dictionary. Write a program, with separate
user defined functions to perform the following operations:

 Push the names of the participants of the dictionary onto a stack, where the distance is more
than 100.

 Pop and display the content of the stack. For example: If the sample content of the dictionary
is as follows: Races ={100:'Varnika', 200 :'Sumit', 400:'Rahul', 800:'Ankit'}

You might also like