[go: up one dir, main page]

67% found this document useful (3 votes)
5K views8 pages

Week 5 Computational Thinking Graded Assignments

The primary goal of the "BOLLYWAGANZA" is to create an entertaining platform that unites participants in a shared love for Indian cinema. By testing their knowledge across various aspects of Bollywood, the event intends to spark friendly competition, foster community spirit, and provide a memorable experience for all participants.

Uploaded by

Dipansh Bist
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
67% found this document useful (3 votes)
5K views8 pages

Week 5 Computational Thinking Graded Assignments

The primary goal of the "BOLLYWAGANZA" is to create an entertaining platform that unites participants in a shared love for Indian cinema. By testing their knowledge across various aspects of Bollywood, the event intends to spark friendly competition, foster community spirit, and provide a memorable experience for all participants.

Uploaded by

Dipansh Bist
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

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:

[210, 198, 188, 173, 240]

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:

[210, 198, 188, 173, 240]

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

Qualifier September (2023 ) Page 1


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
of the execution of the given pseudocode? (NAT)
count=0
A=someList(N)
3
B=someList(rest(N))
4
foreachYinA{
5
foreachZinB{
6
if(Z==Y){
7
count=count+1
8
}
9
}
10
}
11
ProceduresomeList(X)
12
outlist=[], newList=X
13
while(length(newList) >0){
14
outlist=outlist++[first(newList)]
15
newList=rest(rest(newList))
16
}
17
return(outlist)
18
EndsomeList

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
}

Qualifier September (2023 ) Page 2


}
9
if(notFound){
10
L3=L3++[i]
11
}
12
Found=False
13
}
14
return(L3)
15
Endeliminate
4 points
Choose the correct options(s) regarding L. It is a Multiple Select Question (MSQ).

It will contain all the elements of L2 that are not present in L1


It will contain all the elements of L1 that are not present in L2
It will contain all the elements common to L1 and L2
It will contain the elements present in L1 or L2 but not both

Accepted Answers:

It will contain all the elements of L1 that are not present in L2

3 points

5. Which of the following condition(s) is/are always True? It is a Multiple Select Question (MSQ).

length(L1) - length(L2) = Length(L)


length(L1) > length(L2)
length(L1) >= length(L)
length(L2) <= length(L)

Accepted Answers:

length(L1) >= length(L)

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){

Qualifier September (2023 ) Page 3


while(i<=X.LetterCount){
5
A=ithletterinX.Word
6
if(member(C,A)){
7
return(False)
8
}
9
else{
10
C=C++[A]
11
}
12
i=i+1
13
}
14
return(True)
15
EndisPerfect

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. ”

Consider the following information:

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

Qualifier September (2023 ) Page 4


5
L=L++[X.Word]
6
if(X.Wordendswithfullstop){
7
L=unique(L)
8
posCount=comNo(positiveList, L)
9
if(posCount>=2){
10
posSen=posSen+1
11
}
12
L=[]
13
}
14
MoveXtoTable2
15
}

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

Qualifier September (2023 ) Page 5


MoveXtoTable2
15
}
16
if(trueCount/totalCount>=0.5){
17
A=True
18
}
19

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

Line 4: Invalid addition operation for appending in posList


Line 7: Invalid increment of trueCount
Line 9 - 11: These three lines should be replaced by
Line 26: The current statement should be replaced by
No mistakes

Accepted Answers:

Line 7: Invalid increment of trueCount

Line 9 - 11: These three lines should be replaced by

QUESTION 9-10

Let a and b be positive integers. Procedure remainder(a, b) returns remainder if a is divided by b.


ProceduredoSomething(X)
j=2, Flag=True
3

Qualifier September (2023 ) Page 6


3
if(X==1){
4
return(False)
5
}
6
while(j<X){
7
if(remainder(X, j) ==0){
8
Flag=False
9
exitloop
10
}
11
j=j+1
12
}
13
return(Flag)
14
EnddoSomething
5 points
9. When will procedure doSomething(X) return True?

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

Qualifier September (2023 ) Page 7


position=position+1

}
M = [11, 7]
M = [11, 23, 7]
M = [11]
M = [23, 7]

Accepted Answers:

M = [11, 7]

Foundation September (2023 )

You might also like