Professional Documents
Culture Documents
Honor Code:
I pledge to follow the Honor Code and to obey all rules for taking this test as specified by the
proctor.
I understand that when asked to follow the Honor Code on this test, I must follow the rules
below.
· There are 3 parts of questions to answer. When following the Honor Code, the
candidate strictly observes the time allotted to complete this test which is 1.0 hour.
· When following the Honor Code, the candidate must work entirely alone on this test.
Access to computer, phone or any communication device is strictly prohibited.
· When following the Honor Code, the candidate should not refer to any book or
material which might or might not help in answering the test.
· When following the Honor Code, the candidate may not share information about any
aspect of the test with anybody who has or has not already taken the test.
· When following the Honor Code, the candidate must direct all questions concerning
the test to the proctor.
The duration of the complete test is 1.0 hour. (Python and SQL)
PYTHON
Instructions:
1. This (Python) test is of 25 marks in total, which are split as mentioned below.
2. Part 1 contains 5 basic questions regarding strings, lists, tuples, dictionaries and
functions. (14 marks)
3. Part 2 contains 2 questions of Lambda function and list comprehension. (3 marks)
4. Part 3 contains 2 questions relating to Pandas Dataframes. (8 marks)
5. Code to create the data frames for the tables required for Part 3 of the test.
import pandas as pd
import numpy as n
dict1 = {'ID':[1,2,3,4,5],'Name':['Alpha','Bravo','Charlie','Delta','Echo']}
dict2 = {'ID':[2,2,5,3,1,1,4,4],
'Sport':['Cricket','Football','Basketball','Basketball','Table tennis','Cricket','Football','Basketball']}
df3['Marks']=np.where(df3['ID']==1,np.nan,df3['Marks'])
7. Kindly save the .py file with the following naming convention:
Firstname_Lastname_Python_test.py
(For example if your name is Mark Jones the document will be named
Mark_Jones_Python.py)
Part 1 (Basics, strings, lists, tuples, dictionaries)
1. Write a python function ‘convert’ to convert a python string to a python list of words: (4
marks)
example:
example:
l1 = [1,2,3,4,5,6] l2 = [2,3,4,7,8]
new_list = [2,3,4]
example:
l1 = [1,2,2,1,3,4]
new_list = [1,2,3,4]
4. Write a Python program to find the second largest number in a list. (3 marks)
l1= [100,101,102,103,104,105]
2. Write a lambda function to find the smaller value between two elements. (1.5 marks)
Example:
Input: 2,3
Output: 2
Part 3 (Pandas DataFrames):
Use the code in the instructions to create the dataframes for the 3 tables above.
Using the above 3 tables write python codes for the following questions:
1.Merge Table 1 and Table 2 on ID such that the resultant data frame has 3 columns in the
following order: ID, Name and Sport. The objective is to have all the sports played by a
person listed against their corresponding ID and Name. (4 marks)
Output:
ID Name Sports
1 Alpha Cricket
2 Bravo Cricket
2 Bravo Football
3 Charlie Basketball
4 Delta Football
4 Delta Basketball
5 Echo Basketball
2.Find the number of ID’s having marks greater than 80. Also, find the maximum and
minimum values of the column “Marks” in table 3. (4 marks)
SQL
Instructions to follow
1. The test is of 20 marks and the marks for individual questions is written beside each
question.
2. Open your web browser and go to http://www.sqlfiddle.com/.
3. Select MySQL 5.6 as the compiler
4. Paste the schema for the tables (given on next page) in the schema panel and click
on build schema.
5. For each question, send the query as well as the result you obtained in a document
named Firstname_Lastname_SQL.docx (For example if your name is Mark Jones
the document will be named Mark_Jones_SQL.docx)
*If you already have a SQL compiler on your local system, you can use it as well.
employees
joining_date
PreWork: Copy the SQL command below to create schema of the above tables in the
Schema Panel of SQLFiddle.
1. Find employee’s details (with joining date) for Emp_Id E0012 - 3 marks
2. Find number of records with Technician Job_role - 3 marks
4. Find employee’s Joining Date whose name start with “J” and end with “h” - 4 marks
Table for question 6.
t1
sno room in_time
1 A 9:00
2 B 9:45
3 E 10:05
4 A 10:30
5 E 12:00
6 B 12:50
7 D 13:00
8 C 14:20
9 B 15:15
10 C 15:20
11 D 15:55
12 E 16:05
13 A 16:20
14 D 16:40
15 A 16:50
PreWork: Copy the SQL command below to schema of the above tables in the
Schema Panel of SQLFiddle.
CREATE TABLE t1
(`sno` int, `room` varchar(1), `in_time` time);
INSERT INTO t1
(`sno`, `room`, `in_time`)
VALUES
(1, 'A', '09:00'),
(2, 'B', '09:45'),
(3, 'E', '10:05'),
(4, 'A', '10:30'),
(5, 'E', '12:00'),
(6, 'B', '12:50'),
(7, 'D', '13:00'),
(8, 'C', '14:20'),
(9, 'B', '15:15'),
(10, 'C', '15:20'),
(11, 'D', '15:55'),
(12, 'E', '16:05'),
(13, 'A', '16:20'),
(14, 'D', '16:40'),
(15, 'A', '16:50');
6. Person enters the building at 9:00 AM and exits at 17:00. Write the query to count the
number of times person enters each room - 4 marks