wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Kuis_2: Quiz Pemrograman Python

Total questions: 50

Worksheet time: 8mins

Name
Class
Date
1.

Apa yang akan dicetak oleh kode berikut? x = 5 if x > 3: print("A") else: print("B")

a)

A

b)

B

c)

5

d)

Error

e)

Tidak ada yang dicetak

2.

Apa hasil dari kode berikut? x = 10 if x > 5: print("A") elif x == 10: print("B") else: print("C")

a)

A

b)

B

c)

C

d)

Error

e)

Tidak ada yang dicetak

3.

Apa yang akan dicetak oleh kode berikut? x = 3 if x < 2: print("X") elif x == 3: print("Y") else: print("Z")

a)

X

b)

Y

c)

Z

d)

Error

e)

Tidak ada yang dicetak

4.

Apa hasil dari kode berikut? x = 4 if x == 5: print("A") elif x < 5: print("B") else: print("C")

a)

A

b)

B

c)

C

d)

Error

e)

Tidak ada yang dicetak

5.

Apa yang akan dicetak oleh kode berikut? x = 0 if x: print("True") else: print("False")

a)

True

b)

False

c)

Error

d)

0

e)

Tidak ada yang dicetak

6.

Apa hasil dari kode berikut? for i in range(3): print(i)

a)

0

b)

1

c)

2

d)

0 1 2

e)

Error

7.

Apa yang akan dicetak oleh kode berikut? for i in range(1, 5, 2): print(i)

a)

1

b)

1 3

c)

1 2 3

d)

2 4

e)

Error

8.

Apa yang akan dicetak oleh kode berikut? x = 10 for i in range(2, 6): if x % i == 0: print(i)

a)

2

b)

5

c)

2 5

d)

2 5 10

e)

Error

9.

Apa yang akan dicetak oleh kode berikut? for i in range(3): for j in range(2): print(i, j)

a)

0 0, 0 1, 1 0, 1 1, 2 0, 2 1

b)

0 0, 1 0, 2 0

c)

0 1, 1 2, 2 3

d)

0 1, 1 2

e)

Error

10.

Apa hasil dari kode berikut? x = 3 while x > 0: print(x) x -= 1

a)

3 2 1

b)

3 2

c)

1 2 3

d)

3

e)

Error

11.

Apa yang akan dicetak oleh kode berikut? x = 3 while x < 3: print(x) x += 1 else: print("End")

a)

3

b)

Error

c)

End

d)

Tidak ada yang dicetak

e)

3 End

12.

Apa hasil dari kode berikut? x = 5 while x > 0: print(x) x -= 1 if x == 3: break

a)

5 4 3

b)

5 4

c)

5

d)

3

e)

Error

13.

Apa yang akan dicetak oleh kode berikut? x = 2 if x > 5: print("X is greater than 5") elif x == 2: print("X is 2") else: print("X is less than 2")

a)

X is greater than 5

b)

X is 2

c)

X is less than 2

d)

Error

e)

Tidak ada yang dicetak

14.

Apa hasil dari kode berikut? x = 5 y = 3 if x > y: print("x is greater than y") else: print("y is greater than x")

a)

x is greater than y

b)

y is greater than x

c)

Error

d)

Tidak ada yang dicetak

e)

5 3

15.

Apa yang akan dicetak oleh kode berikut? for i in range(1, 4): for j in range(1, 3): if i == 2 and j == 2: continue print(i, j)

a)

1 1, 1 2, 2 1, 2 2, 3 1, 3 2

b)

1 1, 1 2, 2 1, 3 1, 3 2

c)

1 1, 1 2, 2 1, 3 1

d)

1 1, 2 1, 3 1

e)

Error

16.

Apa yang akan dicetak oleh kode berikut? x = 10 if x % 2 == 0: print("Even") else: print("Odd")

a)

Even

b)

Odd

c)

Error

d)

Tidak ada yang dicetak

e)

10

17.

Apa hasil dari kode berikut? for i in range(5): if i % 2 == 0: print("Even") else: print("Odd")

a)

Even Odd Even Odd Even

b)

Od

18.

Apa hasil dari kode berikut? for i in range(5): if i % 2 == 0: print("Even") else: print("Odd")

a)

Even Odd Even Odd Even

b)

Odd Even Odd Even Odd

c)

Even Even Odd Odd Even

d)

Even Odd Even Odd

e)

Error

19.

Apa yang akan dicetak oleh kode berikut? x = 5 if x != 5: print("True") else: print("False")

a)

True

b)

False

c)

5

d)

Error

e)

Tidak ada yang dicetak

20.

Apa yang akan dicetak oleh kode berikut? x = 5 y = 10 if x > y: print("X") elif x == 5: print("Y") else: print("Z")

a)

X

b)

Y

c)

Z

d)

Error

e)

Tidak ada yang dicetak

21.

Apa yang akan dicetak oleh kode berikut? for i in range(4): if i == 2: continue print(i)

a)

0 1 2 3

b)

0 1 3

c)

1 2 3

d)

0 1

e)

Error

22.

Apa yang akan dicetak oleh kode berikut? while True: print("Hello") break

a)

Hello

b)

Error

c)

Tidak ada yang dicetak

d)

Hello Hello

e)

Infinite loop

23.

Apa hasil dari kode berikut? x = 5 if x >= 3 and x <= 8: print("Valid") else: print("Invalid")

a)

Valid

b)

Invalid

c)

Error

d)

Tidak ada yang dicetak

e)

5

24.

Apa yang akan dicetak oleh kode berikut? for i in range(0, 6, 3): print(i)

a)

0 1 2

b)

0 3

c)

0 3 5

d)

1 4

e)

Error

25.

Apa hasil dari kode berikut? x = 0 if x == 0: print("Zero") elif x != 0: print("Non-zero")

a)

Zero

b)

Non-zero

c)

Error

d)

Tidak ada yang dicetak

e)

0

26.

Apa yang akan dicetak oleh kode berikut? x = 3 if x == 1: print("One") elif x == 2: print("Two") else: print("Other")

a)

One

b)

Two

c)

Other

d)

Error

e)

Tidak ada yang dicetak

27.

Apa yang akan dicetak oleh kode berikut? x = 5 while x > 0: print(x) x -= 2

a)

5 3 1

b)

5 4 3 2 1

c)

5 2

d)

5 4

e)

Error

28.

Apa hasil dari kode berikut? x = 0 while x < 3: print(x) x += 1 else: print("Done")

a)

0 1 2 Done

b)

0 1 2

c)

Done

d)

1 2 3

e)

Error

29.

Apa hasil dari kode berikut? for i in range(2): for j in range(2): print(i * j)

a)

0 0 0 1

b)

0 0 1 2

c)

1 2 3 4

d)

0 1 1 2

e)

Error

30.

Apa hasil dari kode berikut? x = 5 y = 10 if x < y and x > 0: print("True") else: print("False")

a)

True

b)

False

c)

5

d)

Error

e)

Tidak ada yang dicetak

31.

Apa yang akan dicetak oleh kode berikut? x = 10 if x % 2 == 0: print("Even") elif x % 3 == 0: print("Divisible by 3") else: print("Odd")

a)

Even

b)

Divisible by 3

c)

Odd

d)

Error

e)

Tidak ada yang dicetak

32.

Apa hasil dari kode berikut? x = 5 y = 3 if x > y: print("X is greater than Y") elif x == y: print("X is equal to Y") else: print("X is smaller than Y")

a)

X is greater than Y

b)

X is equal to Y

c)

X is smaller than Y

d)

Error

e)

Tidak ada yang dicetak

33.

Apa yang akan dicetak oleh kode berikut? x = 0 for i in range(5): x += i print(x)

a)

5

b)

10

c)

15

d)

20

e)

25

34.

Apa hasil dari kode berikut? x = 7 if x == 10: print("X is 10") elif x != 7: print("X is not 7") else: print("X is 7")

a)

X is 7

b)

X is 10

c)

X is not 7

d)

Error

e)

Tidak ada yang dicetak

35.

Apa yang akan dicetak oleh kode berikut? x = 1 while x < 4: print(x) x += 1

a)

1 2 3

b)

0 1 2 3

c)

1 2

d)

3 2 1

e)

Error

36.

Apa hasil dari kode berikut? x = 3 while x > 0: print(x) x -= 1 else: print("Done")

a)

3 2 1 Done

b)

3 2 Done

c)

2 1 Done

d)

Done

e)

3 Done

37.

Apa yang akan dicetak oleh kode berikut? x = 5 y = 8 if x != y: print("Different") else: print("Same")

a)

Different

b)

Same

c)

Error

d)

Tidak ada yang dicetak

e)

5

38.

Apa yang akan dicetak oleh kode berikut? for i in range(1, 6): if i % 2 == 0: print("Even") else: print("Odd")

a)

Even Odd Even Odd Even

b)

Odd Even Odd Even Odd

c)

Even Odd Odd Even Odd

d)

Even Even Odd Even Odd

e)

Error

39.

Apa hasil dari kode berikut? x = 6 for i in range(1, 4): if x % i == 0: print(i)

a)

1 2 3

b)

2 3 6

c)

1 6

d)

1 2 3 6

e)

Error

40.

Apa yang akan dicetak oleh kode berikut? x = 0 while x < 3: print(x) x += 2

a)

0 2

b)

1 2

c)

0 1 2

d)

0 2 4

e)

Error

41.

Apa hasil dari kode berikut? x = 5 if x % 2 == 1: print("Odd") else: print("Even")

a)

Odd

b)

Even

c)

Error

d)

Tidak ada yang dicetak

e)

5

42.

Apa yang akan dicetak oleh kode berikut? x = 3 if x > 5: print("Greater") elif x == 3: print("Equal") else: print("Smaller")

a)

Greater

b)

Equal

c)

Smaller

d)

Error

e)

Tidak ada yang dicetak

43.

Apa hasil dari kode berikut? for i in range(3): for j in range(2): print(i * j)

a)

0 0 0 1 0 2

b)

0 0 1 1 2 2

c)

0 1 2 3 4 5

d)

0 1 0 2 0 3

e)

Error

44.

Apa yang akan dicetak oleh kode berikut? x = 0 if x == 0: print("Zero") else: print("Non-zero")

a)

Zero

b)

Non-zero

c)

Error

d)

Tidak ada yang dicetak

e)

0

45.

Apa hasil dari kode berikut? x = 5 y = 3 if x > y or x == 5: print("True") else: print("False")

a)

True

b)

False

c)

5

d)

Error

e)

Tidak ada yang dicetak

46.

Apa yang akan dicetak oleh kode berikut? x = 0 while x < 4: if x == 2: break print(x) x += 1

a)

0 1 2

b)

0 1

c)

0 1 2 3

d)

0 2

e)

Error

47.

Apa hasil dari kode berikut? x = 10 if x % 3 == 0: print("Divisible by 3") elif x % 2 == 0: print("Divisible by 2") else: print("Not divisible")

a)

Divisible by 3

b)

Divisible by 2

c)

Not divisible

d)

Error

e)

Tidak ada yang dicetak

48.

Apa yang akan dicetak oleh kode berikut? x = 2 for i in range(3): print(i + x)

a)

0 1 2

b)

1 2 3

c)

2 3 4

d)

2 2 2

e)

Error

49.

Apa hasil dari kode berikut? x = 6 if x % 3 == 0: print("Divisible by 3") else: print("Not divisible by 3")

a)

Not divisible by 3

b)

Tidak ada yang dicetak

c)

6

d)

Divisible by 3

e)

Error

50.

Apa yang akan dicetak oleh kode berikut? x = 1 y = 5 if x < y: print("X is less") else: print("Y is less")

a)

1 5

b)

Error

c)

Y is less

d)

Tidak ada yang dicetak

e)

X is less