Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python ООП Сұрақтары

Total questions: 36

Worksheet time: 18mins

Name
Class
Date
1.

name атрибутымен Person класын қалай құруға болады?

a)

class Person: def __init__(self,name): self.name=name

b)

class Person(name): pass

c)

def class Person(name): pass

d)

Person = class(name)

2.

"Alice" деп аталатын Person класс нысанын қалай жасауға болады?

a)

p = Person("Alice")

b)

p = Person.name("Alice")

c)

p = Person({name:"Alice"})

d)

p = new Person("Alice")

3.

p say_hello() нысан әдісін қалай шақыруға болады?

a)

p.say_hello()

b)

p.say_hello

c)

Person.say_hello()

d)

say_hello(p)

4.

Person-нан Student класын қалай мұра етуге болады?

a)

class Student(Person): pass

b)

class Student: Person

c)

class Student extends Person: pass

d)

Student(Person)

5.

Мұрагерден ата-ана әдісін қалай шақыруға болады?

a)

super().method()

b)

Person.method()

c)

self.method()

d)

base.method()

6.

Класста __age жеке атрибутын қалай жасауға болады?

a)

self.__age

b)

self.age

c)

__age

d)

private age

7.

Класста статикалық әдісті қалай жасауға болады?

a)

@staticmethod

b)

@classmethod

c)

@property

d)

static def

8.

Класс әдісін қалай құруға болады?

a)

@classmethod

b)

@staticmethod

c)

@property

d)

def class

e)

classmethod def

9.

Класста getter-i қасиетті қалай жасауға болады?

a)

@property

b)

@staticmethod

c)

def get_x()

d)

@classmethod

e)

getter def

10.

f функциясын асинхронды түрде қалай шақыруға болады?

a)

async def f(): await something

b)

def async f(): pass

c)

def f(): async something

d)

f.async()

e)

await f()

11.

0-ден 4-ке дейінгі сандар генераторын қалай жасауға болады?

a)

(x for x in range(5))

b)

[x for x in range(5)]

c)

{x for x in range(5)}

d)

generator(range(5))

e)

range(5)

12.

g генераторының келесі мәнін қалай алуға болады?

a)

next(g)

b)

g.next()

c)

g.get()

d)

g.next_value()

e)

next_value(g)

13.

Санды 2 есе ұлғайтатын lambda функциясын қалай жасауға болады?

a)

lambda x: x2

b)

def f(x): x2

c)

lambda x: return x2

d)

f = lambda x -> x2

e)

f = lambda x: return x*2

14.

[1,2,3] барлық тізім элементтеріне map арқылы функцияны қалай қолдануға болады?

a)

list(map(lambda x: x2,[1,2,3]))

b)

map(lambda x: x2,[1,2,3])

c)

[lambda x: x2 for x in [1,2,3]]

15.

тен жұп сандарды filter арқылы қалай сүзуге болады?

a)

list(filter(lambda x: x%2==0,[1,2,3,4]))

b)

[x for x in [1,2,3,4] if x%2==0]

c)

filter([1,2,3,4], lambda x: x%2==0)

d)

map(lambda x: x%2==0,[1,2,3,4])

16.

Python-да оқу үшін data.txt файлын қалай ашуға болады?

a)

open("data.txt","r")

b)

open("data.txt","w")

c)

open("data.txt","a")

d)

open("data.txt","x")

17.

Бар файлды қайта жазбай жазу үшін файлды қалай ашуға болады?

a)

open("data.txt","x")

b)

open("data.txt","w")

c)

open("data.txt","a")

d)

open("data.txt","r")

18.

Файлға "Hello" жолын қалай жазуға болады?

a)

file.write("Hello")

b)

file.print("Hello")

c)

write(file,"Hello")

d)

file.add("Hello")

19.

Файлды қалай жабуға болады?

a)

file.close()

b)

close(file)

c)

file.exit()

d)

file.stop()

20.

Автоматты түрде жабылатын файлды қалай қауіпсіз ашуға болады?

a)

with open("data.txt","r") as f: pass

b)

file = open("data.txt","r")

c)

f = open("data.txt","r")

d)

try: f = open("data.txt","r")

21.

Бүкіл файлды жолға қалай оқуға болады?

a)

file.read()

b)

file.readline()

c)

file.readlines()

d)

file.input()

22.

Файлды жол жолмен қалай оқуға болады?

a)

file.readlines()

b)

file.read()

c)

file.readline()

d)

file.getline()

23.

math модулін қалай импорттауға болады?

a)

import math

b)

from math import *

c)

import math as m

d)

include math

24.

import math кейін math модулінен sqrt функциясын қалай пайдалануға болады?

a)

math.sqrt(16)

b)

sqrt(16)

c)

math.sqrt16()

d)

math.sqr(16)

25.

from math import sqrt –дан кейін sqrt функциясын қалай пайдалануға болады?

a)

sqrt(25)

b)

math.sqrt(25)

c)

sqrt25()

d)

math.sqr(25)

26.

rnd псевдоним атымен random модулін қалай импорттауға болады?

a)

import random as rnd

b)

import random

c)

from random import *

d)

import rnd = random

27.

1-ден 10-ға дейінгі кездейсоқ бүтін санды қалай жасауға болады?

a)

random.randint(1,10)

b)

random.random(1,10)

c)

random.range(1,10)

d)

randint(1,10)

28.

Python-да ағымдағы уақытты time модулі арқылы қалай алуға болады?

a)

time.time()

b)

get.time()

c)

time.now()

d)

current.time()

29.

Уақытты алу үшін қандай функция қолданылады?

a)

time.time()

b)

time.now()

c)

current_time()

d)

time.date()

30.

Бағдарламаны 2 секундқа қалай тоқтатуға болады?

a)

time.sleep(2)

b)

wait(2)

c)

delay(2)

d)

sleep(2s)

31.

Ерекшеліктерді өңдеу үшін қандай әдіс қолданылады?

a)

try-except

b)

catch

c)

handle

d)

error

32.

Арнайы ерекшеліктерді қалай жасауға болады?

a)

class MyError(Exception): pass

b)

def MyError(): pass

c)

MyError = Exception()

d)

exception MyError: pass

33.

Функция үшін декораторды қалай жасауға болады?

a)

def decorator(func): return wrapper

b)

def func(): pass

c)

def wrapper(): func()

d)

@decorator_func

34.

f функциясы үшін декораторды қалай пайдалануға болады?

a)

@decorator

b)

f.decorator()

c)

decorator(f)

d)

f = decorator(f)

35.

MyClass класында статикалық әдісті қалай жасауға болады?

a)

@staticmethod

b)

@classmethod

c)

def staticmethod

d)

def MyClass.static

36.

MyClass класс әдісін қалай жасауға болады?

a)

@classmethod

b)

@staticmethod

c)

def classmethod

d)

@property

e)

def method()