Programs List
Programs List
Computer Science
Full Marks: 30 Duration: 3 hrs
General Instructions:
1. For Question I:
a. Attempt one sub-part allotted to you.
b. Write the question allotted to you, followed by the program, then the output.
c. Your program should have at least 5 comments.
2. For Question II:
a. Answer four queries allotted to you.
b. Write each question allotted to you, followed by the answer, then the output.
Lab Test
Python Report File Project Viva
SQL
Docu- Code commands
Logic
mentation Quality
4 2 2 4 7 8 3
For the questions on text file, assume the following content of "India.txt".
I 1. Write a program to create a dictionary containing numbers from 1 to 7 as keys and the days of
7. The script should print the matching day of the week. If a number outside the range 1 to 7 is
input, the script should display an error. Show output of a valid input as well as an invalid input.
2. At a casino, to play, you have to pay Re. 1. Two dice are thrown. If the two dice show the same
number, you get Rs 10; else you lose your Re. 1. WAPS to simulate the throw of the dice, using
random integers. Show output of the player winning and another of the player losing.
3. Write a Python script to show mutability and immutability of Python data types.
4. Write a Python script to show the working of local and global variables.
Page 1 of 4
5. Write function (name="Mohan", age=49) to demonstrate the working of positional, keyword &
default arguments. Invoke the functions with the following values:
6. Write noOfChars() that returns the number of characters in a text file "India.txt". For the given
text file, the output should be: 46 characters
7. Write typesOfCharacters() to read a text file "India.txt" & print the number of alphabets, digits &
special characters in it. For the given file, the output should be: 32 alphabets, 6 digits, 8 specials
Invoke Add(), to append 3 records to the file. Invoke Display() to display the records.
Invoke Modify() to modify the file.
Invoke Display() to display the modified records.
Page 2 of 4
11. Write the following functions:
WriteCSV() to write the details of 3 inventors as shown below, to a CSV file "Inventors.csv".
1, "Linus Torvalds", "Linux Kernel"
2, "Tim Berners-Lee", "World Wide Web"
3, "Guido van Rossum", "Python"
ReadCSV() to read the file contents and print the same.
Invoke the functions.
14. Write a menu-based program with functions to add, delete and display records of hostel
residents using a list as a stack. A record of hostel should contain the following fields:
HostelName, Rooms, Residents. The format of the menu is shown:
a) Add Hostel
b) Delete Hostel
c) Display all Hostels
d) Exit
Push() should ask the user for Hostel details, convert it into a list and add it to the stack.
Pop() pops 1 element from stack and displays U
Page 3 of 4
II Answer the four queries allotted to you, with reference to tables accessories and shoppe.
1. To display id and sname of shops from table shoppe located in 'GK II'.
2. To display shoppe names from table shoppe which contains the word 'Tech'.
3. To display each accessory name without repetition.
4. To display name, id & sname of accessories sold by Tech Shoppe.
5. To display details of accessories whose price is more than 10000.
6. To display shop names whose name begins with 'G'.
7. To display the Natural Join of the 2 tables for id S001.
8. To display details from both tables where price is not known.
Page 4 of 4