WorksheetsPython ООП Сұрақтары
Total questions: 36
Worksheet time: 18mins
name атрибутымен Person класын қалай құруға болады?
class Person: def __init__(self,name): self.name=name
class Person(name): pass
def class Person(name): pass
Person = class(name)
"Alice" деп аталатын Person класс нысанын қалай жасауға болады?
p = Person("Alice")
p = Person.name("Alice")
p = Person({name:"Alice"})
p = new Person("Alice")
p say_hello() нысан әдісін қалай шақыруға болады?
p.say_hello()
p.say_hello
Person.say_hello()
say_hello(p)
Person-нан Student класын қалай мұра етуге болады?
class Student(Person): pass
class Student: Person
class Student extends Person: pass
Student(Person)
Мұрагерден ата-ана әдісін қалай шақыруға болады?
super().method()
Person.method()
self.method()
base.method()
Класста __age жеке атрибутын қалай жасауға болады?
self.__age
self.age
__age
private age
Класста статикалық әдісті қалай жасауға болады?
@staticmethod
@classmethod
@property
static def
Класс әдісін қалай құруға болады?
@classmethod
@staticmethod
@property
def class
classmethod def
Класста getter-i қасиетті қалай жасауға болады?
@property
@staticmethod
def get_x()
@classmethod
getter def
f функциясын асинхронды түрде қалай шақыруға болады?
async def f(): await something
def async f(): pass
def f(): async something
f.async()
await f()
0-ден 4-ке дейінгі сандар генераторын қалай жасауға болады?
(x for x in range(5))
[x for x in range(5)]
{x for x in range(5)}
generator(range(5))
range(5)
g генераторының келесі мәнін қалай алуға болады?
next(g)
g.next()
g.get()
g.next_value()
next_value(g)
Санды 2 есе ұлғайтатын lambda функциясын қалай жасауға болады?
lambda x: x2
def f(x): x2
lambda x: return x2
f = lambda x -> x2
f = lambda x: return x*2
[1,2,3] барлық тізім элементтеріне map арқылы функцияны қалай қолдануға болады?
list(map(lambda x: x2,[1,2,3]))
map(lambda x: x2,[1,2,3])
[lambda x: x2 for x in [1,2,3]]
тен жұп сандарды filter арқылы қалай сүзуге болады?
list(filter(lambda x: x%2==0,[1,2,3,4]))
[x for x in [1,2,3,4] if x%2==0]
filter([1,2,3,4], lambda x: x%2==0)
map(lambda x: x%2==0,[1,2,3,4])
Python-да оқу үшін data.txt файлын қалай ашуға болады?
open("data.txt","r")
open("data.txt","w")
open("data.txt","a")
open("data.txt","x")
Бар файлды қайта жазбай жазу үшін файлды қалай ашуға болады?
open("data.txt","x")
open("data.txt","w")
open("data.txt","a")
open("data.txt","r")
Файлға "Hello" жолын қалай жазуға болады?
file.write("Hello")
file.print("Hello")
write(file,"Hello")
file.add("Hello")
Файлды қалай жабуға болады?
file.close()
close(file)
file.exit()
file.stop()
Автоматты түрде жабылатын файлды қалай қауіпсіз ашуға болады?
with open("data.txt","r") as f: pass
file = open("data.txt","r")
f = open("data.txt","r")
try: f = open("data.txt","r")
Бүкіл файлды жолға қалай оқуға болады?
file.read()
file.readline()
file.readlines()
file.input()
Файлды жол жолмен қалай оқуға болады?
file.readlines()
file.read()
file.readline()
file.getline()
math модулін қалай импорттауға болады?
import math
from math import *
import math as m
include math
import math кейін math модулінен sqrt функциясын қалай пайдалануға болады?
math.sqrt(16)
sqrt(16)
math.sqrt16()
math.sqr(16)
from math import sqrt –дан кейін sqrt функциясын қалай пайдалануға болады?
sqrt(25)
math.sqrt(25)
sqrt25()
math.sqr(25)
rnd псевдоним атымен random модулін қалай импорттауға болады?
import random as rnd
import random
from random import *
import rnd = random
1-ден 10-ға дейінгі кездейсоқ бүтін санды қалай жасауға болады?
random.randint(1,10)
random.random(1,10)
random.range(1,10)
randint(1,10)
Python-да ағымдағы уақытты time модулі арқылы қалай алуға болады?
time.time()
get.time()
time.now()
current.time()
Уақытты алу үшін қандай функция қолданылады?
time.time()
time.now()
current_time()
time.date()
Бағдарламаны 2 секундқа қалай тоқтатуға болады?
time.sleep(2)
wait(2)
delay(2)
sleep(2s)
Ерекшеліктерді өңдеу үшін қандай әдіс қолданылады?
try-except
catch
handle
error
Арнайы ерекшеліктерді қалай жасауға болады?
class MyError(Exception): pass
def MyError(): pass
MyError = Exception()
exception MyError: pass
Функция үшін декораторды қалай жасауға болады?
def decorator(func): return wrapper
def func(): pass
def wrapper(): func()
@decorator_func
f функциясы үшін декораторды қалай пайдалануға болады?
@decorator
f.decorator()
decorator(f)
f = decorator(f)
MyClass класында статикалық әдісті қалай жасауға болады?
@staticmethod
@classmethod
def staticmethod
def MyClass.static
MyClass класс әдісін қалай жасауға болады?
@classmethod
@staticmethod
def classmethod
@property
def method()
