Computational Thinking week 7 graded assignment Complete Solutions Are Discussed In This Blog. We Hope This Might Help You All In Matching Answers . Or For Some Others Reasons If Not Able To Complete Graded Assignments
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’.
No, the answer is incorrect.
Score: 0
Accepted Answers:
For keys a and b in D, a != b is always True.
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)
alphaDict = {'t':2, 'c':1, 'a':1, 's':0}
alphaDict = updateDict(Z, alphaDict)
Procedure updateDict(Z, Dict)
i = 1, x = 't'
while(i <= Z.LetterCount){
x = ith letter of Z.Word
if(not isKey(Dict, x)){
Dict[x] = 1
}
else{
Dict[x] = Dict[x] + 1
}
i = i + 1
}
return(Dict)
End updateDict
No, the answer is incorrect.
Score: 0
Accepted Answers:
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).
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.
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.
No, the answer is incorrect.
Score: 0
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.
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).
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
No, the answer is incorrect.
Score: 0
Accepted Answers:
Line 4: Incorrect conditional statment
Question (5 – 7)
Use the procedure doSomething given below for answering questions 5, 6, and 7.
1
Procedure doSomething(aList)
2
bDict = {}
3
bList = []
4
foreach a in aList{
5
if(not isKey(bDict, a)){
6
bDict[a] = True
7
bList = bList ++ [a]
8
}
9
}
10
return(bList)
11
End doSomething
What will be the value of B at the end of the execution of the following pseudocode.
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]
No, the answer is incorrect.
Score: 0
Accepted Answers:
[3, 4, 5, 1, 9, 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.
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
No, the answer is incorrect.
Score: 0
Accepted Answers:
List of lists of unique words of each sentence from the “Words” dataset
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.
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
No, the answer is incorrect.
Score: 0
Accepted Answers:
List of unique alphabets from the “Words” dataset.
Question (8 – 9)
Let M, P, and C be a list of sequence numbers of students who have scored more than the average marks in Mathematics, Physics and Chemistry respectively using the “Scores” dataset. Answer question 8 and 9 after executing the following pseudocode.
1
seqDict = {}
2
foreach index in M{
3
seqDict[index] = 0
4
}
5
foreach index in P{
6
if(isKey(seqDict, index)){
7
seqDict[index] = seqDict[index] + 1
8
}
9
}
10
foreach index in C{
11
if(isKey(seqDict, index)){
12
seqDict[index] = seqDict[index] + 1
13
}
14
}
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
No, the answer is incorrect.
Score: 0
Accepted Answers:
The student has scored more than the average marks in Mathematics only
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.
No, the answer is incorrect.
Score: 0
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.
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.
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.
No, the answer is incorrect.
Score: 0
Accepted Answers:
Dictionary with words as keys mapped to the number of sentences in which the word is present.