NEW
Font size
Worksheetsgrade 9 week 3
Total questions: 51
Worksheet time: 26hrs 30mins
What is a data type?
Type of application
Category for values
Type of function
Storage file
Which of the following is NOT a built-in data type?
Integer
Boolean
Car
String
What is a user-defined data type?
Random function
System variable
Data type created by the programmer
Error message
In Python, how do you define a new data type?
Using int
Using define
Using class
Using object
What is an object in programming?
Image
Function
Variable that stores an instance of a class
Error
What is contained in a class?
Only numbers
Only strings
Variables and functions
Only files
Which keyword is used to create a class in Python?
type
make
class
object
What is the purpose of the __init__ function in a Python class?
Delete data
Initialize object properties
Print data
Repeat values
How do you create an object from a class?
Call it like a function
Use a loop
Print the class
Import the class
What is the output type of a class object?
String
Instance
List
Float
What is the benefit of user-defined data types?
Make the program longer
Make the code more difficult
Organize related data
Slow down performance
Which of the following is a class in this code?
Student
name
self
def
How do you access class properties?
object-property
object->property
object.property
property.object
What is meant by self in class methods?
User
Name
Instance of the class
Variable
What is meant by encapsulation?
Making code public
Grouping data and methods into a single unit
Sorting data
Deleting old code
What is an attribute in a class?
Function
Built-in method
Variable within the class
Input
What is a method in a class?
Comment
File
Function within a class
Output
Which keyword is used to create a method in a class?
method
def
call
class
What will this code do?
Error
Create a variable
Create a car object
Print Honda
What is mycar.model in the code above?
Method
Property
Loop
Function
What is the correct way to define a class named Animal in Python?
make Animal:
new class Animal:
class Animal:
def Animal:
Which keyword is used to define a function within a class?
define
func
def
function
What is the output of this code?
Lina
name
Student
s
What is meant by 'self' in class methods?
Program
User
Instance of the class
The class itself
Which of the following correctly defines an attribute?
self.age = 10
age = 10
def age = 10
attr.age = 10
What is instantiation in programming?
Deleting a class
Printing a method
Creating an object from a class
Importing Python
What is the result of this code?
Python 101
Book
title
self.title
What is the result of this code? class Book: def __init__(self, title): self.title = title mybook = Book("Python 101") print(mybook.title)
Python 101
Book
title
self.title
How do you call a method from an object?
object->method()
object:method()
object.method()
method.object()
Which of the following can be owned by a class?
Only numbers
Only text
Attributes and methods
Only variables
What is the purpose of using classes in text-based programs?
To increase file size
To print text only
To organize data and behavior
To write loops only
What does the __init__ function do?
Deletes a class
Initializes object data
Duplicates a variable
Imports a file
Which of the following is the correct definition of a method in a class?
method self():
function method(self):
def method(self):
create method(self):
Which keyword is used to access the current object in Python?
current
object
this
self
In OOP, a class is like:
Blueprint
Variable
Function
Loop
What is the result of this code? class Cat: def __init__(self, name): self.name = name c = Cat("Fluffy") print(c.name)
Fluffy
Cat
name
self
Which method is automatically called when an object is created?
__print__()
__init__()
__class__()
__name__()
What does the dot (.) operator do with an object?
Deletes it
Compares it
Accesses its attributes or methods
Loops through it
What are the benefits of using user-defined data types?
Make the code unreadable
Combine related data
Reduce accuracy
Add random values
What does this code print? class Dog: def __init__(self): self.sound = "Bark" d = Dog() print(d.sound)
Bark
sound
Dog
Error
How do you define a class without properties?
class Empty: None
class Empty(): pass
class Empty: do nothing
class pass
Which of the following best describes an object?
A collection of code
A value stored in memory
An instance of a class
A loop within a class
Can a class method return a value?
No
Yes
Only if printed
Only with input
What is the file extension for saving Python programs?
.txt
.exe
.html
.py
What is the output? class Hello: def say_hi(self): return "Hi!" obj = Hello() print(obj.say_hi())
Hi!
say_hi
Hello
obj
What is a method?
A comment
A function within a class
A number
A type of error
How do you define multiple properties in __init__?
By using return
Using self multiple times
Only with a comma
Not allowed
What is an example of object creation?
Student()
s = Student()
def Student()
print(Student)
How can we use input with a user-defined type?
Input is not allowed
By writing inside print
With input() and passing to __init__
Only with strings
Which function is executed first when an object is created?
show()
print()
__init__()
__call__()
Apa yang dilakukan konstruktor?
Mencetak nilai
Membuat nama kelas
Menginisialisasi nilai saat pembuatan objek
Menghapus kelas
