TA MODUL 4 (VERSI 2)

TA MODUL 4 (VERSI 2)

University

10 Qs

quiz-placeholder

Similar activities

Pemrograman Dasar - QUIZ

Pemrograman Dasar - QUIZ

10th Grade - Professional Development

10 Qs

DDP1 - Strings and Text Files

DDP1 - Strings and Text Files

University

6 Qs

KUIS PRAK. 9: MANAGEMENT FILE 😼

KUIS PRAK. 9: MANAGEMENT FILE 😼

University

10 Qs

Повторення пайтон3 панда

Повторення пайтон3 панда

University

9 Qs

X-Quiz #8

X-Quiz #8

University

13 Qs

File Type Extensions

File Type Extensions

8th Grade - University

10 Qs

TA MODUL 4 (VERSI 3)

TA MODUL 4 (VERSI 3)

University

10 Qs

File Handling with Python

File Handling with Python

12th Grade - University

7 Qs

TA MODUL 4 (VERSI 2)

TA MODUL 4 (VERSI 2)

Assessment

Quiz

Computers

University

Medium

Created by

Ibes Ibes

Used 3+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Perhatikan kode berikut:

   ```

   with open("file.txt", "w") as f:

       f.write("Hello\nWorld")

   print(____)

   ```

   Apa yang harus diisi untuk mengetahui posisi kursor dalam file?

f.tell()

f.pos()

f.position()

 f.cursor()

Answer explanation

Method tell() mengembalikan posisi kursor saat ini dalam file.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Perhatikan kode berikut:

   ```

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

   line = f.____()

   ```

   Method apa yang digunakan untuk membaca satu baris?

readnext

readline

readone

getline

Answer explanation

readline() membaca satu baris dari file.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Lengkapi kode berikut untuk membaca file dalam mode binary:

   ```

   with open("image.jpg", ____) as f:

       data = f.read()

   ```

"rb"

"b"

"binary"

"bin"

Answer explanation

Mode "rb" digunakan untuk membaca file dalam format binary.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Perhatikan kode berikut:

    ```

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

    lines = f.____().____()

    ```

    Lengkapi kode untuk membaca semua baris dan menghapus newline character:

readlines, strip

read, splitlines

readlines, splitlines

read, strip

Answer explanation

readlines() membaca semua baris, splitlines() menghapus newline characters.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Perhatikan kode berikut:

    ```

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

        for ____ in f:

            print(line)

    ```

    Apa yang harus diisi untuk iterasi per baris?

word

char

line

text

Answer explanation

Dalam iterasi file, setiap iterasi menghasilkan satu baris.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Perhatikan kode berikut:

    ```

    import os

    os.____("file.txt")

    ```

    Fungsi apa yang digunakan untuk menghapus file?

delete

remove

unlink

Semua jawaban benar

Answer explanation

delete, remove, dan unlink adalah sinonim untuk menghapus file.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Apa yang terjadi ketika file ditutup?

File dihapus dari disk

File dikembalikan ke sistem operasi

File dienkripsi

File dikompres

Answer explanation

Menutup file membebaskan sumber daya sistem.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?