Week 7 - Graded Assignment 7 - (Sep 2025 - CT - Qualifier)
The due date for submitting this assignment has passed. Due on 2025-11-12, 23:59 IST. You may submit any number of times before the due date. The final submission will be considered for grading.
Last Submitted: You have last submitted on: 2025-11-12, 11:11 IST
Note:
Question 1
Let D be a non-empty dictionary. Choose the correct option(s). It is a Multiple Select Question (MSQ).
- Let a be a key of dictionary D, then a is always an integer.
- For keys a and b in D, if a != b then D[a] != D[b] is always True.
- For keys a and b in D, a != b is always True.
- Let D = { ‘a’: 5, ‘b’ : 4, ‘c’ : 6}, then the value of D[4] is ‘b’.
Status: Yes, the answer is correct. Score: 2
Accepted Answers:
- For keys a and b in D, a != b is always True.
Question 2
Let Z be a row in the “Words” table such that Z.Word = “reluctant”. What will be the value of alphaDict[‘t’] at the end of the execution of the following pseudocode? (NAT)
xxxxxxxxxx 1 alphaDict = {'t':2, 'c':1, 'a':1, 's':0} 2 alphaDict = updateDict(Z, alphaDict) 3 4 Procedure updateDict(Z, Dict) 5 i = 1, x = 't' 6 while(i <= Z.LetterCount){ 7 x = ith letter of Z.Word 8 if(not isKey(Dict, x)){ 9 Dict[x] = 1 10 } 11 else{ 12 Dict[x] = Dict[x] + 1 13 } 14 i = i + 1 15 } 16 return(Dict) 17 End updateDict
Your Answer: 4
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
(Type: Numeric) 4
Question 3
The following pseudocode is executed using the “Library” dataset. At the end of the execution, A stores a dictionary with the author’s name as key mapped to the number of books written by him/her. But the code may have mistakes. Identify all such mistakes (if any). Assume that all statements not listed in the options below are free of errors. It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
A = {}
2
while(Table 1 has more rows){
3
Read the first row X from Table 1
4
if(isKey(A, X.Author)){
5
A[X.Author] = 1
6
}
7
else{
8
A[X.Author] = A[X.Author] + 1
9
}
10
Move X to Table 2
11
}
- Replacing the condition given in line 4 with the statement given below will provide the correct result.
xxxxxxxxxx 1 if(not isKey(A, X.Author)) - Interchanging Line 4 and 7 will provide the correct result.
- Interchanging Line 5 and 8 will provide the correct result.
- The pseudocode will provide the correct result even without getting modified.
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
- Replacing the condition given in line 4 with the statement given below will provide the correct result.
if(not isKey(A, X.Author))
- Interchanging Line 5 and 8 will provide the correct result.
Question 4
The following pseudocode is executed using the “Library” Dataset. At the end of the execution, firstBook stores a dictionary with the author’s name as key mapped to the genre of their first published book. But the code may have mistakes. Identify all such mistakes (if any). Assume that all statements not listed in the options below are free of errors. Assume that the rows are arranged in ascending order of publication years of the books. It is a Multiple Select Question (MSQ).
xxxxxxxxxx
1
firstBook = {}
2
while(Table 1 has more rows){
3
Read the first row X from Table 1
4
if(isKey(firstBook, X.Author)){
5
firstBook[X.Author] = X.Genre
6
}
7
Move X to Table 2
8
}
- Line 1: Incorrect initialization of firstBook
- Line 4: Incorrect conditional statment
- Line 7: There should always be an “else” block after “if” block
- No mistakes
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- Line 4: Incorrect conditional statment
Question 5
What will be the value of B at the end of the execution of the following pseudocode.
xxxxxxxxxx
1
B = []
2
A = [3, 4, 5, 3, 1, 9, 4, 6, 5, 9]
3
B = doSomething(A)
4
- [3, 4, 5, 1, 9, 4, 6, 5, 9]
- [3, 4, 5, 1, 9, 6]
- [1, 6]
- [4, 1, 3, 4, 6, 5, 9]
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
- [3, 4, 5, 1, 9, 6]
Question 6
The following pseudocode is executed using the “Words” dataset and the procedure doSomething mentioned above. What will sList store at the end of the execution.
xxxxxxxxxx
1
sList = [], wList = []
2
while(Table 1 has more rows){
3
Read the first row X from Table 1
4
wList = wList ++ [X.Word]
5
if(X.Word ends with a full stop){
6
wList = doSomething(wList)
7
sList = sList ++ [wList]
8
wList = []
9
}
10
Move row X to Table 2
11
}
- List of words from the “Words” dataset.
- List of unique words from the “Words” dataset.
- List of lists of words of each sentence from the “Words” dataset.
- List of lists of unique words of each sentence from the “Words” dataset
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- List of lists of unique words of each sentence from the “Words” dataset
Question 7
The following pseudocode is executed using the “Words” dataset and the procedure doSomething mentioned above. Let explode(W) returns a list of characters of word W in the same order as they are in the word. For example explode(“thinking”) returns [‘t’, ‘h’, ‘i’, ‘n’, ‘k’, ‘i’, ‘n’, ‘g’]. Ignore the punctuations like comma, full stop and so on. What will someList store at the end of the execution.
xxxxxxxxxx
1
w = [], someList = []
2
while(Table 1 has more rows){
3
Read the first row X from Table 1
4
W = explode(X.Word)
5
someList = someList ++ W
6
Move row X to Table 2
7
}
8
9
someList = doSomething(someList)
- List of alphabets from the “Words” dataset.
- List of unique alphabets from the “Words” dataset.
- List of lists of alphabets of each word from the “Words” dataset.
- List of lists of unique alphabets of each word from the “Words” dataset
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- List of unique alphabets from the “Words” dataset.
Question 8
If seqDict[n] == 0 is a True statement, then choose the correct option(s) regarding the student with sequence number n. It is a Multiple Select Question (MSQ).
- The student has scored more than the average marks in any one of the three subjects.
- The student has not scored more than the average marks in any subject.
- The student might have scored more than the average marks either in Physics or in Chemistry
- The student has scored more than the average marks in Mathematics only
Accepted Answers:
- The student has scored more than the average marks in Mathematics only
Question 9
If seqDict[n] == 1 is a True statement, then choose the correct option(s) regarding the student with sequence number n. It is a Multiple Select Question (MSQ).
- The student has scored more than the average marks in Physics and Chemistry but not in Mathematics .
- The student has scored more than the average marks in Mathematics and might have scored more than the average marks in Physics but not in Chemistry.
- The student has scored more than the average marks in Mathematics and might have scored more than the average marks in Chemistry but not in Physics.
- The student has scored more than average marks in any two of three subjects.
Status: Yes, the answer is correct. Score: 3
Accepted Answers:
- The student has scored more than the average marks in Mathematics and might have scored more than the average marks in Physics but not in Chemistry.
- The student has scored more than the average marks in Mathematics and might have scored more than the average marks in Chemistry but not in Physics.
Question 10
The following pseudocode is executed using the “Words” dataset. Let unique(L) returns the list of unique elements of L. What will wCount represent at the end of the execution of the pseudocode? Ignore the upper and lower case, and punctuation symbols while comparing with other words.
xxxxxxxxxx
1
wList = [], uniqueList = []
2
wCount = {}
3
while(Table 1 has more rows){
4
Read the first row X from Table 1
5
wList = wList ++ [X.Word]
6
if(X.Word ends with a full stop){
7
uniqueList = unique(wList)
8
foreach word in uniqueList{
9
if(isKey(wCount, word)){
10
wCount[word] = wCount[word] + 1
11
}
12
else{
13
wCount[word] = 1
14
}
15
}
16
wList = []
17
}
18
Move X to table 2
19
}
- Dictionary with words as keys mapped to the number of sentences in which the word is present.
- Dictionary with words as keys mapped to the frequency count of the word in the dataset.
- Dictionary with words as keys mapped to the maximum frequency of the word in a sentence.
- Dictionary with words as keys mapped to the number of sentences in which the word is present more than one time.
Status: Yes, the answer is correct. Score: 4
Accepted Answers:
- Dictionary with words as keys mapped to the number of sentences in which the word is present.