K/L/TX Reg.
No:
Final Assessment Test – November 2024
Course: BCSE207L - Programming for Data Science
Class NBR(s): 1558/1565 Slot: G1
Time: Three Hours Max. Marks: 100
KEEPING MOBILE PHONE/ANY ELECTRONIC GADGETS, EVEN IN ‘OFF’ POSITION IS TREATED AS EXAM
MALPRACTICE
DON’T WRITE ANYTHING ON THE QUESTION PAPER
Answer ALL Questions
(10 X 10 = 100 Marks)
1. a) How does R empower Data Science Programming when compared to Python? [5] BL3 CO1
Give two specific examples and justify.
b) The image given below is that of number 7 being fed to a Neural Network for [5]
classification training. Comment on the dimension change of the input for the
training
2. Answer the following: BL2 CO1
a. How can you identify the datatype of a variable in R? [2]
b. What is the outcome of the following line of code in R? [2]
assign(“x”, c(6.9, 8.45, 3.25, 5.14))
c. What is the output of the following code in R? [2]
z <- c (0.1, 0.2, 0.3)
x <- c( 2.0, 3.1, 2.9, 4.5)
x+z
[2]
d. Are the vectors s3 and s4 same? Why?
seq(-5, 5, by=.2) -> s3
seq(length=51, from=-5, by=.2) -> s4
e. What will be the output of the following lines of code? Will the output be [2]
same or different? Why?
s5 <- rep(x, times =5)
s6 <- rep(x, each=5)
Page 1 of 5
3. The given dataset shows performance details of 10 BDS Students. BL2 CO2
Class Bonus
Reg No CAT I Discussion CGPA Attendance Marks
Score Earned
21BDSXX01 33 3 8.45 86 1
21BDSXX02 46 5 9.41 95 2
21BDSXX03 23 2 7.01 60 1
21BDSXX04 43 3 8.38 64 0
21BDSXX05 35 0 8.15 75 2
21BDSXX06 25 0 8.72 77 1
21BDSXX07 36 3 9.00 78 1
21BDSXX08 29 5 7.96 65 1
21BDSXX09 40 4 8.00 50 0
21BDSXX10 41 4 7.55 90 2
Write separate functions for each of the following in R:
i. To find the top 3 contributors to class discussions. [2]
ii. To find highest difference between attendance percentages of [2]
first 3 students in the list.
iii. To check if any student’s CAT I marks are less than 25. [2]
iv. To increase the Bonus marks by 1 if Attendance > 2 and if in [2]
top 3 Class Discussion contributors
v. To find the number of students whose Bonus marks are more than [2]
1 after computing the increase in previous sub-division (iv).
4. a) Present the ways of loading a CSV file, text file, image file, tabular data into [5] BL2 CO2
R. Support each case with R code, explain and differentiate the syntax used
for each file type.
b) Write the codes in R for: [5]
i) Create a Dataframe df1 with columns and rows:
empID: 101,102,103
salesPerson: iPhone, Samsung, OnePlus
sales: 200,100, 300
ii) Display the data in the 3rd row, 2nd column.
iii) Create another Dataframe df2 and combine the dataframes df1 and
df2 by columns and rows
iv) Move the first column to the last position
v) Rename 'sales' column to 'salesValue'
Page 2 of 5
5. Design an R pipeline to scrape data from web. Further, add specific notes on the BL4 CO3
licensing, cleaning technique, encoding reversing and assigning the data to a
variable or data frame.
6. Presidential dataset comes preloaded in tidyverse. BL3 CO3
Write the R codes for the following:
a) Display only the Republican Presidents who were Democrats
b) Display all the Democratic Presidents since the Watergate scandal of 1973
c) Compute and add the term length of each president
d) There were no presidential elections in 1962 or 1973. Write the code to
mark the term length computed from previous sub-division (c) as NA for
those two years.
e) Arrange the order of Presidents based on their term lengths starting with
the longest term.
7. Reshaping data is useful for both scientific computing and commercial BL4 CO3
applications. Elaborate how Reshaping Data is applied in Logistic Regression and
under what circumstance. Include a narrative on the data set, preprocessing and
the technique.
Page 3 of 5
8. Take a look at the flights table, observe the number of columns and rows. Also BL2 CO4
note that the column, carrier, has two-character strings.
The expansion of the two-character strings are available in another table, airlines
Write an R code that displays the expanded (Full) Airline name along with all
columns and rows of flights table. Highlight the operation you would perform to
achieve this and explain.
9.a) We have a scenario when we connect a DB to R, where we create a reference to BL3 CO4
a database table and on printing it, the dimensions show as ?? seen below. Is this
is an error? Explain elaborately.
OR
Page 4 of 5
9.b) How are the following packages/functions useful in connecting DB to R? BL3 CO4
I. DBI
II. dbplyr
III. dplyr
IV. dbConnect( )
V. tbl( )
10.a) The table given below shows 4 sets of data which is represented graphically as BL4 CO4
X1, X2, X3 and X4 below the table. Give a narrative about the visual
representation of the data describing the nature of the data.
OR
10.b) Which of the visualization idioms are suitable for designing geospatial maps? BL4 CO4
What are the four Search techniques with respect to location data? Design an
R code to create a leaflet map widget and add a tile layer that draws information
from OpenStreetMap, showing a popular location with zoom feature.
K/L/TX
Page 5 of 5