SlideShare a Scribd company logo
1 of 8
Download to read offline
1 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip
in Teaching (Merit)
පයිතන් Dictionaries දත්ත ප්‍රරූපප ශ්‍රිත ටලු
1. පහත ක්‍රම  තතින්  ික්ෂනරින ර්ගයේ ත්තත ්‍රරූපප ත ්ත ිචල්‍ය ්ෂ තනිය හනි  කාරය
තන්ෂේරර පිළිතුය කුම ්ෂත?
A- d = {}
B- d = {“john”:40, “peter”:45}
C- d = {40:”john”, 45:”peter”}
D- d = (40:”john”, 45:”peter”)
i. A,B,C
ii. A,B,D
iii. A,B,C,D
iv. AC,D
v. B,C,D
2. ේම හි තන්ෂේරර ඒරර තතින්  ික්ෂනනරිනේ හි තඩංගු තුරු( keys) ර් ේ්  ේම ොරරරත?
1. d = {"john":40, "peter":45}
i) “john”, 40, 45, and “peter”
ii) “john” and “peter”
iii) 40 and 45
iv) d = (40:”john”, 45:”peter”)
v) d = (40:”john”, 45)
3. පහත පයිත්  ේ්ෂතේ හි ්‍රතිදතරර කුම ්ෂත?
1. d = {"john":40, "peter":45}
2. "john" in d
i) True
ii) False
iii) None
iv) ේතෝන පණිවුඩ ්ෂ
v) 1
4. පහත පයිත්  ේ්ෂතේ හි ්‍රතිදතරර කුම ්ෂත?
1. d1 = {"john":40, "peter":45}
2. d2 = {"john":466, "peter":45}
3. d1 == d2
i) True
ii) False
iii) None
iv) 0
v) 1
5. පහත පයිත්  ේ්ෂතේ හි ්‍රතිදතරර කුම ්ෂත?
1. d1 = {"john":40, "peter":45}
2. d2 = {"john":466, "peter":45}
3. d1 > d2
i) True
ii) False
iii) 0
iv) ේතෝන පණිවුඩ ්ෂ
v) 1
2 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip
in Teaching (Merit)
6. පහත පයිත්  ේ්ෂතේ හි ්‍රතිදතරර කුම ්ෂත?
1. d = {"john":40, "peter":45}
2. d["john"]
i) 40
ii) 45
iii) “john”
iv) “peter”
v) 4045
7. d = {“john”:40, “peter”:45}බර සිත් ර. “john” හි තන්ෂේරර තුයට (Key) තතර්‍ර ඇතිද
රටිරරාම  ම ාර තනමීම ට භරිචත ාළ හනි  ියරනයදි පි රය තන්ෂේරර පිළිතුය කුම ්ෂත?
i) d.delete(“john”:40)
ii) d.delete(“john”)
iii) del d[“john”]
iv) del d(“john”:40)
v) del.d(john)
8. d = {“john”:40, “peter”:45}, ත්ෂරර ඇතිද ික්ෂනනරින ත්තත ්‍රරූපප ට ත ්ත ිචල්‍යේ හි ඇතිද
රටිරරාම් යණර ේෙවීම ට ේ ොතර යත හනි  ර්‍ංගු ේ්ෂත කුම ්ෂත?
i) d.size() ii) len(d) iii) size(d) iv) d.len() v) del d()
9. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ්  කුම ්ෂත?
d = {"john":40, "peter":45}
print(list(d.keys()))
i) [“john”, “peter”] ii) [“john”:40, “peter”:45]
iii) (“john”, “peter”) iv) (“john”:40, “peter”:45)
v) (‘peter’, ‘john’)
10. d = {“john”:40, “peter”:45}, නුේර්  ලි ර ඇතිද පයිත්  ේ්ෂත ා ත්තත ්ෂ ්‍බර යනනීම ට
d[“susan”] නුේර්  ලි ර ධරරර ාළ ිචට සිදුර් ේ්  කුම ්ෂත?
i) “susan” ් ර පයිත්  ේ්ෂතේ හි ේරොම නතිද රටිරරාම ්ෂ ියෙර Key Error exception නුේර් 
ේතෝන පණිවුඩ ්ෂ ත්ගශර ේේ.
ii) රනඩෙටහර බරධරරි ්  ේතොයර ධරරර වී ලි ර ්‍ත තුයට තතර්‍ රටිරරාම ්ෂ ේරොම නතිද ියෙර
ි සිර්ෂ ත්ගශර ේරොේේ.
iii) “susan” ් ර පයිත්  ේ්ෂතේ හි ේරොම නතිද තුය්ෂ ියෙර KeyError exception නුේර් 
ේතෝන පණිවුඩ ්ෂ ත්ගශර ේේ.
iv) “susan නුේර්  තුය්ෂ ේරොම නතිද ියෙර ාරයා රීතිද ේතෝන ්ෂ (syntax error)ත්ගශර ේේ.
v) “susan නුේර්  තුය්ෂ ේරොම නතිද ියෙර තර්ගි ා ේතෝන ්ෂ (Logical error) ඇතිදේේ.
Tuples ශ්‍රිතස කලුණ ප පයිතන් ටලු
11. පහත ඒරරේ ්  ාරය්ෂ ම ගි්  Python හි tuple එා්ෂ තන්ෂේේත?
i) [1, 2, 3] ii) (1, 2, 3) iii) {1, 2, 3} iv) d(2) v) {}
12. t = (1, 2, 4, 3) නුේර්  ත්ෂරර ඇතිද තරේථරරා ාරය්ෂ තෙතය ේේත?
i) print(t[3]) ii) print(min(t))
iii) t[3] = 45 iv) print(max(t))
v) print(len(t))
3 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip
in Teaching (Merit)
13. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ්  කුම ්ෂත?
1. >>>t=(1,2,4,3)
2. >>>t[1:3]
i) (1, 2) ii) (1, 2, 4) iii) (2, 4) iv) (2, 4, 3) v) ( 4,3)
14. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ්  කුම ්ෂත?
1. >>>t=(1,2,4,3)
2. >>>t[1:-1]
i) (1, 2) ii) (1, 2, 4) iii) (2, 4) iv) (2, 4, 3) v)(3,4,2)
15. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ්  කුම ්ෂත?
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
i) [2, 3, 9] ii) [1, 2, 4, 3, 8, 9] iii) [1, 4, 8] iv) (1, 4, 8) v) [1, 2, 4, 3]
16. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ්  කුම ්ෂත?
1. d = {"john":40, "peter":45}
2. d["john"]
i) 40
ii) 45
iii) “john”
iv)john:40
v) “peter”
17. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ්  කුම ්ෂත?
1. >>>t = (1, 2)
2. >>>2 * t
i) (1, 2, 1, 2)
ii) [1, 2, 1, 2]
iii) (1, 1, 2, 2)
iv) (2,2,1,1)
v) [1, 1, 2, 2]
18. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ්  කුම ්ෂත?
1. >>>t1 = (1, 2, 4, 3)
2. >>>t2 = (1, 2, 3, 4)
3. >>>t1 < t2
i) True
ii) False
iii) Error
iv) 1
v) 0
4 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip
in Teaching (Merit)
19. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ්  කුම ්ෂත?
1. >>>my_tuple = (1, 2, 3, 4)
2. >>>my_tuple.append( (5, 6, 7) )
3. >>>print len(my_tuple)
i) 1
ii) 2
iii) 5
iv) 0
v) ේතෝන පණිිචඩ ්ෂ
20. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ්  කුම ්ෂත?
1. numberGames = {}
2. numberGames[(1,2,4)] = 8
3. numberGames[(4,2,1)] = 10
4. numberGames[(1,2)] = 12
5.
6. sum = 0
7. for k in numberGames:
8. sum += numberGames[k]
9.
10. print len(numberGames) + sum
i) 30 ii) 25 iii) 24 iv) 33 v) 12
පුනර්ුරප ශ්‍රිත පයිතන් ටලු
21. පහත පයිත්  රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
i) [‘ab’, ‘cd’]
ii) [‘AB’, ‘CD’]
iii) [None, None]
iv) [‘ab’,’AB’]
v) ඉහත ඒරරේ ්  ි සිර්ෂ ේරොේේ.
22. පහත පයිත්  රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
x = ['ab', 'cd']
for i in x:
x.append(i.upper())
print(x)
i) [‘AB’, ‘CD’]
ii) [‘ab’, ‘cd’, ‘AB’, ‘CD’]
iii) [‘ab’, ‘cd’]
iv) [‘ab’,’ AB’, ‘CD’]
v) ඉහත ඒරරේ ්  ි සිර්ෂ ේරොේේ.
5 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip
in Teaching (Merit)
23. පහත පයිත්  රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
i = 1
while True:
if i%3 == 0:
break
print(i)
i + = 1
i) 1 2
ii) 1 2 3
iii) ේතෝන පණිවුඩ ි 
iv) 2 1
v) ඉහත ඒරරේ ්  ි සිර්ෂ ේරොේේ.
24. පහත පයිත්  රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
i = 1
while True:
if i%7 == 0:
break
print(i)
i += 1
i) 1 2 3 4 5 6
ii) 1 2 3 4 5 6 7
iii) ේතෝන පණිවුඩ ි 
iv) 2 3 4 5 6
v) ඉහත ඒරරේ ්  ි සිර්ෂ ේරොේේ.
25. පහත පයිත්  රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
i = 5
while True:
if i%0O11 == 0:
break
print(i)
i += 1
i) 5 6 7 8 9 10
ii) 5 6 7 8
iii) 5 6
iv) ේතෝන පණිවුඩ ි 
v) 5 6 7 8 9
26. පහත පයිත්  රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
i = 5
while True:
if i%9 == 0:
break
print(i)
i += 1
i) 5 6 7 8
ii) 5 6 7 8 9
iii) 5 6 7 8 9 10 11 12 13 14 15 ….
iv) ේතෝශ පණිවුඩ ි 
v) ි සිිචේටා තරේ  ේරොේේ
6 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip
in Teaching (Merit)
27. පහත පයිත්  රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
i = 1
while True:
if i%2 == 0:
break
print(i)
i += 2
i) 1
ii) 1 2
iii) 1 2 3 4 5 6 …
iv) 1 3 5 7 9 11 …
v) 1 3 5 7 11 …
පයිත්  ශ්‍රිත (Function) ඇසුින්  ්‍රශ්ර
28- පහත ාරය ්‍රාරශ ්ෂ පයිත්  පිනයණා භරනරේරහි භරිචත රර ශ්‍රිත (Function) ෙම්බ් ධේ ් 
ෙතය ේේත?
i. රනරත රනරත භරිචත ාළ හනි  රනඩෙටහර්ෂ ේ්‍ෙ ශ්‍රිත (Function) හනඳි් ිච හනා.
ii. ශ්‍රිත (Function) ම ගි්  පිනයණා රනඩෙටහරට රඩර ෙර්ගථා ෙනානේම ්ෂ ්‍බර ේරොේේ
iii. භරිචත ාය් රරටම  කේේියා වූ ශ්‍රිත ිය්ගම රණ ාය යනනීේම් පහසුාම  පයිත්  ්‍බර
ේරොේතයි.
iv. ශ්‍රිත භරිචත ර් ේ්  රේතු මූලිා භරනරර්‍ පම ණි.
v. ඉහත සි ල්්‍ම  ියරනයදි
29- පයිත්  හි ශ්‍රිත ්ෂ ිය්ගම රණ ි රීම ට භරිචත රර ර්‍ංගු රරම  ර් ේ් ,
i. Fun
ii. Define
iii. Def
iv. Function
v. Func{}
30 පහත රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
1. def sayHello():
2. print('Hello World!')
3. sayHello()
4. sayHello()
i. Hello World!
Hello World!
ii. ‘Hello World!’
‘Hello World!’
iii. Hello
Hello
iv. ඉහත සි ල්්‍ම  ියරනයදි
v. 1 හර 2 ර පිළිතුරු ේතාම  ියරනයදි
7 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip
in Teaching (Merit)
31. පහත පයිත්  රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
1. def printMax(a, b):
2. if a > b:
3. print(a, 'is maximum')
4. elseif a == b:
5. print()
6. else:
7. print(b, 'is maximum')
8. printMax(3, 4)
i. 3
ii. 4
iii. 4 is maximum
iv. 3 is equal to 4
v. ඉහත ි සිර්ෂ ේරොේේ
32. පහත පයිත්  රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත?
1. x = 50
2. def func(x):
3. print('x is', x)
4. x = 2
5. print('Changed local x to', x)
6. func(x)
7. print('x is still', x)
i. x is still 50
ii. x is 50
iii. x is still 2
iv. x is still 100
v. ඉහත ි සිර්ෂ ේරොේේ.
vi.
33. පහත පයිත්  රනඩෙටහේර්  ාරය්ෂ ්‍රතිදතරර ායයි ත?
1. x = 50
2.
3. def func():
4. global x
5.
6. print('x is', x)
7. x = 2
8. print('Changed global x to', x)
9. func()
10. print('Value of x is', x)
i. x is 50
Changed global x to 2
Value of x is 50
ii. x is 50
Changed global x to 2
Value of x is 2
iii. x is 2
Changed global x to 50
Value of x is 2
iv. x is 50
Changed global x to 50
Value of x is 50
v. ඉහත ි සිර්ෂ ේරොේේ
8 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip
in Teaching (Merit)
34- පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් ?
1. def say(message, times = 1):
2. print(message * times)
3.
4. say('Hello')
5. say('World', 5)
i. Hello
WorldWorldWorldWorldWorld
ii. Hello
World 5
iii. Hello
World, Hello,World, Hello,World
iv. Hello
World,World,World,World,World
v. Hello
35-පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් ,
1. def func(a, b=5, c=10):
2. print('a is', a, 'and b is', b, 'and c is', c)
3.
4. func(3, 7)
5. func(25, c = 24)
6. func(c = 50, a = 100)
i) a is 7 and b is 3 and c is 10
a is 25 and b is 5 and c is 24
a is 5 and b is 100 and c is 50
ii) a is 3 and b is 7 and c is 10
a is 5 and b is 25 and c is 24
a is 50 and b is 100 and c is 5
iii) a is 3 and b is 7 and c is 10
a is 25 and b is 5 and c is 24
a is 100 and b is 5 and c is 50
iv) ඉහත 1 හර 2 පිළිතුරු ියරනයදි
v)a is 3 and b is 7 and c is 10
a is 25 and b is 5 and c is 25
a is 100 and b is 5 and c is 50

More Related Content

What's hot

ඇල්ගොරිතම හා පැස්කල් පරිගණක භාෂාව ආශ්‍රිත ගැටලු
ඇල්ගොරිතම හා පැස්කල් පරිගණක භාෂාව ආශ්‍රිත  ගැටලුඇල්ගොරිතම හා පැස්කල් පරිගණක භාෂාව ආශ්‍රිත  ගැටලු
ඇල්ගොරිතම හා පැස්කල් පරිගණක භාෂාව ආශ්‍රිත ගැටලුMahesh Kodituwakku
 
Questions for Lesson 5(AL ICT)
Questions for Lesson 5(AL ICT)Questions for Lesson 5(AL ICT)
Questions for Lesson 5(AL ICT)Mahesh Kodituwakku
 
G.C.E O/L Model Questions -Spreadsheet and DBMS
G.C.E O/L Model Questions -Spreadsheet and DBMSG.C.E O/L Model Questions -Spreadsheet and DBMS
G.C.E O/L Model Questions -Spreadsheet and DBMSMahesh Kodituwakku
 
පරිගණක පරිණාමය Evolution of Computer sinhala
පරිගණක පරිණාමය Evolution of Computer sinhalaපරිගණක පරිණාමය Evolution of Computer sinhala
පරිගණක පරිණාමය Evolution of Computer sinhalaPrabath Jayawardena
 
7 වන ඒකකය - පද්ධති විශ්ලේශනය හා පිරිසැලසුම
7 වන ඒකකය - පද්ධති විශ්ලේශනය හා පිරිසැලසුම7 වන ඒකකය - පද්ධති විශ්ලේශනය හා පිරිසැලසුම
7 වන ඒකකය - පද්ධති විශ්ලේශනය හා පිරිසැලසුමMahesh Kodituwakku
 
DFD,Activity Diagram ,Document Flow Diagram
DFD,Activity Diagram ,Document Flow DiagramDFD,Activity Diagram ,Document Flow Diagram
DFD,Activity Diagram ,Document Flow DiagramMahesh Kodituwakku
 
පරිගණකයේ පරිණාමය(Histry of computer)
පරිගණකයේ පරිණාමය(Histry of computer)පරිගණකයේ පරිණාමය(Histry of computer)
පරිගණකයේ පරිණාමය(Histry of computer)NoteGun LMS
 

What's hot (20)

AL ICT Lesson 13
AL ICT Lesson 13AL ICT Lesson 13
AL ICT Lesson 13
 
AL ICT Questions(Lesson 4)
AL ICT  Questions(Lesson 4)AL ICT  Questions(Lesson 4)
AL ICT Questions(Lesson 4)
 
AI
AIAI
AI
 
AL ICT Questions
AL ICT QuestionsAL ICT Questions
AL ICT Questions
 
ICT Model Paper
ICT Model PaperICT Model Paper
ICT Model Paper
 
ඇල්ගොරිතම හා පැස්කල් පරිගණක භාෂාව ආශ්‍රිත ගැටලු
ඇල්ගොරිතම හා පැස්කල් පරිගණක භාෂාව ආශ්‍රිත  ගැටලුඇල්ගොරිතම හා පැස්කල් පරිගණක භාෂාව ආශ්‍රිත  ගැටලු
ඇල්ගොරිතම හා පැස්කල් පරිගණක භාෂාව ආශ්‍රිත ගැටලු
 
IOT G.C.E AL ICT Questions
IOT G.C.E AL ICT QuestionsIOT G.C.E AL ICT Questions
IOT G.C.E AL ICT Questions
 
uses of ict
uses of ictuses of ict
uses of ict
 
Questions for Lesson 5(AL ICT)
Questions for Lesson 5(AL ICT)Questions for Lesson 5(AL ICT)
Questions for Lesson 5(AL ICT)
 
AL -ICT Networking -Questions
AL -ICT Networking -QuestionsAL -ICT Networking -Questions
AL -ICT Networking -Questions
 
G.C.E O/L Model Questions -Spreadsheet and DBMS
G.C.E O/L Model Questions -Spreadsheet and DBMSG.C.E O/L Model Questions -Spreadsheet and DBMS
G.C.E O/L Model Questions -Spreadsheet and DBMS
 
AL ICT LOGIC GATES
AL ICT LOGIC GATESAL ICT LOGIC GATES
AL ICT LOGIC GATES
 
AL ICT -Part 1
AL ICT -Part 1AL ICT -Part 1
AL ICT -Part 1
 
පරිගණක පරිණාමය Evolution of Computer sinhala
පරිගණක පරිණාමය Evolution of Computer sinhalaපරිගණක පරිණාමය Evolution of Computer sinhala
පරිගණක පරිණාමය Evolution of Computer sinhala
 
7 වන ඒකකය - පද්ධති විශ්ලේශනය හා පිරිසැලසුම
7 වන ඒකකය - පද්ධති විශ්ලේශනය හා පිරිසැලසුම7 වන ඒකකය - පද්ධති විශ්ලේශනය හා පිරිසැලසුම
7 වන ඒකකය - පද්ධති විශ්ලේශනය හා පිරිසැලසුම
 
AL ICT -Part 2
AL ICT -Part 2AL ICT -Part 2
AL ICT -Part 2
 
G.C.E.A/L Operating Systems
G.C.E.A/L Operating Systems G.C.E.A/L Operating Systems
G.C.E.A/L Operating Systems
 
AL ICT - Model Paper
AL ICT - Model PaperAL ICT - Model Paper
AL ICT - Model Paper
 
DFD,Activity Diagram ,Document Flow Diagram
DFD,Activity Diagram ,Document Flow DiagramDFD,Activity Diagram ,Document Flow Diagram
DFD,Activity Diagram ,Document Flow Diagram
 
පරිගණකයේ පරිණාමය(Histry of computer)
පරිගණකයේ පරිණාමය(Histry of computer)පරිගණකයේ පරිණාමය(Histry of computer)
පරිගණකයේ පරිණාමය(Histry of computer)
 

More from Mahesh Kodituwakku

More from Mahesh Kodituwakku (16)

OSI Model
OSI ModelOSI Model
OSI Model
 
G.C.E O/L and A/L Lessons
G.C.E O/L and A/L LessonsG.C.E O/L and A/L Lessons
G.C.E O/L and A/L Lessons
 
G.C.E. O/L ICT(Lesson 1)
G.C.E. O/L ICT(Lesson 1)G.C.E. O/L ICT(Lesson 1)
G.C.E. O/L ICT(Lesson 1)
 
G.C.E.AL ICT
G.C.E.AL ICT G.C.E.AL ICT
G.C.E.AL ICT
 
G.C.E. O/L ICT
G.C.E. O/L ICTG.C.E. O/L ICT
G.C.E. O/L ICT
 
HTML Questions
HTML QuestionsHTML Questions
HTML Questions
 
G.C.E O/L Model Papers( for 2019)
G.C.E O/L Model Papers( for 2019)G.C.E O/L Model Papers( for 2019)
G.C.E O/L Model Papers( for 2019)
 
දකුණු පලාත් උසස් පෙළ තොරතුරු තාක්ෂණය ප්‍රශ්න පත්‍රය 2019
දකුණු පලාත් උසස් පෙළ තොරතුරු තාක්ෂණය ප්‍රශ්න පත්‍රය 2019දකුණු පලාත් උසස් පෙළ තොරතුරු තාක්ෂණය ප්‍රශ්න පත්‍රය 2019
දකුණු පලාත් උසස් පෙළ තොරතුරු තාක්ෂණය ප්‍රශ්න පත්‍රය 2019
 
Arduino Basic for Grade 9
Arduino Basic for Grade 9Arduino Basic for Grade 9
Arduino Basic for Grade 9
 
ICT Grade 8 and 9
ICT Grade 8 and 9ICT Grade 8 and 9
ICT Grade 8 and 9
 
Grade 7 ICT
Grade 7 ICTGrade 7 ICT
Grade 7 ICT
 
Lesson 12- G.C.E.A/L ICT
Lesson 12- G.C.E.A/L ICTLesson 12- G.C.E.A/L ICT
Lesson 12- G.C.E.A/L ICT
 
Grade 10 -ICT
Grade 10 -ICTGrade 10 -ICT
Grade 10 -ICT
 
AL Questions - Programing
AL Questions - Programing AL Questions - Programing
AL Questions - Programing
 
G.C.E AL ICT Paper-A
G.C.E AL ICT Paper-AG.C.E AL ICT Paper-A
G.C.E AL ICT Paper-A
 
Grade -9 ICT Lesson Notes
Grade -9 ICT Lesson NotesGrade -9 ICT Lesson Notes
Grade -9 ICT Lesson Notes
 

පයිතන් පරිගණක භාෂාව ආශ්‍රිත ගැටලු

  • 1. 1 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip in Teaching (Merit) පයිතන් Dictionaries දත්ත ප්‍රරූපප ශ්‍රිත ටලු 1. පහත ක්‍රම තතින් ික්ෂනරින ර්ගයේ ත්තත ්‍රරූපප ත ්ත ිචල්‍ය ්ෂ තනිය හනි කාරය තන්ෂේරර පිළිතුය කුම ්ෂත? A- d = {} B- d = {“john”:40, “peter”:45} C- d = {40:”john”, 45:”peter”} D- d = (40:”john”, 45:”peter”) i. A,B,C ii. A,B,D iii. A,B,C,D iv. AC,D v. B,C,D 2. ේම හි තන්ෂේරර ඒරර තතින් ික්ෂනනරිනේ හි තඩංගු තුරු( keys) ර් ේ් ේම ොරරරත? 1. d = {"john":40, "peter":45} i) “john”, 40, 45, and “peter” ii) “john” and “peter” iii) 40 and 45 iv) d = (40:”john”, 45:”peter”) v) d = (40:”john”, 45) 3. පහත පයිත් ේ්ෂතේ හි ්‍රතිදතරර කුම ්ෂත? 1. d = {"john":40, "peter":45} 2. "john" in d i) True ii) False iii) None iv) ේතෝන පණිවුඩ ්ෂ v) 1 4. පහත පයිත් ේ්ෂතේ හි ්‍රතිදතරර කුම ්ෂත? 1. d1 = {"john":40, "peter":45} 2. d2 = {"john":466, "peter":45} 3. d1 == d2 i) True ii) False iii) None iv) 0 v) 1 5. පහත පයිත් ේ්ෂතේ හි ්‍රතිදතරර කුම ්ෂත? 1. d1 = {"john":40, "peter":45} 2. d2 = {"john":466, "peter":45} 3. d1 > d2 i) True ii) False iii) 0 iv) ේතෝන පණිවුඩ ්ෂ v) 1
  • 2. 2 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip in Teaching (Merit) 6. පහත පයිත් ේ්ෂතේ හි ්‍රතිදතරර කුම ්ෂත? 1. d = {"john":40, "peter":45} 2. d["john"] i) 40 ii) 45 iii) “john” iv) “peter” v) 4045 7. d = {“john”:40, “peter”:45}බර සිත් ර. “john” හි තන්ෂේරර තුයට (Key) තතර්‍ර ඇතිද රටිරරාම ම ාර තනමීම ට භරිචත ාළ හනි ියරනයදි පි රය තන්ෂේරර පිළිතුය කුම ්ෂත? i) d.delete(“john”:40) ii) d.delete(“john”) iii) del d[“john”] iv) del d(“john”:40) v) del.d(john) 8. d = {“john”:40, “peter”:45}, ත්ෂරර ඇතිද ික්ෂනනරින ත්තත ්‍රරූපප ට ත ්ත ිචල්‍යේ හි ඇතිද රටිරරාම් යණර ේෙවීම ට ේ ොතර යත හනි ර්‍ංගු ේ්ෂත කුම ්ෂත? i) d.size() ii) len(d) iii) size(d) iv) d.len() v) del d() 9. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් කුම ්ෂත? d = {"john":40, "peter":45} print(list(d.keys())) i) [“john”, “peter”] ii) [“john”:40, “peter”:45] iii) (“john”, “peter”) iv) (“john”:40, “peter”:45) v) (‘peter’, ‘john’) 10. d = {“john”:40, “peter”:45}, නුේර් ලි ර ඇතිද පයිත් ේ්ෂත ා ත්තත ්ෂ ්‍බර යනනීම ට d[“susan”] නුේර් ලි ර ධරරර ාළ ිචට සිදුර් ේ් කුම ්ෂත? i) “susan” ් ර පයිත් ේ්ෂතේ හි ේරොම නතිද රටිරරාම ්ෂ ියෙර Key Error exception නුේර් ේතෝන පණිවුඩ ්ෂ ත්ගශර ේේ. ii) රනඩෙටහර බරධරරි ් ේතොයර ධරරර වී ලි ර ්‍ත තුයට තතර්‍ රටිරරාම ්ෂ ේරොම නතිද ියෙර ි සිර්ෂ ත්ගශර ේරොේේ. iii) “susan” ් ර පයිත් ේ්ෂතේ හි ේරොම නතිද තුය්ෂ ියෙර KeyError exception නුේර් ේතෝන පණිවුඩ ්ෂ ත්ගශර ේේ. iv) “susan නුේර් තුය්ෂ ේරොම නතිද ියෙර ාරයා රීතිද ේතෝන ්ෂ (syntax error)ත්ගශර ේේ. v) “susan නුේර් තුය්ෂ ේරොම නතිද ියෙර තර්ගි ා ේතෝන ්ෂ (Logical error) ඇතිදේේ. Tuples ශ්‍රිතස කලුණ ප පයිතන් ටලු 11. පහත ඒරරේ ් ාරය්ෂ ම ගි් Python හි tuple එා්ෂ තන්ෂේේත? i) [1, 2, 3] ii) (1, 2, 3) iii) {1, 2, 3} iv) d(2) v) {} 12. t = (1, 2, 4, 3) නුේර් ත්ෂරර ඇතිද තරේථරරා ාරය්ෂ තෙතය ේේත? i) print(t[3]) ii) print(min(t)) iii) t[3] = 45 iv) print(max(t)) v) print(len(t))
  • 3. 3 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip in Teaching (Merit) 13. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් කුම ්ෂත? 1. >>>t=(1,2,4,3) 2. >>>t[1:3] i) (1, 2) ii) (1, 2, 4) iii) (2, 4) iv) (2, 4, 3) v) ( 4,3) 14. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් කුම ්ෂත? 1. >>>t=(1,2,4,3) 2. >>>t[1:-1] i) (1, 2) ii) (1, 2, 4) iii) (2, 4) iv) (2, 4, 3) v)(3,4,2) 15. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් කුම ්ෂත? >>>t = (1, 2, 4, 3, 8, 9) >>>[t[i] for i in range(0, len(t), 2)] i) [2, 3, 9] ii) [1, 2, 4, 3, 8, 9] iii) [1, 4, 8] iv) (1, 4, 8) v) [1, 2, 4, 3] 16. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් කුම ්ෂත? 1. d = {"john":40, "peter":45} 2. d["john"] i) 40 ii) 45 iii) “john” iv)john:40 v) “peter” 17. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් කුම ්ෂත? 1. >>>t = (1, 2) 2. >>>2 * t i) (1, 2, 1, 2) ii) [1, 2, 1, 2] iii) (1, 1, 2, 2) iv) (2,2,1,1) v) [1, 1, 2, 2] 18. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් කුම ්ෂත? 1. >>>t1 = (1, 2, 4, 3) 2. >>>t2 = (1, 2, 3, 4) 3. >>>t1 < t2 i) True ii) False iii) Error iv) 1 v) 0
  • 4. 4 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip in Teaching (Merit) 19. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් කුම ්ෂත? 1. >>>my_tuple = (1, 2, 3, 4) 2. >>>my_tuple.append( (5, 6, 7) ) 3. >>>print len(my_tuple) i) 1 ii) 2 iii) 5 iv) 0 v) ේතෝන පණිිචඩ ්ෂ 20. පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් කුම ්ෂත? 1. numberGames = {} 2. numberGames[(1,2,4)] = 8 3. numberGames[(4,2,1)] = 10 4. numberGames[(1,2)] = 12 5. 6. sum = 0 7. for k in numberGames: 8. sum += numberGames[k] 9. 10. print len(numberGames) + sum i) 30 ii) 25 iii) 24 iv) 33 v) 12 පුනර්ුරප ශ්‍රිත පයිතන් ටලු 21. පහත පයිත් රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? x = ['ab', 'cd'] for i in x: i.upper() print(x) i) [‘ab’, ‘cd’] ii) [‘AB’, ‘CD’] iii) [None, None] iv) [‘ab’,’AB’] v) ඉහත ඒරරේ ් ි සිර්ෂ ේරොේේ. 22. පහත පයිත් රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? x = ['ab', 'cd'] for i in x: x.append(i.upper()) print(x) i) [‘AB’, ‘CD’] ii) [‘ab’, ‘cd’, ‘AB’, ‘CD’] iii) [‘ab’, ‘cd’] iv) [‘ab’,’ AB’, ‘CD’] v) ඉහත ඒරරේ ් ි සිර්ෂ ේරොේේ.
  • 5. 5 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip in Teaching (Merit) 23. පහත පයිත් රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? i = 1 while True: if i%3 == 0: break print(i) i + = 1 i) 1 2 ii) 1 2 3 iii) ේතෝන පණිවුඩ ි iv) 2 1 v) ඉහත ඒරරේ ් ි සිර්ෂ ේරොේේ. 24. පහත පයිත් රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? i = 1 while True: if i%7 == 0: break print(i) i += 1 i) 1 2 3 4 5 6 ii) 1 2 3 4 5 6 7 iii) ේතෝන පණිවුඩ ි iv) 2 3 4 5 6 v) ඉහත ඒරරේ ් ි සිර්ෂ ේරොේේ. 25. පහත පයිත් රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? i = 5 while True: if i%0O11 == 0: break print(i) i += 1 i) 5 6 7 8 9 10 ii) 5 6 7 8 iii) 5 6 iv) ේතෝන පණිවුඩ ි v) 5 6 7 8 9 26. පහත පයිත් රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? i = 5 while True: if i%9 == 0: break print(i) i += 1 i) 5 6 7 8 ii) 5 6 7 8 9 iii) 5 6 7 8 9 10 11 12 13 14 15 …. iv) ේතෝශ පණිවුඩ ි v) ි සිිචේටා තරේ ේරොේේ
  • 6. 6 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip in Teaching (Merit) 27. පහත පයිත් රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? i = 1 while True: if i%2 == 0: break print(i) i += 2 i) 1 ii) 1 2 iii) 1 2 3 4 5 6 … iv) 1 3 5 7 9 11 … v) 1 3 5 7 11 … පයිත් ශ්‍රිත (Function) ඇසුින් ්‍රශ්ර 28- පහත ාරය ්‍රාරශ ්ෂ පයිත් පිනයණා භරනරේරහි භරිචත රර ශ්‍රිත (Function) ෙම්බ් ධේ ් ෙතය ේේත? i. රනරත රනරත භරිචත ාළ හනි රනඩෙටහර්ෂ ේ්‍ෙ ශ්‍රිත (Function) හනඳි් ිච හනා. ii. ශ්‍රිත (Function) ම ගි් පිනයණා රනඩෙටහරට රඩර ෙර්ගථා ෙනානේම ්ෂ ්‍බර ේරොේේ iii. භරිචත ාය් රරටම කේේියා වූ ශ්‍රිත ිය්ගම රණ ාය යනනීේම් පහසුාම පයිත් ්‍බර ේරොේතයි. iv. ශ්‍රිත භරිචත ර් ේ් රේතු මූලිා භරනරර්‍ පම ණි. v. ඉහත සි ල්්‍ම ියරනයදි 29- පයිත් හි ශ්‍රිත ්ෂ ිය්ගම රණ ි රීම ට භරිචත රර ර්‍ංගු රරම ර් ේ් , i. Fun ii. Define iii. Def iv. Function v. Func{} 30 පහත රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? 1. def sayHello(): 2. print('Hello World!') 3. sayHello() 4. sayHello() i. Hello World! Hello World! ii. ‘Hello World!’ ‘Hello World!’ iii. Hello Hello iv. ඉහත සි ල්්‍ම ියරනයදි v. 1 හර 2 ර පිළිතුරු ේතාම ියරනයදි
  • 7. 7 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip in Teaching (Merit) 31. පහත පයිත් රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? 1. def printMax(a, b): 2. if a > b: 3. print(a, 'is maximum') 4. elseif a == b: 5. print() 6. else: 7. print(b, 'is maximum') 8. printMax(3, 4) i. 3 ii. 4 iii. 4 is maximum iv. 3 is equal to 4 v. ඉහත ි සිර්ෂ ේරොේේ 32. පහත පයිත් රනඩෙටහේරහි ්‍රතිදතරර කුම ්ෂත? 1. x = 50 2. def func(x): 3. print('x is', x) 4. x = 2 5. print('Changed local x to', x) 6. func(x) 7. print('x is still', x) i. x is still 50 ii. x is 50 iii. x is still 2 iv. x is still 100 v. ඉහත ි සිර්ෂ ේරොේේ. vi. 33. පහත පයිත් රනඩෙටහේර් ාරය්ෂ ්‍රතිදතරර ායයි ත? 1. x = 50 2. 3. def func(): 4. global x 5. 6. print('x is', x) 7. x = 2 8. print('Changed global x to', x) 9. func() 10. print('Value of x is', x) i. x is 50 Changed global x to 2 Value of x is 50 ii. x is 50 Changed global x to 2 Value of x is 2 iii. x is 2 Changed global x to 50 Value of x is 2 iv. x is 50 Changed global x to 50 Value of x is 50 v. ඉහත ි සිර්ෂ ේරොේේ
  • 8. 8 Mahesh Kodituwakku-BTech-(ICT),MCTS,MIEEE,Certificate in ICT(AIT-Thailand)National Dip in Teaching (Merit) 34- පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් ? 1. def say(message, times = 1): 2. print(message * times) 3. 4. say('Hello') 5. say('World', 5) i. Hello WorldWorldWorldWorldWorld ii. Hello World 5 iii. Hello World, Hello,World, Hello,World iv. Hello World,World,World,World,World v. Hello 35-පහත රනඩෙටහේරහි ්‍රතිදතරර ර් ේ් , 1. def func(a, b=5, c=10): 2. print('a is', a, 'and b is', b, 'and c is', c) 3. 4. func(3, 7) 5. func(25, c = 24) 6. func(c = 50, a = 100) i) a is 7 and b is 3 and c is 10 a is 25 and b is 5 and c is 24 a is 5 and b is 100 and c is 50 ii) a is 3 and b is 7 and c is 10 a is 5 and b is 25 and c is 24 a is 50 and b is 100 and c is 5 iii) a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 24 a is 100 and b is 5 and c is 50 iv) ඉහත 1 හර 2 පිළිතුරු ියරනයදි v)a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 25 a is 100 and b is 5 and c is 50