Week 5 Computational Thinking Graded Assignments
Week 5 Computational Thinking Graded Assignments
1.What will be the value of mList at the end of the execution of the given pseudocode?
L=[[0, 210], [1, 198], [2, 188], [3, 173], [4, 240]]
2
mList=[]
3
foreachelementinL{
4
mList=mList++[last(element)]
5
}
[0, 210, 1, 198, 2, 188, 3, 173, 4, 240]
[0, 1, 2, 3, 4]
[[0, 210], [1, 198], [2, 188], [3, 173], [4, 240]]
[210, 198, 188, 173, 240]
Accepted Answers:
2 points
2. What will be the value of mList at the end of the execution of the given pseudocode?
1
L=[[0, 210, 78], [1, 198, 91], [2, 188, 77], [3, 173, 78], [4, 240, 89]]
2
mList=[]
3
foreachelementinL{
4
mList=mList++[last(init(element))]
5
}
[0, 210, 1, 198, 2, 188, 3, 173, 4, 240]
[0, 1, 2, 3, 4]
[[0, 210], [1, 198], [2, 188], [3, 173], [4, 240]]
[210, 198, 188, 173, 240]
Accepted Answers:
3.Let N be a list of first 50 positive integers (i.e., N = [1, 2, 3, ......, 49, 50]). What will be the value of count at the end
Accepted Answers:
(Type: Numeric) 0
3 points
Question (4-5)
4. Consider the procedure given below. If L1 and L2 are two lists, and L = eliminate(L1, L2), then answer the
following questions.
Procedureeliminate(L1, L2)
L3=[], Found=False
3
foreachiinL1{
4
foreachjinL2{
5
if(i==j){
6
Found==True
7
}
8
}
Accepted Answers:
3 points
5. Which of the following condition(s) is/are always True? It is a Multiple Select Question (MSQ).
Accepted Answers:
5 points
6. A word is said to be perfect if no letter is repeated. Let isPerfect be a procedure that takes a row X in the
"Words" table as input and returns True if the word in row X is a perfect word otherwise returns False. Choose
the correct implementation of the procedure isPerfect.
Accepted Answers:
ProcedureisPerfect(X)
C=[]
3
i=1
4
while(i<=X.LetterCount){
7. The given pseudocode is executed using a dataset having the same fields as the “Words” dataset, and
contains the following words -
“I ordered this product from Gitark. I am very happy to share my review regarding this awesome product. It is not
only nice to use, but also has a very cool look. I think this is the best product which can be bought in this price
range. ”
1. unique(L) returns a list of unique elements of list L. For example unique(["think", "like", "toppers", "think"]) will
return ["think", "like", "toppers"].
2. comNo(L1, L2) returns the number of common elements in lists L1 and L2.
3. Ignore the upper and lower case, and punctuation symbols while comparing with other words
1
positiveList=[“happy”, “awesome”, “nice”, “fine”, “best”, “cool”]
2
posSen=0, L=[]
3
while(Table1hasmorerows){
4
ReadthefirstrowXinTable1
5
What will be the value of posSen at the end of the execution of the above pseudocode?
Accepted Answers:
(Type: Numeric) 2
5 points
6 points
8. Mona tells Sona that at least 50 percent of sentences have nouns just after an adjective. Sona writes the
following pseudocode to find if Mona is right or not. At the end of the execution of the pseudocode given
below, A stores True if Mona is right otherwise False. But Sona might have made mistakes in one or more
lines. Identify such lines (if any). It is a Multiple Select Question (MSQ). Assume that there is at least one
adjective in every sentence.
A=False, trueCount=0, totalCount=0, posList=[]
while(Table1hasmorerows){
3
ReadthefirstrowXinTable1
4
posList=posList++[X.PartOfSpeech]
5
if(X.Wordendswithafullstop){
6
if(isTrue(posList) ==0){
7
trueCount=trueCount++[1]
8
}
9
else{
10
totalCount=totalCount+1
11
}
12
posList=[]
13
}
14
MoveXtoTable2
20
ProcedureisTrue(L)
21
count=0
22
while(length(L) >=2){
23
if(first(L) =="Adjective"){
24
count=count+1
25
if(first(rest(L)) =="Noun"{
26
count=count-1
27
}
28
}
29
L=rest(L)
30
}
31
return(count)
32
EndisTrue
Accepted Answers:
QUESTION 9-10
X is a prime number
X is an even number
X is an odd number
X is more than 1
Accepted Answers:
X is a prime number
5 points
10. Consider the procedure discussed above. What will be the value of M at the end of the execution of the given
pseudocode below?
1
L=[6, 10, 11, 23, 7, 50]
2
M=[]
3
position=1
4
foreachelementinL{
5
if(doSomething(position) anddoSomething(element)){
6
M=M++[element]
7
}
8
}
M = [11, 7]
M = [11, 23, 7]
M = [11]
M = [23, 7]
Accepted Answers:
M = [11, 7]