wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Rating_Cases

Total questions: 30

Worksheet time: 8mins

Name
Class
Date
1.
cubes = [1, 8, 27]
cubes.append(4 ** 3)
print(cubes)
a)
[64,1, 8, 27]
b)
[1, 8, 27, 12]
c)
[1, 8, 27, 64]
d)
[12 ,1, 8, 27]
2.
word = "galaxy"
print(word[4:50])
a)

axyaxy

b)

axy

c)

xy

d)

xyxy

3.
x = 51 % 3
print(x)
a)

17

b)

0

4.
def if_confusion(x, y):
    if x > y:
        if x - 5 > 0:
            x = y
            return "A" if y == y + y else "B"
        elif x + y > 0:
            while x > y: x -= 1
            while y > x: y -= 1
            if x == y:
                return "E"
    else:
        if x - 2 > y - 4:
            x_old = x
            x = y * y
            y = 2 * x_old
            if (x - 4) ** 2 > (y - 7) ** 2:
                return "C"
            return "D"
        return "H"
print(if_confusion(3, 7))
a)

C

b)

D

c)

E

d)

H

5.
x = 'cool'
print(x[-1] + x[-2]
        + x[-4] + x[-3])
a)

cool

b)

colo

c)

loco

d)

looc

6.
words = ['cat', 'mouse']
for word in words:
    print(len(word))
a)

1

3

b)

2

4

c)

3

5

d)

4

4

7.
word = "galaxy"
print(word[:-2] + word[-2:])
a)

yxalag

b)

yxa

c)

gal

d)

galaxy

8.
def ping(i):
    if i > 0:
        return pong(i - 1)
    return "0"
def pong(i):
    if i > 0:
        return ping(i - 1)
    return "1"
print(ping(29))
a)

0

b)

1

9.
customers = ['Marie', 'Anne', 'Donald']
customers[2:4] = ['Barack', 'Olivia', 'Sophia']
print(customers)
a)

['Marie', 'Anne', 'Barack']

b)

['Barack', 'Olivia', 'Sophia']

c)

['Marie', 'Anne', 'Barack', 'Olivia', 'Sophia']

d)

['Marie', 'Anne', 'Donald']

10.
letters = ['a', 'b', 'c',
           'd', 'e', 'f', 'g']
letters[1:] = []
print(letters)
a)

['a','b']

b)

['a','b','c']

c)

['a']

d)

['b','c','d']

11.
a, b = 0, 1
while b < 5:
    print(b)
    a, b = b, a + b
a)

0 1 2 3

b)

1 1 2 3

c)

1 2 3 4

d)

0 1 3 2

12.
print(range(5, 10)[-1])
print(range(0, 10, 3)[2])
print(range(-10, -100, -30)[1])
a)

9
6
-40

b)

5
3
-30

c)

6
9
-20

13.
def matrix_find(matrix, value):
    if not matrix or not matrix[0]:
        return False
    j = len(matrix) - 1
    for row in matrix:
        while row[j] > value:
            j = j - 1
            if j == -1:
                return False
        if row[j] == value:
            return True
    return False
matrix = [[3, 4, 4, 6],
          [6, 8, 11, 12],
          [6, 8, 11, 15],
          [9, 11, 12, 17]]
print(matrix_find(matrix=matrix, value=11))
a)

False

b)

True

14.

Kod çıktısını yorumlar mısınız? Sonuç ne olur?

4 lines
15.
def concatenation(*args, sep="/"):
    return sep.join(args)
print(concatenation("A", "B", "C", sep=","))
a)

C,B,A

b)

A,C,B

c)

A,B,C

16.
x = 5 * 3.8 - 1
print(x)
a)

18

b)

18.0

c)

14

d)

14.0

17.
words = ['cat', 'mouse', 'dog']
for word in words[:]:
    if len(word) > 3:
        words.insert(0, word)
print(words[0])
a)

dog

b)

mouse

c)

cat

18.
print("""
A
B
C
""" == "\nA\nB\nC\n")
a)

True

b)

False

19.
print('P"yt\'h"on')
a)

Pyt\hon

b)

P"yt\'h"on

c)

Python

d)

P"yt'h"on

20.

Kod bloğunu yorumlayınız.

4 lines
21.

Listeyi doğru şekilde sıralayan fonksiyon hangisidir?

a)

qsort1

b)

qsort2

22.
print("Answer")
while True:
    pass
print("42")
a)

42

b)

Answer

23.

Bu kodun çıktısı nedir?

a)

two three

b)

three

c)

four

d)

one

24.

Kod çıktısını yorumlar mısınız?

4 lines
25.

Kod çıktısını yorumlar mısınız?

4 lines
26.

Bir alışveriş sepetindeki ürünleri 1’den başlayarak numaralandırmak istiyorsunuz. Bunu Python’da tek satırda yapabilen fonksiyon hangisidir?”

a)

zip

b)

break

c)

for

d)

enumerate

27.

Bir kafede 10 bardak kahvenin hepsine aynı anda süt eklemek istiyorsunuz. Python’da listedeki her elemana aynı işlemi uygulamak için hangi yapı kullanılır?

a)

filter

b)

map

c)

reduce

d)

zip

28.

Elinizde bir öğrenci notları listesi var, 50’nin üzerindekileri ‘Geçti’, diğerlerini ‘Kaldı’ olarak işaretlemek istiyorsunuz. Python’da bunu kısa ve tek satırda yapmaya yarayan yapı nedir?

a)

Docstring

b)

List Comprehension

c)

Dict Comprehension

d)

Return

29.

Bir film listesinde hem sıralı hem de tekrar eden filmleri saklamak istiyorsunuz. Bu veri yapısı Python’da hangisidir?

a)

list

b)

dict

c)

tuple

d)

set

30.

Bir arkadaş listeniz var, fakat aynı isimler tekrar tekrar yazılmış. Sadece eşsiz kişileri görmek istiyorsunuz. Python’da hangi veri yapısını kullanırsınız?

a)

dict

b)

set

c)

list

d)

tuple