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

19CS403 PYTHON LAB EXAM Questions

This document contains details about a Python programming lab examination, including: 1) The exam consists of 2 programs worth 35 marks total and a viva voce section worth 10 marks, for a total of 50 marks. 2) Program 1 is worth 5 marks for the write up and 10 marks for execution, and Program 2 is worth 5 marks for the write up and 20 marks for execution. 3) The exam also includes 17 multiple choice questions covering a range of Python programming concepts and tasks.

Uploaded by

Sharan Shetty
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
200 views

19CS403 PYTHON LAB EXAM Questions

This document contains details about a Python programming lab examination, including: 1) The exam consists of 2 programs worth 35 marks total and a viva voce section worth 10 marks, for a total of 50 marks. 2) Program 1 is worth 5 marks for the write up and 10 marks for execution, and Program 2 is worth 5 marks for the write up and 20 marks for execution. 3) The exam also includes 17 multiple choice questions covering a range of Python programming concepts and tasks.

Uploaded by

Sharan Shetty
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

(ISO 9001:2015 Certified)

Accredited with ‘A’ Grade by NAAC


Department of Computer Science and Engineering

19CS403: Python Programming Lab Examination

Evaluation
Evaluation Evaluation Criteria Marks
Component
Program 1 Write up 05
Execution 10
Program 2 Write up 05
Execution 20
Viva-Voce 10
Total 50

PART-A
Q. Question Description CO
No
1 Build a program called “GuessMyNumber”. The computer will generate a random 1
number between 1 and 10. The user types in a number and the computer replies
“lower” if the random number is lower than the guess, “higher” if the random number
is higher , and “correct!” if the guess is correct. The player can continue guessing until
the guess is right.
2 Write a python program to create two separate lists of integers. List elements of both 1
the list shall be read from keyboard input. Program should display “Lists are
symmetrical” if both the lists contain equal number of even and odd numbers.
3 Write a Python program to generate first ‘n ’Fibonacci numbers. 1
4 Given below is the list of marks scored by students. Find top three scorers for 2
the course and also display the average marks scored by all students.
Implement the solution using Python Programming.

Student Marks
Name
John 86.5
Jack 91.2
Jill 84.5
Harry 72.1
Joe 80.5
(ISO 9001:2015 Certified)
Accredited with ‘A’ Grade by NAAC
Department of Computer Science and Engineering

5 Write a program to count the number of capital letters and display the position of each 2
capital letter in a user entered string via keyboard.
6 Write a program to count the number of each vowel in a given string. 2
7 Write a program to remove all punctuations like “’!()-[]{};:’’’,\,<>,/,?,@,#,$,%^&*_~” 2
from the string provided by the user.
8 Consider two strings, String1 and String2 and display the merged string 2
as output. The merged string should be the capital letters from both the
strings in the order they appear.
Sample Input:
String1:ILikeC
String2:MaryLikesPython
Merged string should be ILCMLPS

9 Write a binary search function which searches an item in a sorted list. 2


The function should return the index of element to be searched in the list.
10 Write a function that returns the index of the smallest element in a list of 2
integers. If the number of such elements is greater than 1, return the smallest
index. Use the following header:
def indexOfSmallestElement(lst):
Write a program that prompts the user to enter a list of numbers, invokes this
function to return the index of the smallest element and displays the index.
11 Write a program that will count the number of characters, words, and lines in a file. 2
Words are separated by a white-space character. Your program should prompt the user
to enter a filename.
12 Suppose that a text file contains marks for 6 courses for a student in a line. Each course 3
marks is separated by space as delimiter. File contains marks for ‘n’ number of
students in separate lines. Write a program that reads themarksfrom the file for each student
anddisplays the totaland average. Your program should prompt the user to enter a filename.
PART-B
(ISO 9001:2015 Certified)
Accredited with ‘A’ Grade by NAAC
Department of Computer Science and Engineering

13 Design a class named Account that contains: 3


A private int data field named accountno for the account.
A private float data field named balance for the account.
A constructor that creates an account with the specified accountno and
Initial balance (default 100).
A method named withdraws that withdraws a specified amount from the account. A minimum
balance of 100 should be maintained for each account.
A method named deposit that deposits a specified amount to the specific account.
Write a program that maintains ‘n’ number of Account objects with unique accountno and supports
following operations.
a) New account creation
b) deposit operation for a given account no
c) withdraw operation for a given account no
d) Display account no with highest balance

14 Develop python program to perform the below mentioned operations. 3


a) display total marks scored by each student
b) Display top scorer and the top score
c) Show the graph depicting score range versus no: of students. A sample graph is shown below.

Scenario: There are 10 students and answers to 10 multiple choice questions of each student is stored
in a file called marks.txt. Each answer is delimited by space. Each line provides a student’s answers
to the questions, as shown below. The answer key is stored in a file named keys.txt. The format of
answer keys as shown below.

Key D B D C C D A E A D
Marks.txt

Student0 A B A C C D E E A D
Student1 D B A B C A E E A D
Student2 E D D A C B E E A D
Student3 C B A E D C E E A D
Student4 A B D C C D E E A D
Student5 B B E C C D E E A D
Student6 B B A C C D E E A D
Student7 E B E C C D E E A D
Student8 C B A E D C E E A D
Student9 A B D C C D E E A D
(ISO 9001:2015 Certified)
Accredited with ‘A’ Grade by NAAC
Department of Computer Science and Engineering

15 Write a program to create a list to maintain country names, respective capital and its population. The 3
program should support following operations

a) To enter country name, capital and its population.


b) To accept the name of a country as an input and print the corresponding capital name and
population as output. Otherwise, the program should print an appropriate message if the country is
not found in the list.
c) To display the country name with highest population.

16 CIE and SEE marks of Ten students for 3rd semester is stored in a CSV file. Marks details are 4
stored in a worksheet and the format of marks details is shown below. The worksheet
provides CIE and SEE marks for the courses CS301 TO CS306. Perform data analysis using
numpy, pandas, matplotlib python libraries for the following scenarios.
a) Display the subject code with highest avg score in the semester
b) Visualize each student’s avg CIE and avg SEE for 3rd sem using a bar chart graph.
Sample chart is shown below.
(ISO 9001:2015 Certified)
Accredited with ‘A’ Grade by NAAC
Department of Computer Science and Engineering

17 CIE and SEE marks of Ten students for 3rd semester are stored in a CSV file. Marks details 5
are stored in a worksheet and the format of marks details is shown below. The worksheet
provides CIE and SEE marks for the courses CS301 TO CS306. Perform data analysis using
numpy, pandas, matplotlib python libraries for the following scenarios.
a) Display the usn with highest total score.
b) Visualize grade analysis (No of students with S,A,F grades) for each subjects using a
bar chart graph. Sample chart is shown below.
Grade calculation: S : CIE + SEE >=90

A: (CIE + SEE >= 80) AND (CIE + SEE < 90)


F: (CIE + SEE < 40)
(ISO 9001:2015 Certified)
Accredited with ‘A’ Grade by NAAC
Department of Computer Science and Engineering
(ISO 9001:2015 Certified)
Accredited with ‘A’ Grade by NAAC
Department of Computer Science and Engineering

18 Placement data distribution across various branches and companies is shown in the table 5
below for the academic year 2020.Perform data analysis using numpy, pandas, matplotlib
python libraries for the following scenarios.
a) Display the branch name with highest no of total placements across all the companies.
b) Display the company name with highest no of total placements across all the branches.
c) Display branch name and company name having highest no of placements.(e.g,’CSE’-‘DXC’)
d) Draw a pie chart showing distribution of total placements across all the branches.
e) Draw a pie chart showing distribution of total placements across all the companies.
Cap- Hexa TCS Hack-
Mind- gemi Acce- - Code- TCS Cogni- with Infosys
Branch DXC Tree ni nture ware vita Ninja zant Infy (CRP)
Civil 2 1 1 1 1
Mech. 15 1 1 7 2 6
E&E 9 4 6 4 1 3 4 5
E&C 34 18 39 22 3 2 15 10 23
CSE 76 66 34 44 4 5 10 13 6 21
ISE 39 28 16 20 4 9 9
BT 2
MCA 9 5 1 3 1 2

You might also like