You are on page 1of 8

BCSE101E - Computer Programming:

Python

Cycle Sheet – Phase 2

October 8, 2021
Faculty Team of FALL2021-22 – BCSE101E
Authored by:

School of Computer Science and Engineering


Vellore Institute of Technology
Vellore.
BCSE101E – Module 6

[M6_CSQ1] A string s2 is said to be a “substring” of a string s1, if s2 can be derived from


s1 by deleting some characters. Given two strings s1, s2 and starting position of the search,
develop an algorithm and write a python code to search the substring s2 and print the
position of substring in main String s1, if found. Otherwise print “NotAvailable”. [CO2] [L1]

For example

Input:

s1=”mask”

s2=”ask”

SearchPosition=0

Output:

FoundPosition=1.

For the same s1, s2, if SearchPosition is 3 then FoundPosition= -2.

Test Cases are

case=1 case=2 case=3


input=police input=cellphone input=drama
BCSE101E - Computer Programming: Python

ice phone doctor


2 6 2
output=1 output=-2 output=NotAvailable

[M6_CSQ2] Develop a program using function to solve a classic ancient puzzle. We count
m heads and n legs among chickens and rabbits in a farm. How many rabbits (x) and chickens
(y) do we have? If m and n are 35 and 94, then the x and y will be 12 and 23. [CO2] [L1]

For example:

Input:

35

94

1
Output:

12

23

Test Cases are

case=1 case=2 case=3


input= 35 input= 22 input=33
94 66 90
output= 12 output= 11 output=12
23 11 21

[M6_CSQ3] Design a python program to list the students’ name who secured

(i) exact mean score

(ii) above mean score and

(iii) below mean score

of the class using user defined function. [CO2] [L1]

For example, if the input is {‘siva’: 40, ‘kumar’:60, ‘arun’:80}, then the output is,

kumar

arun

BCSE101E - Computer Programming: Python


siva

Test Cases are

case=1 case=2 case=3


input= ‘siva’: 40, input= ‘abc’: 10, input= ‘sachin’: 70,
‘kumar’:60, ‘arun’:80 ‘def’:80, ‘ijk’:60 ‘doni’:80, ‘kohli’:50
output= kumar output= def, ijk output= sachin, doni
arun abc kohli
siva

2
[M6_CSQ4] Write a python program to generate a quiz using two files, named Questions.txt
and Answers.txt. The program opens Questions.txt and displays the question with options
on the screen. The program will verify the Answer.txt file and display the scores. [CO2] [L1]

For example, Questions.txt file contains the following details:

1. Who is the prime minister of India?

A. Narendra Modi B. Shivraj Patil

2. Who is the President of USA?

A. Donald Trump B. Joe Biden

Answer.txt file contains the following details:

1.A

2.B

If inputs are A and B, then the Score is 100

Test Cases are

case=1 case=2 case=3

input= A input: A input=B


B A A

output=100 output=50 output=0


BCSE101E - Computer Programming: Python

[M6_CSQ5] Write a python program that defines a user defined function called frequency ()
which identifies and count the frequency of occurrences of the words in a given sentence
that is passed to the user defined function. The frequency occurrences of the word should
be returned in sorted order by words in the string. [CO2] [L1]

For Example:

Input:

Sentence = “It is true for all that that that that refers to is not the same that that that to refers
to “

Output:-

3
It:1

all:1

for:1

is:2

not:1

refers:2

same:1

that:7

the:1

to:3

true:1

Test Cases are

case=1 case=2 case=3


input= I am a input= I Am a CORE input= It is true for all
student of VIT my CSE Student of VIT that that that that
friends are student output= Am-1 refers to is not the
of VIT CORE – 1 same that that that to
output= I – 1 CSE-1 refers to
VIT – 2 I–1 output= It:1

BCSE101E - Computer Programming: Python


a -1 Student-1 all:1
am – 1 VIT-1 for:1
are – 1 a-1 is:2
friends – 1 of -1 not:1
my -1 refers:2
of – 2 same:1
student – 2 that:7
the:1
to:3
true:1

4
[HoT Question]

Design a python program that merges two files and write the results to new file (THREE.txt).
The merge operation should take place line by line. The first line of the merged file should
contain the first line of TWO.txt and the second line of the merged file should contain the
first line of the ONE.txt.

For Example:- The content of ONE.txt and TWO.txt are input and the content of THREE.txt is
the output.

Input:-

Python Language is old Programming language!!!

Which Language is Old Programming Language?

Output:

Which Language is Old Programming Language?

Python Language is old Programming language!!!

Test Cases are

case=1
input= This is same as C Programming language used to do more
complex problem.
Usually a file is kept on a permanent storage media, e.g. a hard
drive disk.
BCSE101E - Computer Programming: Python

output= Usually a file is kept on a permanent storage media, e.g. a


hard drive disk.
This is same as C Programming language used to do more complex
problem.
case=2
input= a hard drive disk problem.
Usually a file is kept on a permanent storage media,
output= Usually a file is kept on a permanent storage media, a hard
drive disk.
case=3
input= This is a Simple Programming language used to do more
complex problem. Yes, This is Not a very Simple Programming
language used to do more complex problem.

5
A file or a computer file is a chunk of logically related data or
information which can be used by computer programs. Usually a file
is kept on a permanent storage media, e.g. a hard drive disk.
output =
A file or a computer file is a chunk of logically related data or
information which can be used by computer programs. This is a
Simple Programming language used to do more complex problem.
Usually a file is kept on a permanent storage media, e.g. a hard drive
disk. Yes, This is Not a very Simple Programming language but used
to solve more simple to complex problem.

BCSE101E - Computer Programming: Python

6
BCSE101E – Module 7

[M7_CSQ1] Write a NumPy program to compute the mean, standard deviation, and
variance of a given array along the second axis. [CO2] [L1]

[M7_CSQ2] Create a NumPy program to create a structured array from given student
name, height, class and their data types. Now sort by class, then height if class are equal.
[CO2] [L1]

[M7_CSQ3] Develop a NumPy program to sort the student id with increasing height of the
students from given students id and height. Print the integer indices that describes the sort
order by multiple columns and the sorted data. [CO2] [L1]

[M7_CSQ4] Design a Pandas program to join the two given data frames along rows and
assign all data. [CO2] [L1]

[M7_CSQ5] Write a Pandas program to convert all the string values to upper, lower cases
in a given pandas series. Also find the length of the string values. [CO2] [L1]

[M7_CSQ6] Create a Pandas program to create

• Datetime object for Jan 15 2012.

• Specific date and time of 9:20 pm.

• Local date and time.


BCSE101E - Computer Programming: Python

• A date without time.

• Current date.

• Time from a datetime.

• Current local time. [CO2] [L1]

You might also like