0% found this document useful (0 votes)
22 views3 pages

Sainik School Ambikapur CS Exam 2024-25

The document outlines practical examination tasks for Computer Science (083) at Sainik School Ambikapur for the academic year 2024-25. It includes various programming assignments in Python, such as file handling, stack implementation, sorting algorithms, and SQL database creation. Each task is designed to assess students' understanding and application of programming concepts and data structures.

Uploaded by

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

Sainik School Ambikapur CS Exam 2024-25

The document outlines practical examination tasks for Computer Science (083) at Sainik School Ambikapur for the academic year 2024-25. It includes various programming assignments in Python, such as file handling, stack implementation, sorting algorithms, and SQL database creation. Each task is designed to assess students' understanding and application of programming concepts and data structures.

Uploaded by

labphysics14
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

SAINIK SCHOOL AMBIKAPUR

COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

1. Write a program to read content of a file “[Link]” and print number of


occurrence of the word “do” in it. Do not count the within a word eg. “done”.
Ex :- I will do it, if you request me to do it. It would have been done much earlier

2. Write a Menu driven program to implement stack:


 Push
 Pop
 Peek
 Display
 Exit

SAINIK SCHOOL AMBIKAPUR


COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

1. Write a function in Python that counts the number of “Me” or “My” words present
in a text file “[Link]”
2. Write a program using function SUMFUN( ) with arguments X and N which
returns the sum of N terms of the following: x-x3 /3 + x5 /5 – x7 /7 + x9 /9…..

SAINIK SCHOOL AMBIKAPUR


COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

1. Write a python program using function PUSH(Arr), where Arr is a list of numbers.
From this list push all numbers divisible by 5 into a stack implemented by using a
list. Display the stack if it has at least one element, otherwise display appropriate
error message.
2. Program to write data in a csv file [Link]. and then read and display the data
from [Link] file.

SAINIK SCHOOL AMBIKAPUR


COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

1. Write a program to accept an array of marks of ten students and sort using
Bubble/Selection sort.
2. Write a python program using function POP(Arr), where Arr is a stack
implemented by a list of numbers. The function returns the value deleted from the
stack.

SAINIK SCHOOL AMBIKAPUR


COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

1. Write a program in python to create a stack “student” with details of student name
and their marks. Write Operation for Push, Pop and Traversal operation using menu.
2. WAP to open a file and count the Number of Lines, No. of Words and No. of
Characters in a given file.
SAINIK SCHOOL AMBIKAPUR
COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

1. Write a Program to create a binary file to store roll number and name and search any
roll number and display the respective name.
2. Write a python program to create a stack of Book’s record which contains [Book
code, Book title, Book price].
 Write function PUSH to add record into the stack
 Write function POP and display the record in the stack

SAINIK SCHOOL AMBIKAPUR


COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

[Link] a function in Python that counts the number of “this” or “that” words present
in a text file “[Link]”
2. Write a python program to create stack Sport_Stack to store age of sportsman using
stack implementation as list. Write Operation for Push, Pop and Traversal operation
using menu.

SAINIK SCHOOL AMBIKAPUR


COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

1. Write a function in Python that counts the number of “Me” or “My” words present
in a text file “[Link]”
2. Write a python program to create a stack of Book’s record which contains [Book
code, Book title, Book price].
 Write function PUSH to add record into the stack
 Write function POP and display the record in the stack

SAINIK SCHOOL AMBIKAPUR


COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

[Link] a function in Python that counts the number of “this” or “that” words present
in a text file “[Link]”
2. Write a Menu driven program to implement stack:
 Push
 Pop
 Peek
 Display
 Exit
SAINIK SCHOOL AMBIKAPUR
COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

[Link] a function in Python that counts the number of “this” or “that” words present
in a text file “[Link]”
2. Write a python code to create a SQL table Cadet (using pymysql interface ) with
following specifications:
 Schno – int – size 4 – Primary Key
 Name – char – size 15
 DOB – Date
Note the following to establish connectivity between Python and MYSQL:
 Username is root
 Password is ssap
Insert one row as given below:
SchNo Name DOB
851 Shivam Kumar 21-06-2007

SAINIK SCHOOL AMBIKAPUR


COMPUTER SCIENCE (083) , PRACTICAL EXAMINATION 2024-25

1. Write a function in Python that counts the number of “Me” or “My” words present
in a text file “[Link]”
2. Write a python code to create a SQL table Student (using pymysql interface )
with following specifications:
 Admno – int – size 4 – Primary Key
 SName – char – size 15
 DOB – Date
Note the following to establish connectivity between Python and MYSQL:
 Username is root
 Password is tiger
Insert one row as given below:
AdmNo SName DOB
1229 Harsh Bhati 21-03-2006

Common questions

Powered by AI

When designing a Python program to handle CSV files, considerations include choosing the appropriate CSV library methods for reading and writing, such as using 'csv.writer()' and 'csv.reader()' from Python's built-in 'csv' module. Ensure that the delimiter used matches the data's format and take care of quoting characters and handling special cases like long strings or embedded commas. It's crucial to handle file streams carefully—open files using 'with' for automatic closure and manage potential errors with try-except blocks to prevent data loss or corruption. Considerations for encoding, especially if dealing with special characters, are also important .

To count specific words in a text file ignoring variations, employ techniques including regular expressions for pattern recognition. For example, '\bword\b' in 're.findall()' ensures exact matching by considering word boundaries. This approach avoids capturing variations like 'words' if counting 'word'. Natural Language Processing (NLP) libraries like NLTK can tokenize text to ensure words are accurately separated. Pre-processing steps, such as converting text to lower case, ensure case insensitivity. Combining these techniques provides robust solutions for precise word counts while ignoring linguistic variations .

Designing a menu-driven stack program in Python involves creating functions for basic stack operations: push (to add elements), pop (to remove elements), and peek (to view the top element). The menu can be implemented with a loop that continues until an exit option is selected. You prompt the user with options, take input to select the desired operation, and call the appropriate function. Each function interacts with a list that represents the stack. For example, 'push' adds an element using 'list.append()', 'pop' removes the top using 'list.pop()', and 'peek' accesses the top element using 'list[-1]' .

Creating a stack in Python for managing sports data involves using a list as the base structure for stack operations. Implement the 'push' feature by appending ages to the list, use 'list.pop()' to implement the 'pop' feature, removing the latest age, and a traversal feature can iterate over the list to display each age, ideally in reverse to mirror stack behavior. The program typically includes a user menu for operations selection, with appropriate logic to handle empty stack conditions and ensure data consistency .

Python can interact with MySQL databases using connectors like 'pymysql'. Establishing a connection involves specifying database credentials such as username and password. For creating tables, SQL commands are executed through a cursor obtained from the connection object. To manage sports data, create a table with relevant fields, e.g., athlete ID, name, and sport. Inserting data involves executing an 'INSERT' SQL command with values supplied as a tuple. After operations, it is critical to commit the transaction to save changes and close the connection to prevent leaks. Error handling for connectivity and command execution should also be considered .

File handling in Python can be used alongside text processing libraries or regular expressions to count word occurrences. When reading a file, lines of text are collected, ideally using 'with open()' to handle the file securely. Each line is then split into words. To specifically count occurrences of words like 'do' without counting the pattern within other words such as 'done', use string methods or regular expressions, e.g., '\bdo\b' ensures boundaries around the word 'do' are considered. Use 're.findall()' to find all occurrences and simply return the count .

Developing a Python program to sort student marks strategically involves selecting an efficient sorting algorithm based on data characteristics, such as size and distribution. Algorithms like Quick Sort or Merge Sort offer better performance for large datasets compared to Bubble Sort. Implementing the chosen algorithm involves leveraging Python's built-in sorting methods, such as 'sorted()' or 'list.sort()' for in-place sorting, which are optimized for various data patterns. The sorted data enables performance insights by facilitating operations like median calculation, percentile analysis, or identifying top performers, thereby contributing to effective data-driven decision-making in educational contexts .

Implementing arithmetic series calculations in Python showcases effective function design through parameterization and reuse. A function like 'SUMFUN()' that computes a series such as x - x^3/3 + x^5/5 can use parameters (X and N) for flexibility, allowing different inputs for the base and number of terms. The function applies a loop or recursive method for accumulating the series, considering sign alternation for each term. This encapsulation enhances code readability, maintainability, and enables easy integration or modification within larger systems, illustrating the principles of abstraction and separation of concerns .

Managing a stack to store book records in Python requires handling each record as a tuple or class containing book attributes like code, title, and price. Efficient management involves ensuring stack operations (push and pop) maintain the order of entry, with 'list.append()' for push and 'list.pop()' for pop operations. Error handling for operations when the stack is empty, possibly using exceptions, is crucial. Traversing the stack for display should consider book attributes to present data comprehensively. Stacks automate record history management, suitable for scenarios where recent access is prioritized .

Bubble Sort and Selection Sort are simple algorithms used to sort arrays or lists. Applying either to sort an array of student marks involves iterating over the collection multiple times. Bubble Sort compares adjacent elements and swaps them if they are in the wrong order, effectively bubbling the largest unsorted element to its correct position after each complete pass. Selection Sort, on the other hand, selects the minimum element from the unsorted segment and swaps it with the first unsorted element. Bubble Sort continues until no swaps are needed, while Selection Sort completes after n-1 passes, where n is the element count. Selection Sort performs fewer comparisons and is generally more efficient on average .

You might also like