Search Header Logo

TA MODUL 2 (VERSI 3)

Authored by Ibes Ibes

Other

University

Used 4+ times

TA MODUL 2 (VERSI 3)
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Perhatikan kode berikut

   Operator manakah yang tepat untuk mengisi bagian yang kosong agar menghasilkan output "1 2 3 4"?

=

+=

*=


/=


Answer explanation

Operator += menambahkan nilai 1 ke variabel i pada setiap iterasi.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Apa output dari kode berikut?

3 4 5 6 7

 3 5 7

 4 6 8


  3 6


Answer explanation

range(3, 8, 2) menghasilkan deret dengan start=3, stop=8 (eksklusif), dan step=2.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Perhatikan kode berikut

    Apakah output yang dihasilkan?

5

10

15

Error

Answer explanation

Fungsi outer membuat closure dengan nilai x=10, kemudian inner menambahkan y=5.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Lengkapi kode berikut untuk membuat fungsi yang valid

func

void

def

function

Answer explanation

'def' adalah keyword untuk mendefinisikan fungsi dalam Python.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Perhatikan kode berikut:

i = 0

while True:

if i >= 5:

break

print(i, end=' ')

i += 1

    Apakah output yang dihasilkan?

0 1 2 3 4 5

0 1 2 3 4


1 2 3 4 5


Infinite loop


Answer explanation

Loop berhenti ketika i mencapai 5, setelah mencetak 0 sampai 4.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Manakah syntax yang benar untuk membuat fungsi dengan parameter *args?

def func(*args)

def func(**args)


def func(args*)


def func(*arg)


Answer explanation

*args adalah sintaks yang benar untuk parameter variadic.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Apa output dari kode berikut?

def outer():

x = 1

def inner():

nonlocal x 

x = 2 i

nner()

return x 

print(outer())

1

2

None

Error

Answer explanation

Keyword nonlocal memungkinkan inner function mengubah variabel outer function.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?