S24 - Bigdata Lab Final 005
S24 - Bigdata Lab Final 005
S24 - Bigdata Lab Final 005
Marks Obtained
Note:
Question Understanding is also a part of the Exam.
Write to-the-point answer. No need to give extra details to make your answer long.
Return the question paper to the invigilator
Q1. You are tasked with implementing a Scala program to process a list of student exam scores. Your program should
include the following functionalities:
1. Processing Functions: Implement the following functions to process the list of exam scores:
o calculateAverage(scores: List[Int]): Double: Calculates the average score from the
given list of exam scores.
o countPassFail(scores: List[Int]): (Int, Int): Counts the number of passing and failing
scores in the list.
o findTopScore(scores: List[Int]): Int: Finds the highest score in the list.
2. Pattern Matching: Utilize pattern matching to handle different cases efficiently.
3. Recursive Function: Implement recursive functions where appropriate to iterate through the list.
4. Main Program: Write a main program that demonstrates the usage of the implemented functions. Provide a
sample list of exam scores, and then calculate and display the average score, the number of passing and failing
scores, and the highest score.
Page 1|9
********** Best of Luck **********
Department of Information Engineering Technology (IET)
National Skills University Islamabad
Evaluation Criteria:
Correct implementation of processing functions using pattern matching and recursion - 10 marks
Efficient use of pattern matching to handle different cases - 5 marks
Successful demonstration of the main program with appropriate output - 10 marks
Page 2|9
********** Best of Luck **********
Department of Information Engineering Technology (IET)
National Skills University Islamabad
Page 3|9
********** Best of Luck **********
Department of Information Engineering Technology (IET)
National Skills University Islamabad
===================================================
===================================================
Q2 You are given a dataset containing information about students' performance in exams. Your task is to use
PySpark to perform the following operations:
Evaluation Criteria:
uploaded = files.upload()
print("Schema:")
df.printSchema()
df.show(5)
df = df.fillna(mean_scores_dict)
avg_scores.show()
Page 5|9
********** Best of Luck **********
Department of Information Engineering Technology (IET)
National Skills University Islamabad
passed_failed_counts.show()
failed_counts.show()
avg_scores_df = avg_scores.toPandas()
plt.bar(avg_scores_df.columns, avg_scores_df.iloc[0])
plt.xlabel("Subjects")
plt.ylabel("Average Score")
plt.show()
passed_failed_counts_df = passed_failed_counts.toPandas()
failed_counts_df = failed_counts.toPandas()
plt.xlabel("Subjects")
plt.ylabel("Count")
plt.legend()
plt.show()
print("The analysis provides insights into the average scores, pass rates, and overall performance of students across different
subjects.")
Schema:
root
|-- Student_ID: integer (nullable = true)
|-- BIGDATA: integer (nullable = true)
|-- OOPS: integer (nullable = true)
|-- DSA: integer (nullable = true)
|-- COAL: integer (nullable = true)
Page 6|9
********** Best of Luck **********
Department of Information Engineering Technology (IET)
National Skills University Islamabad
+------------+---------+--------+---------+---------+--------------+
|avg(BIGDATA)|avg(OOPS)|avg(DSA)|avg(COAL)|avg(DBMS)|avg(MARKETING)|
+------------+---------+--------+---------+---------+--------------+
| 50.36| 42.04| 49.2| 45.44| 44.16| 43.56|
+------------+---------+--------+---------+---------+--------------+
+-------+----+---+----+----+---------+
|BIGDATA|OOPS|DSA|COAL|DBMS|MARKETING|
+-------+----+---+----+----+---------+
| 16| 7| 9| 7| 7| 7|
+-------+----+---+----+----+---------+
+-------+----+---+----+----+---------+
|BIGDATA|OOPS|DSA|COAL|DBMS|MARKETING|
+-------+----+---+----+----+---------+
| 9| 18| 16| 18| 18| 18|
+-------+----+---+----+----+---------+
Page 7|9
********** Best of Luck **********
Department of Information Engineering Technology (IET)
National Skills University Islamabad
Page 8|9
********** Best of Luck **********
Department of Information Engineering Technology (IET)
National Skills University Islamabad
The analysis provides insights into the average scores, pass rates, and overall
performance of students across different subjects.
=========================================================
=========================================================
=========================================================
Page 9|9
********** Best of Luck **********