Prasnya
Prasnya
Prasnya
Continue with Google
Prasnya
Continue with Google
Week 6 Computational Thinking Questions | Prasnya
Computational Thinking > Week 6
All PYQs
Topic-Wise PYQs
Start Weekly Test
Mock tests
Week mock
Topic mock
Subject mock
Type:
All
Difficulty:
All
Year:
All
67Q
01
The following pseudocode is executed using the Scores dataset. What will the values of `A` and `B` represent at the end of execution? ``` D = {} while(Table 1 has more rows){ Read the first row X in Table 1 if(isKey(D, X.Town/City)){ if(D[X.Town/City] > X.Mathematics){ D[X.Town/City] = X.Mathematics } } else{ D[X.Town/City] = X.Mathematics } Move X to Table 2 } A = 0, B = 100 foreach y in keys(D){ if(B == D[y]){ A = A + 1 } if(B > D[y]){ A = 1 B = D[y] } } ```
Single correct
MEDIUM
4 marks
06 April 2026
02
The following pseudocode is executed on the Shopping Bills dataset. What will `Val` represent at the end of execution? ``` CustomerTotal = {} billCount = 0 globalSum = 0 while(Table 1 has more rows){ Read the first row Bill in Table 1 billTotal = 0 foreach item in Bill.ItemList{ billTotal = billTotal + item.Price } globalSum = globalSum + billTotal billCount = billCount + 1 if(isKey(CustomerTotal, Bill.CustName)){ CustomerTotal[Bill.CustName] = CustomerTotal[Bill.CustName] + billTotal } else{ CustomerTotal[Bill.CustName] = billTotal } Move row Bill to Table 2 } AvgBill = globalSum / billCount Val = 0 foreach name in keys(CustomerTotal){ if(CustomerTotal[name] > AvgBill){ Val = Val + 1 } } ```
Single correct
MEDIUM
5 marks
06 April 2026
03
We have a dictionary `Registration` where the keys are student names and the values are lists of courses they have registered for. We want to create a new dictionary `CourseRoll` where the keys are course names and the values are lists of students registered for each course. Identify the correct implementation(s). Example `Registration`: `{"Rahul": ["Math", "Physics"], "Sita": ["Physics", "Chemistry"], "Amar": ["Math"]}` Expected `CourseRoll`: `{"Math": ["Rahul", "Amar"], "Physics": ["Rahul", "Sita"], "Chemistry": ["Sita"]}`
Multiple correct
MEDIUM
4 marks
06 April 2026
04
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 execution of the following pseudocode? ``` alphaDict = {'t': 2, 'c': 1, 'a': 1, 's': 0} alphaDict = updateDict(Z, alphaDict) Procedure updateDict(Z, Dict) i = 1 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 ```
Numerical
EASY
3 marks
06 April 2026
05
The following procedure is executed on dictionary `D = {'A': 10, 'B': 25, 'C': 30, 'D': 40, 'E': 18}`. What is the final value of `val`? ``` val = 0 keysList = keys(D) foreach k in keysList{ if(D[k] % 10 == 0){ val = val + D[k] D[k] = D[k] / 2 } else{ val = val - D[k] D[k] = D[k] + 5 } if(D[k] > 10){ val = val + 10 } else{ val = val - 5 } } ```
Numerical
HARD
4 marks
06 April 2026
06
Based on the comprehension context above, what does the variable `count` represent at the end of execution?
Comprehension
MEDIUM
4 marks
06 April 2026
07
Based on the comprehension context above, if we modify the code to remove the membership check `if(not member(TeamDict[country], player))` and always append the player instead, what would `TeamDict[country]` contain?
Comprehension
EASY
4 marks
06 April 2026
08
What is the value of `Result` at the end of execution of the following pseudocode? ``` Procedure buildList(aList) seenDict = {} resultList = [] foreach item in aList { if(not isKey(seenDict, item)) { seenDict[item] = True resultList = [item] ++ resultList } } return(resultList) End buildList Data = [4, 1, 4, 5, 2, 1, 3, 2, 6] Result = buildList(Data) ```
Single correct
MEDIUM
4 marks
03 August 2025
09
What will the value of `freqDict` be at the end of the execution of the following pseudocode? ``` Procedure countCharacters(charList) freqDict = {} foreach c in charList { if(isKey(freqDict, c)) { freqDict[c] = freqDict[c] + 1 } else { freqDict[c] = 1 } } return(freqDict) End countCharacters B = ['a', 'b', 'a', 'c', 'b', 'd', 'a', 'c', 'b', 'e', 'd', 'a'] freqDict = countCharacters(B) ```
Single correct
EASY
4 marks
03 August 2025
10
The following pseudocode is executed on the "Words" table. What does the list `L` contain at the end of execution? ``` L = [] A = "None" Read the first row X in Table 1 A = X.PartOfSpeech Move X to Table 2 while(Table 1 has more rows) { Read the first row X in Table 1 if(X.PartOfSpeech == "noun") { if(A == "Article") { L = L ++ [X.Word] } } A = X.PartOfSpeech Move X to Table 2 } ```
Single correct
MEDIUM
4 marks
03 August 2025
11
The following pseudocode is executed using the "Shopping Bills" dataset. At the end of execution, `A` represents the maximum number of unique items sold by a shop. Choose the correct code fragment(s) to complete the pseudocode. ``` D = {} while(Table 1 has more rows) { Read the first row X in Table 1 ************************ **** Fill the code **** ************************ Move X to Table 2 } A = 0 foreach a in keys(D) { if(A < length(keys(D[a]))) { A = length(keys(D[a])) } } ```
Multiple correct
HARD
5 marks
03 August 2025
12
The following pseudocode is executed using the "Library" dataset. Let `P` be a list of authors. After the execution of the pseudocode below, `dict[X]` should store the number of books having at least
200
200
200
pages and written in or after year
2000
2000
2000
by author `X` from the list `P`. Choose the correct code fragment(s) to complete the pseudocode. ``` dict = {} foreach author in P { dict[author] = 0 } while(Table 1 has more rows) { Read the first row X from Table 1 ************************ **** Fill the Code * ************************ Move X to Table 2 } ```
Multiple correct
MEDIUM
4 marks
03 August 2025
13
At the end of execution of pseudocode, which of the following statements is/are correct?
Comprehension
MEDIUM
4 marks
03 August 2025
14
What will `length(sList)` represent at the end of the execution?
Comprehension
EASY
3 marks
03 August 2025
15
What is the value of
B
B
B
at the end of the execution of the following pseudocode? ``` Procedure doSomething(aList) bDict = {} bList = [] foreach a in aList { if (not isKey(bDict, a)) { bDict[a] = True bList = [a] ++ bList } } return (bList) End doSomething A = [2, 6, 7, 2, 8, 7, 6, 2, 3] B = doSomething(A) ```
Single correct
MEDIUM
4 marks
16 March 2025
16
What is the value of
r
e
s
u
l
t
D
i
c
t
resultDict
r
es
u
l
t
D
i
c
t
at the end of the execution of the following pseudocode? ``` Procedure createFrequencyDict(aList) freqDict = {} foreach a in aList { if (isKey(freqDict, a)) { freqDict[a] = freqDict[a] + 1 } else { freqDict[a] = 1 } } return (freqDict) End createFrequencyDict A = [3, 5, 3, 7, 8, 5, 3, 8, 8, 9, 5, 3] resultDict = createFrequencyDict(A) ```
Single correct
EASY
5 marks
16 March 2025
17
The following pseudocode is executed on the "Scores" dataset. Which of the following statements is/are true at the end of the execution? Let `SeqNo` in the "Scores" dataset represent the `CardNo` of the respective student. ``` A = [] B = [] while (Table 1 has more rows) { Read the top row X from Table 1 if (X.Total > 200) { A = A ++ [X.CardNo] if (X.CityTown == "Chennai") { B = B ++ [X.CardNo] } } } ```
Multiple correct
MEDIUM
4 marks
16 March 2025
18
Let
X
X
X
be a row from the "Words" table. Consider the following procedure: ``` Procedure isRich(X) cDict = {} i = 1 while (i <= X.LetterCount) { A = ith letter in X.Word if (A is a consonant) { cDict[A] = True } i = i + 1 } if (length(keys(cDict)) > 4) { return (True) } return (False) End isRich ``` The return value of `isRich(Y)` will be `True` if
Multiple correct
MEDIUM
4 marks
16 March 2025
19
The following pseudocode is executed using the "Shopping Bills" dataset. At the end of the execution, the variable `D` captures the following information: for each customer `Z`, `D[Z]["Shop"]` stores the shops visited by `Z`, and `D[Z]["Category"]` stores the categories of the items purchased by `Z`. But the pseudocode may have mistakes. Identify all such mistakes, if any. ``` D = {} while (Pile 1 has more cards) { Read the top card X in Pile 1 D = updateDictionary(D, X) Move X to Pile 2 } Procedure updateDictionary(D, Y) if (not isKey(D, Y.CustomerName)) { D[Y.CustomerName] = {"Shop": [], "Category": []} } D[Y.CustomerName]["Shop"][Y.ShopName] = True foreach A in Y.ItemList { D[Y.CustomerName]["Shop"][A.Category] = True } return (D) End updateDictionary ```
Multiple correct
HARD
4 marks
16 March 2025
20
If `seqDict[n] == 0` is a `True` statement, then choose the correct option regarding the student with sequence number `n`.
Comprehension
EASY
3 marks
16 March 2025
21
If `seqDict[n] == 1` is a `True` statement, then choose the correct option(s) regarding the student with sequence number `n`.
Comprehension
MEDIUM
4 marks
16 March 2025
22
What will the value of `B` be at the end of the execution of the following pseudocode? ``` Procedure doSomething(aList) bDict = {} bList = [] foreach a in aList { if(not isKey(bDict, a)) { bDict[a] = True bList = bList ++ [a] } } return(bList) End doSomething A = [2, 6, 7, 2, 8, 7, 6, 2, 3] B = doSomething(A) ```
Single correct
EASY
4 marks
01 December 2024
23
Let `Z` be a row in the Words table such that `Z.Word = "mississippi"`. What will be the value of `alphaDict["s"]` at the end of the execution of the following pseudocode? ``` alphaDict = {'i': 3, 'c': 1, 'a': 1, 's': 1} alphaDict = updateDict(Z, alphaDict) Procedure updateDict(Z, Dict) i = 1 while(i <= Z.LetterCount) { x = ith letter of Z.Word if(not isKey(Dict, x)) { Dict[x] = 1 } else { Dict[x] = Dict[x] + 2 } i = i + 1 } return(Dict) End updateDict ```
Numerical
EASY
4 marks
01 December 2024
24
Based on the Olympics pseudocode above, what will `Dict` store at the end of execution?
Comprehension
MEDIUM
4 marks
01 December 2024
25
Based on the Olympics pseudocode above, what will `list` store at the end of execution of the pseudocode?
Comprehension
MEDIUM
4 marks
01 December 2024
26
Let `X` be a row from the Words table. Consider the following procedure. The return value of `isRich(Y)` will be False if ``` Procedure isRich(X) vDict = {} i = 1, A = "" while (i <= X.LetterCount) { A = ith letter in X.Word if (A is a vowel) { vDict[A] = True } i = i + 1 } if (length(keys(vDict)) >= 3) { return(True) } return(False) End isRich ```
Single correct
MEDIUM
4 marks
04 August 2024
27
The following pseudocode is executed using the Library dataset. What will `D` represent at the end of execution? ``` D = {} while (Table 1 has more rows) { Read the first row X in Table 1 if (isKey(D, X.Author)) { if (D[X.Author] > X.Year) { D[X.Author] = X.Year } } else { D[X.Author] = X.Year } Move X to Table 2 } ```
Single correct
MEDIUM
4 marks
04 August 2024
28
The following pseudocode is executed using the Words dataset. Let `X.Word` and `Y.Word` be "engineering" and "analysis" respectively. At the end of execution, which statements are correct? ``` firstDict = {}, secondDict = {}, commonDict = {} firstDict = createDict(X) secondDict = createDict(Y) foreach key in keys(firstDict) { if (isKey(secondDict, key)) { if (firstDict[key] > secondDict[key]) { commonDict[key] = firstDict[key] } else { commonDict[key] = secondDict[key] } } } Procedure createDict(Z) i = 1, x = '', Dict = {} 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 ```
Multiple correct
HARD
5 marks
04 August 2024
29
The following pseudocode is executed using the Olympics dataset. At the end of execution, which statements are correct? ``` P = {} while (Table 1 has more rows) { Read the first row X in Table 1 P = updateMedalCounts(P, X.Sport, X.Medal) Move X to Table 2 } n = doSomething(P) Procedure updateMedalCounts(Q, Sport, Medal) if (isKey(Q, Sport)) { Q[Sport][Medal] = Q[Sport][Medal] + 1 } else { Q[Sport] = {"Gold": 0, "Silver": 0, "Bronze": 0} Q[Sport][Medal] = 1 } return(Q) End updateMedalCounts Procedure doSomething(R) max = 0 for each sport in keys(R) { if (R[sport]["Gold"] > max) { max = R[sport]["Gold"] } } return(max) End doSomething ```
Multiple correct
MEDIUM
5 marks
04 August 2024
30
At the end of execution, `wordCount` represents the number of words in which the number of distinct consonants is greater than or equal to 3. The pseudocode may have mistakes. Identify all mistakes, if any. ``` wordCount = 0 while (Table 1 has more rows) { Read the first row X in Table 1 if (doSomething(X) >= 3) { wordCount = wordCount + 1 } Move X to Table 2 } Procedure doSomething(Y) A = [], i = 1 while (i < Y.LetterCount) { l = ith letter of Y.Word if (l is consonant) { A[l] = True } i = i + 1 } return(length(keys(A))) End doSomething ```
Multiple correct
MEDIUM
4 marks
04 August 2024
31
The given pseudocode is executed using the Words dataset. What does `wordCount` represent at the end of execution? ``` wordCount = 0 while (Table 1 has more rows) { Read the first row X in Table 1 if (doSomething(X) >= 3) { wordCount = wordCount + 1 } Move X to Table 2 } Procedure doSomething(Y) A = {}, i = 1 while (i <= Y.LetterCount) { L = ith letter of Y.Word if (L is consonant) { A[L] = True } i = i + 1 } return(length(keys(A))) End doSomething ```
Single correct
MEDIUM
3 marks
24 March 2024
32
What will the value of `B` be at the end of execution of the following pseudocode? ``` Procedure doSomething(aList) bDict = {} bList = [] foreach a in aList { if (not isKey(bDict, a)) { bDict[a] = True bList = bList ++ [a] } } return(bList) End doSomething A = [4, 3, 1, 3, 4, 5, 1, 2, 7] B = doSomething(A) ```
Single correct
EASY
3 marks
24 March 2024
33
The following pseudocode is executed using the Scores dataset. What will the values of `A` and `B` represent at the end of execution? ``` D = {} while (Table 1 has more rows) { Read the first row X in Table 1 if (isKey(D, X.Town/City)) { if (D[X.Town/City] > X.Physics) { D[X.Town/City] = X.Physics } } else { D[X.Town/City] = X.Physics } Move X to Table 2 } A = 0, B = 100 foreach Y in keys(D) { if (B == D[Y]) { A = A + 1 } if (B > D[Y]) { A = 1 B = D[Y] } } ```
Single correct
HARD
3 marks
24 March 2024
34
The following pseudocode is executed using the Words dataset. Let `X.Word` and `Y.Word` be "computational" and "thinking" respectively. What will be the value of `commonDict`? ``` firstDict = {}, secondDict = {}, commonDict = {} firstDict = updateDict(X, commonDict) secondDict = updateDict(Y, commonDict) foreach key in keys(firstDict) { if (isKey(secondDict, key)) { if (firstDict[key] > secondDict[key]) { commonDict[key] = firstDict[key] } else { commonDict[key] = secondDict[key] } } } Procedure updateDict(Z, Dict) i = 1, x = '' 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 ```
Single correct
HARD
4 marks
24 March 2024
35
The following pseudocode is executed using the Olympics dataset. What will `B` represent at the end of execution? ``` P = {} while (Table 1 has more rows) { Read the first row X in Table 1 P = updateMedalCounts(P, X.Sport, X.Medal) Move X to Table 2 } B = doSomething(P) Procedure updateMedalCounts(Q, Sport, Medal) if (isKey(Q, Sport)) { Q[Sport][Medal] = Q[Sport][Medal] + 1 } else { Q[Sport] = {"Gold": 0, "Silver": 0, "Bronze": 0} Q[Sport][Medal] = 1 } return(Q) End updateMedalCounts Procedure doSomething(R) max = 0 foreach sport in keys(R) { if (R[sport]["Gold"] > max) { max = R[sport]["Gold"] } } return(max) End doSomething ```
Single correct
MEDIUM
4 marks
24 March 2024
36
The following pseudocode is executed using the Shopping Bills dataset. What will `AA` represent at the end of execution? ``` BB = {}, AA = "None" while (Pile 1 has more cards) { Read the top card X in Pile 1 if (X.ShopName == "SV Stores") { BB = updateDictionary(BB, X) } Move X to Pile 2 } AA = GetKeyByKey(BB) Procedure updateDictionary(D, Y) foreach A in Y.ItemList { if (isKey(D, A.Category)) { D[A.Category] = D[A.Category] + 1 } else { D[A.Category] = 1 } } return(D) End updateDictionary Procedure GetKeyByKey(D) A = "None", B = 0 foreach Y in keys(D) { if (B < D[Y]) { A = Y B = D[Y] } } return(A) End GetKeyByKey ```
Single correct
MEDIUM
4 marks
24 March 2024
37
The following pseudocode is executed using station-wise cards of the Train dataset. At the end, `STN[X][A]` should store the number of trains running through station `X` on day `A`. Choose the correct code fragment to complete `getInfo`. ``` STN = {} while (Pile 1 has more cards) { Read the top card X in Pile 1 STN[X.StationName] = getInfo(STN, X) Move X to Pile 2 } Procedure getInfo(STN, X) ******************** * Fill the code * ******************** return(D) End getInfo ```
Single correct
MEDIUM
4 marks
24 March 2024
38
The following pseudocode is executed using the Library dataset. Let `p` be a list of authors, and after execution `dict[X]` stores the number of books having at least 200 pages and written on or after 2000 by author `X`. Choose the correct code fragment(s) to complete the pseudocode. ``` dict = {} foreach author in p { dict[author] = 0 } while (Table 1 has more rows) { Read the first row X from Table 1 ******************** * Fill the code * ******************** Move X to Table 2 } ```
Multiple correct
MEDIUM
4 marks
24 March 2024
39
The following pseudocode is executed on the Shopping Bills dataset. What will `d` represent at the end of execution? ``` d = {} while (Table 1 has more rows) { Read the first row X in Table 1 d = doSomething(X, d, "SV Stores") d = doSomething(X, d, "Big Bazaar") d = doSomething(X, d, "Sun General") Move X to Table 2 } Procedure doSomething(Y, D, S) if (isKey(D, S)) { D[S] = D[S] ++ [Y.TotalBillAmount] } else { D[S] = [Y.TotalBillAmount] } return D End doSomething ```
Single correct
MEDIUM
3 marks
03 December 2023
40
The following pseudocode is executed on the Words dataset. What will the values of `B` and `C` represent at the end of execution? ``` A = {} while (Table 1 has more rows) { Read the first row X in Table 1 A = doSomething(A, X.PartOfSpeech) Move X to Table 2 } B = 0 C = None foreach k in keys(A) { if (A[k] > B) { B = A[k] C = k } } Procedure doSomething(Y, P) if (isKey(Y, P)) { Y[P] = Y[P] + 1 } else { Y[P] = 1 } return Y End doSomething ```
Single correct
MEDIUM
3 marks
03 December 2023
41
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 execution? ``` alphaDict = {'t': 2, 'c': 1, 'a': 1, 's': 0} alphaDict = updateDict(Z, alphaDict) Procedure updateDict(Z, Dict) i = 1 while (i <= Z.LetterCount) { x = ith letter of Z.Word if (not isKey(Dict, x)) { Dict[x] = 1 } else { Dict[x] = Dict[x] + 2 } i = i + 1 } return(Dict) End updateDict ```
Numerical
EASY
4 marks
03 December 2023
42
Let `X` be a row from the Words table. Consider the following procedure. The return value of `CheckVowels(Y)` will be False if: ``` Procedure CheckVowels(X) vDict = {} i = 1 while (i <= X.LetterCount) { A = ith letter in X.Word if (A is a vowel) { vDict[A] = True } i = i + 1 } if (length(keys(vDict)) >= 3) { return(True) } return(False) End CheckVowels ```
Multiple correct
EASY
3 marks
03 December 2023
43
The following pseudocode is executed using the Olympics dataset. The variable `medalDict` should store a dictionary with player name as key mapped to another dictionary. The nested dictionary stores medal type as key mapped to a list of years in which the player won that medal. The pseudocode may have mistakes. Identify all such mistakes. ``` medalDict = {} while(Table 1 has more rows) { Read the first row X in Table 1 if(isKey(medalDict, X.Name)) { if(not(isKey(medalDict[X.Name], X.Medal))) { medalDict[X.Name][X.Medal] = medalDict[X.Name][X.Medal] ++ [X.Year] } else { medalDict[X.Name][X.Medal] = [X.Year] } } else { medalDict[X.Name][X.Medal] = [X.Year] } Move X to Table 2 } ```
Multiple correct
HARD
5 marks
06 August 2023
44
The following pseudocode is executed using the Olympics dataset. What will `B` represent at the end of execution? ``` D = {} while(Table 1 has more rows) { Read the first row X in Table 1 D = updateDict(D, X.Sport) Move X to Table 2 } B = findAValue(D) Procedure updateDict(D, a) if(isKey(D, a)) { D[a] = D[a] + 1 } else { D[a] = 1 } return(D) End updateDict Procedure findAValue(D) V = 0 foreach a in keys(D) { if(D[a] > V) { V = D[a] } } return(V) End findAValue ```
Single correct
MEDIUM
3 marks
06 August 2023
45
The following pseudocode is executed on the Words dataset. What will `Count1` represent at the end of execution? ``` D = {} A = 0, Total = 0, Count = 0 while(Table 1 has more rows) { Read the first row X in Table 1 Total = Total + X.LetterCount Count = Count + 1 if(isKey(D, X.Word)) { D[X.Word]["Freq"] = D[X.Word]["Freq"] + 1 } else { D[X.Word] = {} D[X.Word]["Freq"] = 1 D[X.Word]["LC"] = X.LetterCount } if(D[X.Word]["Freq"] > A) { A = D[X.Word]["Freq"] } Move row X to Table 2 } Avg = Total / Count Count1 = 0, Count2 = 0 foreach k in keys(D) { if(D[k]["Freq"] == A) { if(D[k]["LC"] > Avg) { Count1 = Count1 + 1 } else { Count2 = Count2 + 1 } } } ```
Single correct
HARD
5 marks
06 August 2023
46
Consider a dictionary `dict = {'A': [1, 2, 3, 4, 5], 'B': [6, 7, 8, 9], 'C': 19}`. The following procedure `DoSomething(dict)` is executed. What can the procedure return? ``` procedure DoSomething(dict) foreach i in keys(dict) { return(dict[i]) } end DoSomething ```
Multiple correct
MEDIUM
4 marks
06 August 2023
47
The following pseudocode is executed using the Library dataset. `P` is a list of authors who have written books in English. `dict[X]` stores the number of books having at least 100 pages and written on or before 2000 by author `X`. Choose the correct code fragment(s) to complete the pseudocode. ``` dict = {} foreach author in P { dict[author] = 0 } while(Table 1 has more rows) { Read the first row X from Table 1 ******************** * Fill the code * ******************** Move X to Table 2 } ```
Multiple correct
MEDIUM
3 marks
06 August 2023
48
Let `Y` be a card in the Shopping Bills dataset. Consider the following procedure. ``` Procedure findSomething(Y) D = {} foreach Z in Y.ItemList { if(isKey(D, Z.Category)) { return(Z.Category) } D[Z.Category] = True } return("None") End findSomething ``` What will `findSomething(X)` return where `X` represents the given Shopping Bills card?
Single correct
EASY
2 marks
02 April 2023
49
The following pseudocode is executed using the Words dataset. Assume that rows in Table 1 are arranged in increasing order of sequence number. What will `L` store at the end of execution? ``` L = [] A = "None" Read the first row X in Table 1 A = X.PartOfSpeech Move X to Table 2 while(Table 1 has more rows) { Read the first row Y in Table 1 if(Y.PartOfSpeech == "Noun") { if(A == "Adjective") { L = L ++ [Y.Word] } } A = Y.PartOfSpeech Move Y to Table 2 } ```
Single correct
MEDIUM
4 marks
02 April 2023
50
Let `X` be a row in the Words dataset. Procedure `isRich(X)` should return `True` if the number of distinct vowels is less than the number of distinct consonants in `X.Word`. The code may have mistakes. Identify all such mistakes, if any. ``` Procedure isRich(X) vDict = {}, wDict = {} i = 1 while(i <= X.LetterCount) { A = ith letter in X.Word if(A is a vowel) { vDict[A] = True } wDict[A] = True i = i + 1 } if(length(keys(vDict)) < length(keys(wDict))) { return(True) } return(True) End isRich ```
Multiple correct
MEDIUM
4 marks
02 April 2023
51
The following pseudocode is executed using the Olympics dataset. At the end of execution, `medalDict` should store a nested dictionary where each player maps to medal types, and each medal type maps to a list of years. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` medalDict = {} while(Table 1 has more rows) { Read the first row X in Table 1 if(isKey(medalDict, X.Name)) { if(isKey(medalDict[X.Name], X.Medal)) { medalDict[X.Name][X.Medal] = [X.Year] } else { medalDict[X.Name][X.Medal] = [X.Year] } } else { medalDict[X.Name][X.Medal] = [X.Year] } Move X to Table 2 } ```
Multiple correct
HARD
5 marks
02 April 2023
52
Consider the following pseudocode where `Y` is a row in the Words table. At the end of execution, what will be the value of `length(keys(alphaDict))` if `Y.Word` is "think"? ``` alphaDict = {'t': 2, 'e': 1} alphaDict = updateDict(Y, alphaDict) Procedure updateDict(Z, Dict) i = 1 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 ```
Numerical
EASY
4 marks
02 April 2023
53
What will `count` represent at the end of execution if the missing code is filled by: ``` if(X.Word ends with full stop) { if(X.PartOfSpeech == "Noun") { count = count + 1 } } ```
Comprehension
EASY
3 marks
02 April 2023
54
What will `count` represent at the end of execution if the missing code is filled by: ``` if(flag and X.PartOfSpeech == "Noun") { count = count + 1 } flag = False if(X.Word ends with full stop) { flag = True } ```
Comprehension
MEDIUM
3 marks
02 April 2023
55
What will each value `D[J][I]` represent at the end of execution?
Comprehension
EASY
4 marks
02 April 2023
56
Consider the dictionary `D` created in the previous question. What will the value of `L` represent at the end of execution of the following pseudocode? ``` A = 0, L = [] foreach i in keys(D) { foreach j in keys(D[i]) { B = findRange(D[i][j]) if(B == 0) { L = L ++ [j] } if(B > A) { A = B L = [j] } } } Procedure findRange(Y) p = first(Y), q = first(Y) foreach k in Y { if(k > p) { p = k } if(k < q) { q = k } } return(p - q) End findRange ```
Comprehension
HARD
5 marks
02 April 2023
57
What will be the value of `D` at the end of execution of the following pseudocode? ``` D = {'a': {'a': 5, 'b': 4}, 'b': 1} D['b'] = D['b'] + D['b'] ```
Single correct
EASY
1 marks
20 November 2022
58
Let `dict` be a dictionary. Which of the following is not a valid value of `dict`?
Single correct
EASY
1 marks
20 November 2022
59
Let `'x'`, `'y'`, and `'z'` be the only keys of dictionary `D`, and `L = keys(D)`. At the end of execution of the following pseudocode, `flag` stores `True`. Choose the possible value of `L`. ``` flag = False position = 0 foreach key in L { if((position == 1) and (key == 'y')) { flag = True } position = position + 1 } ```
Single correct
EASY
2 marks
20 November 2022
60
Consider the following pseudocode, where `D` is a dictionary. Choose a statement regarding `D` such that `sum` will always store a value greater than 0 at the end of execution. ``` sum = 0 foreach key in keys(D) { sum = sum + first(D[key]) } ```
Single correct
MEDIUM
3 marks
20 November 2022
61
Let `X` be a row from the Words table. Consider the following procedure. The return value of `isRich(Y)` will be `False` if: ``` Procedure isRich(X) vDict = {} i = 1, A = "" while(i <= X.LetterCount) { A = ith letter in X.Word if(A is a vowel) { vDict[A] = True } i = i + 1 } if(length(keys(vDict)) >= 3) { return(True) } return(False) End isRich ```
Single correct
MEDIUM
3 marks
20 November 2022
62
The following pseudocode is executed using the Words dataset. Rows are arranged in increasing sequence number. At the end of execution, `L` should store the list of nouns that appear immediately after an adjective. Choose the correct code fragment to complete the pseudocode. ``` L = [] A = "None" Read the first row X in Table 1 A = X.PartOfSpeech Move X to Table 2 while(Table 1 has more rows) { Read the first row Y in Table 1 ******************** *** Fill the code *** ******************** A = Y.PartOfSpeech Move Y to Table 2 } ```
Single correct
HARD
4 marks
20 November 2022
63
Let `medalDict` be a dictionary with player name as key mapped to the list of medals associated with the player from the Olympics dataset. `repeatMedals(medalDict)` should return the list of players who have won at least one type of medal more than once. The code may have mistakes. Identify all such mistakes, if any. ``` procedure repeatMedals(medalDict) repeatPlayers = [] foreach player in keys(medalDict) { tempDict = {} foreach medal in medalDict[player] { tempDict[medal] = True } if(length(keys(tempDict)) == length(medalDict[player])) { repeatPlayers = repeatPlayers ++ [player] } } return(repeatPlayers) End repeatMedals ```
Multiple correct
MEDIUM
4 marks
20 November 2022
64
The following pseudocode is executed using the Olympics dataset. `medalDict` should store a nested dictionary where each player maps to medal types and each medal type maps to a list of years. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` medalDict = {} while(Table 1 has more rows) { Read the first row X in Table 1 if(isKey(medalDict, X.Name)) { if(isKey(medalDict[X.Name], X.Medal)) { medalDict[X.Name][X.Medal] = [X.Year] } else { medalDict[X.Name][X.Medal] = [X.Year] } } else { medalDict[X.Name][X.Medal] = [X.Year] } Move X to Table 2 } ```
Multiple correct
HARD
5 marks
20 November 2022
65
Let `X.Word` be "thinking". At the end of execution of the following pseudocode, what will be the value of `length(keys(alphaDict))`? ``` alphabet = {'t': 2, 'e': 1, 'w': 1} alphaDict = updateDict(X, alphabet) ```
Comprehension
MEDIUM
3 marks
20 November 2022
66
Let `X.Word` and `Y.Word` be "computational" and "thinking" respectively. The following pseudocode is executed using the Words dataset and the procedure `updateDict`. At the end, what is the value of `length(keys(commonDict))`? ``` firstDict = {}, secondDict = {}, commonDict = {} firstDict = updateDict(X, commonDict) secondDict = updateDict(Y, commonDict) foreach key in keys(firstDict) { if(isKey(secondDict, key)) { if(firstDict[key] > secondDict[key]) { commonDict[key] = firstDict[key] } else { commonDict[key] = secondDict[key] } } } ```
Comprehension
MEDIUM
3 marks
20 November 2022
67
Consider the dictionary `commonDict` created in the previous question. What will be the value of `commonDict['i']`?
Comprehension
MEDIUM
4 marks
20 November 2022
Showing 67 questions.
Computational Thinking > Week 6
All PYQs
Topic-Wise PYQs
Start Weekly Test
Mock tests
Week mock
Topic mock
Subject mock
Type:
All
Difficulty:
All
Year:
All
67Q
01
The following pseudocode is executed using the Scores dataset. What will the values of `A` and `B` represent at the end of execution? ``` D = {} while(Table 1 has more rows){ Read the first row X in Table 1 if(isKey(D, X.Town/City)){ if(D[X.Town/City] > X.Mathematics){ D[X.Town/City] = X.Mathematics } } else{ D[X.Town/City] = X.Mathematics } Move X to Table 2 } A = 0, B = 100 foreach y in keys(D){ if(B == D[y]){ A = A + 1 } if(B > D[y]){ A = 1 B = D[y] } } ```
Single correct
MEDIUM
4 marks
06 April 2026
02
The following pseudocode is executed on the Shopping Bills dataset. What will `Val` represent at the end of execution? ``` CustomerTotal = {} billCount = 0 globalSum = 0 while(Table 1 has more rows){ Read the first row Bill in Table 1 billTotal = 0 foreach item in Bill.ItemList{ billTotal = billTotal + item.Price } globalSum = globalSum + billTotal billCount = billCount + 1 if(isKey(CustomerTotal, Bill.CustName)){ CustomerTotal[Bill.CustName] = CustomerTotal[Bill.CustName] + billTotal } else{ CustomerTotal[Bill.CustName] = billTotal } Move row Bill to Table 2 } AvgBill = globalSum / billCount Val = 0 foreach name in keys(CustomerTotal){ if(CustomerTotal[name] > AvgBill){ Val = Val + 1 } } ```
Single correct
MEDIUM
5 marks
06 April 2026
03
We have a dictionary `Registration` where the keys are student names and the values are lists of courses they have registered for. We want to create a new dictionary `CourseRoll` where the keys are course names and the values are lists of students registered for each course. Identify the correct implementation(s). Example `Registration`: `{"Rahul": ["Math", "Physics"], "Sita": ["Physics", "Chemistry"], "Amar": ["Math"]}` Expected `CourseRoll`: `{"Math": ["Rahul", "Amar"], "Physics": ["Rahul", "Sita"], "Chemistry": ["Sita"]}`
Multiple correct
MEDIUM
4 marks
06 April 2026
04
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 execution of the following pseudocode? ``` alphaDict = {'t': 2, 'c': 1, 'a': 1, 's': 0} alphaDict = updateDict(Z, alphaDict) Procedure updateDict(Z, Dict) i = 1 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 ```
Numerical
EASY
3 marks
06 April 2026
05
The following procedure is executed on dictionary `D = {'A': 10, 'B': 25, 'C': 30, 'D': 40, 'E': 18}`. What is the final value of `val`? ``` val = 0 keysList = keys(D) foreach k in keysList{ if(D[k] % 10 == 0){ val = val + D[k] D[k] = D[k] / 2 } else{ val = val - D[k] D[k] = D[k] + 5 } if(D[k] > 10){ val = val + 10 } else{ val = val - 5 } } ```
Numerical
HARD
4 marks
06 April 2026
06
Based on the comprehension context above, what does the variable `count` represent at the end of execution?
Comprehension
MEDIUM
4 marks
06 April 2026
07
Based on the comprehension context above, if we modify the code to remove the membership check `if(not member(TeamDict[country], player))` and always append the player instead, what would `TeamDict[country]` contain?
Comprehension
EASY
4 marks
06 April 2026
08
What is the value of `Result` at the end of execution of the following pseudocode? ``` Procedure buildList(aList) seenDict = {} resultList = [] foreach item in aList { if(not isKey(seenDict, item)) { seenDict[item] = True resultList = [item] ++ resultList } } return(resultList) End buildList Data = [4, 1, 4, 5, 2, 1, 3, 2, 6] Result = buildList(Data) ```
Single correct
MEDIUM
4 marks
03 August 2025
09
What will the value of `freqDict` be at the end of the execution of the following pseudocode? ``` Procedure countCharacters(charList) freqDict = {} foreach c in charList { if(isKey(freqDict, c)) { freqDict[c] = freqDict[c] + 1 } else { freqDict[c] = 1 } } return(freqDict) End countCharacters B = ['a', 'b', 'a', 'c', 'b', 'd', 'a', 'c', 'b', 'e', 'd', 'a'] freqDict = countCharacters(B) ```
Single correct
EASY
4 marks
03 August 2025
10
The following pseudocode is executed on the "Words" table. What does the list `L` contain at the end of execution? ``` L = [] A = "None" Read the first row X in Table 1 A = X.PartOfSpeech Move X to Table 2 while(Table 1 has more rows) { Read the first row X in Table 1 if(X.PartOfSpeech == "noun") { if(A == "Article") { L = L ++ [X.Word] } } A = X.PartOfSpeech Move X to Table 2 } ```
Single correct
MEDIUM
4 marks
03 August 2025
11
The following pseudocode is executed using the "Shopping Bills" dataset. At the end of execution, `A` represents the maximum number of unique items sold by a shop. Choose the correct code fragment(s) to complete the pseudocode. ``` D = {} while(Table 1 has more rows) { Read the first row X in Table 1 ************************ **** Fill the code **** ************************ Move X to Table 2 } A = 0 foreach a in keys(D) { if(A < length(keys(D[a]))) { A = length(keys(D[a])) } } ```
Multiple correct
HARD
5 marks
03 August 2025
12
The following pseudocode is executed using the "Library" dataset. Let `P` be a list of authors. After the execution of the pseudocode below, `dict[X]` should store the number of books having at least
200
200
200
pages and written in or after year
2000
2000
2000
by author `X` from the list `P`. Choose the correct code fragment(s) to complete the pseudocode. ``` dict = {} foreach author in P { dict[author] = 0 } while(Table 1 has more rows) { Read the first row X from Table 1 ************************ **** Fill the Code * ************************ Move X to Table 2 } ```
Multiple correct
MEDIUM
4 marks
03 August 2025
13
At the end of execution of pseudocode, which of the following statements is/are correct?
Comprehension
MEDIUM
4 marks
03 August 2025
14
What will `length(sList)` represent at the end of the execution?
Comprehension
EASY
3 marks
03 August 2025
15
What is the value of
B
B
B
at the end of the execution of the following pseudocode? ``` Procedure doSomething(aList) bDict = {} bList = [] foreach a in aList { if (not isKey(bDict, a)) { bDict[a] = True bList = [a] ++ bList } } return (bList) End doSomething A = [2, 6, 7, 2, 8, 7, 6, 2, 3] B = doSomething(A) ```
Single correct
MEDIUM
4 marks
16 March 2025
16
What is the value of
r
e
s
u
l
t
D
i
c
t
resultDict
r
es
u
l
t
D
i
c
t
at the end of the execution of the following pseudocode? ``` Procedure createFrequencyDict(aList) freqDict = {} foreach a in aList { if (isKey(freqDict, a)) { freqDict[a] = freqDict[a] + 1 } else { freqDict[a] = 1 } } return (freqDict) End createFrequencyDict A = [3, 5, 3, 7, 8, 5, 3, 8, 8, 9, 5, 3] resultDict = createFrequencyDict(A) ```
Single correct
EASY
5 marks
16 March 2025
17
The following pseudocode is executed on the "Scores" dataset. Which of the following statements is/are true at the end of the execution? Let `SeqNo` in the "Scores" dataset represent the `CardNo` of the respective student. ``` A = [] B = [] while (Table 1 has more rows) { Read the top row X from Table 1 if (X.Total > 200) { A = A ++ [X.CardNo] if (X.CityTown == "Chennai") { B = B ++ [X.CardNo] } } } ```
Multiple correct
MEDIUM
4 marks
16 March 2025
18
Let
X
X
X
be a row from the "Words" table. Consider the following procedure: ``` Procedure isRich(X) cDict = {} i = 1 while (i <= X.LetterCount) { A = ith letter in X.Word if (A is a consonant) { cDict[A] = True } i = i + 1 } if (length(keys(cDict)) > 4) { return (True) } return (False) End isRich ``` The return value of `isRich(Y)` will be `True` if
Multiple correct
MEDIUM
4 marks
16 March 2025
19
The following pseudocode is executed using the "Shopping Bills" dataset. At the end of the execution, the variable `D` captures the following information: for each customer `Z`, `D[Z]["Shop"]` stores the shops visited by `Z`, and `D[Z]["Category"]` stores the categories of the items purchased by `Z`. But the pseudocode may have mistakes. Identify all such mistakes, if any. ``` D = {} while (Pile 1 has more cards) { Read the top card X in Pile 1 D = updateDictionary(D, X) Move X to Pile 2 } Procedure updateDictionary(D, Y) if (not isKey(D, Y.CustomerName)) { D[Y.CustomerName] = {"Shop": [], "Category": []} } D[Y.CustomerName]["Shop"][Y.ShopName] = True foreach A in Y.ItemList { D[Y.CustomerName]["Shop"][A.Category] = True } return (D) End updateDictionary ```
Multiple correct
HARD
4 marks
16 March 2025
20
If `seqDict[n] == 0` is a `True` statement, then choose the correct option regarding the student with sequence number `n`.
Comprehension
EASY
3 marks
16 March 2025
21
If `seqDict[n] == 1` is a `True` statement, then choose the correct option(s) regarding the student with sequence number `n`.
Comprehension
MEDIUM
4 marks
16 March 2025
22
What will the value of `B` be at the end of the execution of the following pseudocode? ``` Procedure doSomething(aList) bDict = {} bList = [] foreach a in aList { if(not isKey(bDict, a)) { bDict[a] = True bList = bList ++ [a] } } return(bList) End doSomething A = [2, 6, 7, 2, 8, 7, 6, 2, 3] B = doSomething(A) ```
Single correct
EASY
4 marks
01 December 2024
23
Let `Z` be a row in the Words table such that `Z.Word = "mississippi"`. What will be the value of `alphaDict["s"]` at the end of the execution of the following pseudocode? ``` alphaDict = {'i': 3, 'c': 1, 'a': 1, 's': 1} alphaDict = updateDict(Z, alphaDict) Procedure updateDict(Z, Dict) i = 1 while(i <= Z.LetterCount) { x = ith letter of Z.Word if(not isKey(Dict, x)) { Dict[x] = 1 } else { Dict[x] = Dict[x] + 2 } i = i + 1 } return(Dict) End updateDict ```
Numerical
EASY
4 marks
01 December 2024
24
Based on the Olympics pseudocode above, what will `Dict` store at the end of execution?
Comprehension
MEDIUM
4 marks
01 December 2024
25
Based on the Olympics pseudocode above, what will `list` store at the end of execution of the pseudocode?
Comprehension
MEDIUM
4 marks
01 December 2024
26
Let `X` be a row from the Words table. Consider the following procedure. The return value of `isRich(Y)` will be False if ``` Procedure isRich(X) vDict = {} i = 1, A = "" while (i <= X.LetterCount) { A = ith letter in X.Word if (A is a vowel) { vDict[A] = True } i = i + 1 } if (length(keys(vDict)) >= 3) { return(True) } return(False) End isRich ```
Single correct
MEDIUM
4 marks
04 August 2024
27
The following pseudocode is executed using the Library dataset. What will `D` represent at the end of execution? ``` D = {} while (Table 1 has more rows) { Read the first row X in Table 1 if (isKey(D, X.Author)) { if (D[X.Author] > X.Year) { D[X.Author] = X.Year } } else { D[X.Author] = X.Year } Move X to Table 2 } ```
Single correct
MEDIUM
4 marks
04 August 2024
28
The following pseudocode is executed using the Words dataset. Let `X.Word` and `Y.Word` be "engineering" and "analysis" respectively. At the end of execution, which statements are correct? ``` firstDict = {}, secondDict = {}, commonDict = {} firstDict = createDict(X) secondDict = createDict(Y) foreach key in keys(firstDict) { if (isKey(secondDict, key)) { if (firstDict[key] > secondDict[key]) { commonDict[key] = firstDict[key] } else { commonDict[key] = secondDict[key] } } } Procedure createDict(Z) i = 1, x = '', Dict = {} 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 ```
Multiple correct
HARD
5 marks
04 August 2024
29
The following pseudocode is executed using the Olympics dataset. At the end of execution, which statements are correct? ``` P = {} while (Table 1 has more rows) { Read the first row X in Table 1 P = updateMedalCounts(P, X.Sport, X.Medal) Move X to Table 2 } n = doSomething(P) Procedure updateMedalCounts(Q, Sport, Medal) if (isKey(Q, Sport)) { Q[Sport][Medal] = Q[Sport][Medal] + 1 } else { Q[Sport] = {"Gold": 0, "Silver": 0, "Bronze": 0} Q[Sport][Medal] = 1 } return(Q) End updateMedalCounts Procedure doSomething(R) max = 0 for each sport in keys(R) { if (R[sport]["Gold"] > max) { max = R[sport]["Gold"] } } return(max) End doSomething ```
Multiple correct
MEDIUM
5 marks
04 August 2024
30
At the end of execution, `wordCount` represents the number of words in which the number of distinct consonants is greater than or equal to 3. The pseudocode may have mistakes. Identify all mistakes, if any. ``` wordCount = 0 while (Table 1 has more rows) { Read the first row X in Table 1 if (doSomething(X) >= 3) { wordCount = wordCount + 1 } Move X to Table 2 } Procedure doSomething(Y) A = [], i = 1 while (i < Y.LetterCount) { l = ith letter of Y.Word if (l is consonant) { A[l] = True } i = i + 1 } return(length(keys(A))) End doSomething ```
Multiple correct
MEDIUM
4 marks
04 August 2024
31
The given pseudocode is executed using the Words dataset. What does `wordCount` represent at the end of execution? ``` wordCount = 0 while (Table 1 has more rows) { Read the first row X in Table 1 if (doSomething(X) >= 3) { wordCount = wordCount + 1 } Move X to Table 2 } Procedure doSomething(Y) A = {}, i = 1 while (i <= Y.LetterCount) { L = ith letter of Y.Word if (L is consonant) { A[L] = True } i = i + 1 } return(length(keys(A))) End doSomething ```
Single correct
MEDIUM
3 marks
24 March 2024
32
What will the value of `B` be at the end of execution of the following pseudocode? ``` Procedure doSomething(aList) bDict = {} bList = [] foreach a in aList { if (not isKey(bDict, a)) { bDict[a] = True bList = bList ++ [a] } } return(bList) End doSomething A = [4, 3, 1, 3, 4, 5, 1, 2, 7] B = doSomething(A) ```
Single correct
EASY
3 marks
24 March 2024
33
The following pseudocode is executed using the Scores dataset. What will the values of `A` and `B` represent at the end of execution? ``` D = {} while (Table 1 has more rows) { Read the first row X in Table 1 if (isKey(D, X.Town/City)) { if (D[X.Town/City] > X.Physics) { D[X.Town/City] = X.Physics } } else { D[X.Town/City] = X.Physics } Move X to Table 2 } A = 0, B = 100 foreach Y in keys(D) { if (B == D[Y]) { A = A + 1 } if (B > D[Y]) { A = 1 B = D[Y] } } ```
Single correct
HARD
3 marks
24 March 2024
34
The following pseudocode is executed using the Words dataset. Let `X.Word` and `Y.Word` be "computational" and "thinking" respectively. What will be the value of `commonDict`? ``` firstDict = {}, secondDict = {}, commonDict = {} firstDict = updateDict(X, commonDict) secondDict = updateDict(Y, commonDict) foreach key in keys(firstDict) { if (isKey(secondDict, key)) { if (firstDict[key] > secondDict[key]) { commonDict[key] = firstDict[key] } else { commonDict[key] = secondDict[key] } } } Procedure updateDict(Z, Dict) i = 1, x = '' 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 ```
Single correct
HARD
4 marks
24 March 2024
35
The following pseudocode is executed using the Olympics dataset. What will `B` represent at the end of execution? ``` P = {} while (Table 1 has more rows) { Read the first row X in Table 1 P = updateMedalCounts(P, X.Sport, X.Medal) Move X to Table 2 } B = doSomething(P) Procedure updateMedalCounts(Q, Sport, Medal) if (isKey(Q, Sport)) { Q[Sport][Medal] = Q[Sport][Medal] + 1 } else { Q[Sport] = {"Gold": 0, "Silver": 0, "Bronze": 0} Q[Sport][Medal] = 1 } return(Q) End updateMedalCounts Procedure doSomething(R) max = 0 foreach sport in keys(R) { if (R[sport]["Gold"] > max) { max = R[sport]["Gold"] } } return(max) End doSomething ```
Single correct
MEDIUM
4 marks
24 March 2024
36
The following pseudocode is executed using the Shopping Bills dataset. What will `AA` represent at the end of execution? ``` BB = {}, AA = "None" while (Pile 1 has more cards) { Read the top card X in Pile 1 if (X.ShopName == "SV Stores") { BB = updateDictionary(BB, X) } Move X to Pile 2 } AA = GetKeyByKey(BB) Procedure updateDictionary(D, Y) foreach A in Y.ItemList { if (isKey(D, A.Category)) { D[A.Category] = D[A.Category] + 1 } else { D[A.Category] = 1 } } return(D) End updateDictionary Procedure GetKeyByKey(D) A = "None", B = 0 foreach Y in keys(D) { if (B < D[Y]) { A = Y B = D[Y] } } return(A) End GetKeyByKey ```
Single correct
MEDIUM
4 marks
24 March 2024
37
The following pseudocode is executed using station-wise cards of the Train dataset. At the end, `STN[X][A]` should store the number of trains running through station `X` on day `A`. Choose the correct code fragment to complete `getInfo`. ``` STN = {} while (Pile 1 has more cards) { Read the top card X in Pile 1 STN[X.StationName] = getInfo(STN, X) Move X to Pile 2 } Procedure getInfo(STN, X) ******************** * Fill the code * ******************** return(D) End getInfo ```
Single correct
MEDIUM
4 marks
24 March 2024
38
The following pseudocode is executed using the Library dataset. Let `p` be a list of authors, and after execution `dict[X]` stores the number of books having at least 200 pages and written on or after 2000 by author `X`. Choose the correct code fragment(s) to complete the pseudocode. ``` dict = {} foreach author in p { dict[author] = 0 } while (Table 1 has more rows) { Read the first row X from Table 1 ******************** * Fill the code * ******************** Move X to Table 2 } ```
Multiple correct
MEDIUM
4 marks
24 March 2024
39
The following pseudocode is executed on the Shopping Bills dataset. What will `d` represent at the end of execution? ``` d = {} while (Table 1 has more rows) { Read the first row X in Table 1 d = doSomething(X, d, "SV Stores") d = doSomething(X, d, "Big Bazaar") d = doSomething(X, d, "Sun General") Move X to Table 2 } Procedure doSomething(Y, D, S) if (isKey(D, S)) { D[S] = D[S] ++ [Y.TotalBillAmount] } else { D[S] = [Y.TotalBillAmount] } return D End doSomething ```
Single correct
MEDIUM
3 marks
03 December 2023
40
The following pseudocode is executed on the Words dataset. What will the values of `B` and `C` represent at the end of execution? ``` A = {} while (Table 1 has more rows) { Read the first row X in Table 1 A = doSomething(A, X.PartOfSpeech) Move X to Table 2 } B = 0 C = None foreach k in keys(A) { if (A[k] > B) { B = A[k] C = k } } Procedure doSomething(Y, P) if (isKey(Y, P)) { Y[P] = Y[P] + 1 } else { Y[P] = 1 } return Y End doSomething ```
Single correct
MEDIUM
3 marks
03 December 2023
41
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 execution? ``` alphaDict = {'t': 2, 'c': 1, 'a': 1, 's': 0} alphaDict = updateDict(Z, alphaDict) Procedure updateDict(Z, Dict) i = 1 while (i <= Z.LetterCount) { x = ith letter of Z.Word if (not isKey(Dict, x)) { Dict[x] = 1 } else { Dict[x] = Dict[x] + 2 } i = i + 1 } return(Dict) End updateDict ```
Numerical
EASY
4 marks
03 December 2023
42
Let `X` be a row from the Words table. Consider the following procedure. The return value of `CheckVowels(Y)` will be False if: ``` Procedure CheckVowels(X) vDict = {} i = 1 while (i <= X.LetterCount) { A = ith letter in X.Word if (A is a vowel) { vDict[A] = True } i = i + 1 } if (length(keys(vDict)) >= 3) { return(True) } return(False) End CheckVowels ```
Multiple correct
EASY
3 marks
03 December 2023
43
The following pseudocode is executed using the Olympics dataset. The variable `medalDict` should store a dictionary with player name as key mapped to another dictionary. The nested dictionary stores medal type as key mapped to a list of years in which the player won that medal. The pseudocode may have mistakes. Identify all such mistakes. ``` medalDict = {} while(Table 1 has more rows) { Read the first row X in Table 1 if(isKey(medalDict, X.Name)) { if(not(isKey(medalDict[X.Name], X.Medal))) { medalDict[X.Name][X.Medal] = medalDict[X.Name][X.Medal] ++ [X.Year] } else { medalDict[X.Name][X.Medal] = [X.Year] } } else { medalDict[X.Name][X.Medal] = [X.Year] } Move X to Table 2 } ```
Multiple correct
HARD
5 marks
06 August 2023
44
The following pseudocode is executed using the Olympics dataset. What will `B` represent at the end of execution? ``` D = {} while(Table 1 has more rows) { Read the first row X in Table 1 D = updateDict(D, X.Sport) Move X to Table 2 } B = findAValue(D) Procedure updateDict(D, a) if(isKey(D, a)) { D[a] = D[a] + 1 } else { D[a] = 1 } return(D) End updateDict Procedure findAValue(D) V = 0 foreach a in keys(D) { if(D[a] > V) { V = D[a] } } return(V) End findAValue ```
Single correct
MEDIUM
3 marks
06 August 2023
45
The following pseudocode is executed on the Words dataset. What will `Count1` represent at the end of execution? ``` D = {} A = 0, Total = 0, Count = 0 while(Table 1 has more rows) { Read the first row X in Table 1 Total = Total + X.LetterCount Count = Count + 1 if(isKey(D, X.Word)) { D[X.Word]["Freq"] = D[X.Word]["Freq"] + 1 } else { D[X.Word] = {} D[X.Word]["Freq"] = 1 D[X.Word]["LC"] = X.LetterCount } if(D[X.Word]["Freq"] > A) { A = D[X.Word]["Freq"] } Move row X to Table 2 } Avg = Total / Count Count1 = 0, Count2 = 0 foreach k in keys(D) { if(D[k]["Freq"] == A) { if(D[k]["LC"] > Avg) { Count1 = Count1 + 1 } else { Count2 = Count2 + 1 } } } ```
Single correct
HARD
5 marks
06 August 2023
46
Consider a dictionary `dict = {'A': [1, 2, 3, 4, 5], 'B': [6, 7, 8, 9], 'C': 19}`. The following procedure `DoSomething(dict)` is executed. What can the procedure return? ``` procedure DoSomething(dict) foreach i in keys(dict) { return(dict[i]) } end DoSomething ```
Multiple correct
MEDIUM
4 marks
06 August 2023
47
The following pseudocode is executed using the Library dataset. `P` is a list of authors who have written books in English. `dict[X]` stores the number of books having at least 100 pages and written on or before 2000 by author `X`. Choose the correct code fragment(s) to complete the pseudocode. ``` dict = {} foreach author in P { dict[author] = 0 } while(Table 1 has more rows) { Read the first row X from Table 1 ******************** * Fill the code * ******************** Move X to Table 2 } ```
Multiple correct
MEDIUM
3 marks
06 August 2023
48
Let `Y` be a card in the Shopping Bills dataset. Consider the following procedure. ``` Procedure findSomething(Y) D = {} foreach Z in Y.ItemList { if(isKey(D, Z.Category)) { return(Z.Category) } D[Z.Category] = True } return("None") End findSomething ``` What will `findSomething(X)` return where `X` represents the given Shopping Bills card?
Single correct
EASY
2 marks
02 April 2023
49
The following pseudocode is executed using the Words dataset. Assume that rows in Table 1 are arranged in increasing order of sequence number. What will `L` store at the end of execution? ``` L = [] A = "None" Read the first row X in Table 1 A = X.PartOfSpeech Move X to Table 2 while(Table 1 has more rows) { Read the first row Y in Table 1 if(Y.PartOfSpeech == "Noun") { if(A == "Adjective") { L = L ++ [Y.Word] } } A = Y.PartOfSpeech Move Y to Table 2 } ```
Single correct
MEDIUM
4 marks
02 April 2023
50
Let `X` be a row in the Words dataset. Procedure `isRich(X)` should return `True` if the number of distinct vowels is less than the number of distinct consonants in `X.Word`. The code may have mistakes. Identify all such mistakes, if any. ``` Procedure isRich(X) vDict = {}, wDict = {} i = 1 while(i <= X.LetterCount) { A = ith letter in X.Word if(A is a vowel) { vDict[A] = True } wDict[A] = True i = i + 1 } if(length(keys(vDict)) < length(keys(wDict))) { return(True) } return(True) End isRich ```
Multiple correct
MEDIUM
4 marks
02 April 2023
51
The following pseudocode is executed using the Olympics dataset. At the end of execution, `medalDict` should store a nested dictionary where each player maps to medal types, and each medal type maps to a list of years. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` medalDict = {} while(Table 1 has more rows) { Read the first row X in Table 1 if(isKey(medalDict, X.Name)) { if(isKey(medalDict[X.Name], X.Medal)) { medalDict[X.Name][X.Medal] = [X.Year] } else { medalDict[X.Name][X.Medal] = [X.Year] } } else { medalDict[X.Name][X.Medal] = [X.Year] } Move X to Table 2 } ```
Multiple correct
HARD
5 marks
02 April 2023
52
Consider the following pseudocode where `Y` is a row in the Words table. At the end of execution, what will be the value of `length(keys(alphaDict))` if `Y.Word` is "think"? ``` alphaDict = {'t': 2, 'e': 1} alphaDict = updateDict(Y, alphaDict) Procedure updateDict(Z, Dict) i = 1 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 ```
Numerical
EASY
4 marks
02 April 2023
53
What will `count` represent at the end of execution if the missing code is filled by: ``` if(X.Word ends with full stop) { if(X.PartOfSpeech == "Noun") { count = count + 1 } } ```
Comprehension
EASY
3 marks
02 April 2023
54
What will `count` represent at the end of execution if the missing code is filled by: ``` if(flag and X.PartOfSpeech == "Noun") { count = count + 1 } flag = False if(X.Word ends with full stop) { flag = True } ```
Comprehension
MEDIUM
3 marks
02 April 2023
55
What will each value `D[J][I]` represent at the end of execution?
Comprehension
EASY
4 marks
02 April 2023
56
Consider the dictionary `D` created in the previous question. What will the value of `L` represent at the end of execution of the following pseudocode? ``` A = 0, L = [] foreach i in keys(D) { foreach j in keys(D[i]) { B = findRange(D[i][j]) if(B == 0) { L = L ++ [j] } if(B > A) { A = B L = [j] } } } Procedure findRange(Y) p = first(Y), q = first(Y) foreach k in Y { if(k > p) { p = k } if(k < q) { q = k } } return(p - q) End findRange ```
Comprehension
HARD
5 marks
02 April 2023
57
What will be the value of `D` at the end of execution of the following pseudocode? ``` D = {'a': {'a': 5, 'b': 4}, 'b': 1} D['b'] = D['b'] + D['b'] ```
Single correct
EASY
1 marks
20 November 2022
58
Let `dict` be a dictionary. Which of the following is not a valid value of `dict`?
Single correct
EASY
1 marks
20 November 2022
59
Let `'x'`, `'y'`, and `'z'` be the only keys of dictionary `D`, and `L = keys(D)`. At the end of execution of the following pseudocode, `flag` stores `True`. Choose the possible value of `L`. ``` flag = False position = 0 foreach key in L { if((position == 1) and (key == 'y')) { flag = True } position = position + 1 } ```
Single correct
EASY
2 marks
20 November 2022
60
Consider the following pseudocode, where `D` is a dictionary. Choose a statement regarding `D` such that `sum` will always store a value greater than 0 at the end of execution. ``` sum = 0 foreach key in keys(D) { sum = sum + first(D[key]) } ```
Single correct
MEDIUM
3 marks
20 November 2022
61
Let `X` be a row from the Words table. Consider the following procedure. The return value of `isRich(Y)` will be `False` if: ``` Procedure isRich(X) vDict = {} i = 1, A = "" while(i <= X.LetterCount) { A = ith letter in X.Word if(A is a vowel) { vDict[A] = True } i = i + 1 } if(length(keys(vDict)) >= 3) { return(True) } return(False) End isRich ```
Single correct
MEDIUM
3 marks
20 November 2022
62
The following pseudocode is executed using the Words dataset. Rows are arranged in increasing sequence number. At the end of execution, `L` should store the list of nouns that appear immediately after an adjective. Choose the correct code fragment to complete the pseudocode. ``` L = [] A = "None" Read the first row X in Table 1 A = X.PartOfSpeech Move X to Table 2 while(Table 1 has more rows) { Read the first row Y in Table 1 ******************** *** Fill the code *** ******************** A = Y.PartOfSpeech Move Y to Table 2 } ```
Single correct
HARD
4 marks
20 November 2022
63
Let `medalDict` be a dictionary with player name as key mapped to the list of medals associated with the player from the Olympics dataset. `repeatMedals(medalDict)` should return the list of players who have won at least one type of medal more than once. The code may have mistakes. Identify all such mistakes, if any. ``` procedure repeatMedals(medalDict) repeatPlayers = [] foreach player in keys(medalDict) { tempDict = {} foreach medal in medalDict[player] { tempDict[medal] = True } if(length(keys(tempDict)) == length(medalDict[player])) { repeatPlayers = repeatPlayers ++ [player] } } return(repeatPlayers) End repeatMedals ```
Multiple correct
MEDIUM
4 marks
20 November 2022
64
The following pseudocode is executed using the Olympics dataset. `medalDict` should store a nested dictionary where each player maps to medal types and each medal type maps to a list of years. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` medalDict = {} while(Table 1 has more rows) { Read the first row X in Table 1 if(isKey(medalDict, X.Name)) { if(isKey(medalDict[X.Name], X.Medal)) { medalDict[X.Name][X.Medal] = [X.Year] } else { medalDict[X.Name][X.Medal] = [X.Year] } } else { medalDict[X.Name][X.Medal] = [X.Year] } Move X to Table 2 } ```
Multiple correct
HARD
5 marks
20 November 2022
65
Let `X.Word` be "thinking". At the end of execution of the following pseudocode, what will be the value of `length(keys(alphaDict))`? ``` alphabet = {'t': 2, 'e': 1, 'w': 1} alphaDict = updateDict(X, alphabet) ```
Comprehension
MEDIUM
3 marks
20 November 2022
66
Let `X.Word` and `Y.Word` be "computational" and "thinking" respectively. The following pseudocode is executed using the Words dataset and the procedure `updateDict`. At the end, what is the value of `length(keys(commonDict))`? ``` firstDict = {}, secondDict = {}, commonDict = {} firstDict = updateDict(X, commonDict) secondDict = updateDict(Y, commonDict) foreach key in keys(firstDict) { if(isKey(secondDict, key)) { if(firstDict[key] > secondDict[key]) { commonDict[key] = firstDict[key] } else { commonDict[key] = secondDict[key] } } } ```
Comprehension
MEDIUM
3 marks
20 November 2022
67
Consider the dictionary `commonDict` created in the previous question. What will be the value of `commonDict['i']`?
Comprehension
MEDIUM
4 marks
20 November 2022
Showing 67 questions.