
TA MODUL 4 (VERSI 3)
Authored by Ibes Ibes
Computers
University
Used 4+ times

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
Apa yang terjadi jika kita membuka file yang tidak ada dengan mode "r"?
File akan dibuat otomatiS
FileNotFoundError
File akan dibuka kosong
Program akan berhenti
Answer explanation
Python akan raise FileNotFoundError jika mencoba membuka file yang tidak ada dalam mode read.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Perhatikan kode berikut:
```
with open("file.txt", "r") as f:
content = f.read()
print(content.____)
```
Method apa yang digunakan untuk menghitung jumlah baris?
count("\n")
linecount()
countlines()
getlines()
Answer explanation
Menghitung jumlah newline characters untuk mengetahui jumlah baris
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Bagaimana cara menambahkan satu baris teks di akhir file tanpa menghapus konten yang ada?
open(file, "w+")
open(file, "a")
open(file, "r+")
open(file, "w")
Answer explanation
Mode "a" (append) menambahkan konten di akhir file tanpa menghapus konten yang ada.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Apa yang terjadi jika kita mencoba membuka file dalam mode "x" yang sudah ada?
File akan ditimpa
FileExistsError
File akan dibuka dalam mode read
Konten file akan dihapus
Answer explanation
Mode "x" raise FileExistsError jika file sudah ada.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Perhatikan kode berikut:
```
with open("file.txt", "r") as f:
print(f.____())
```
Method apa yang membaca seluruh file sebagai list of lines?
readlines
readall
readline
read
Answer explanation
readlines() membaca seluruh file dan mengembalikan list of lines.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Bagaimana cara mengecek apakah sebuah file ada?
```
import os
print(____("file.txt"))
```
os.exists
os.path.exists
os.isfile
os.file.exists
Answer explanation
os.path.exists() mengecek keberadaan file atau direktori.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Apa fungsi dari mode "w+"?
Hanya membaca
Membaca dan menulis, menghapus konten
Membaca dan menulis, tidak menghapus konten
Hanya menulis
Answer explanation
Mode "w+" menghapus konten lama dan memungkinkan membaca dan menulis.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Soal SKD
Quiz
•
University - Professi...
12 questions
Google Calendar & Google Drive
Quiz
•
7th Grade - University
13 questions
L1 - Computer Networks
Quiz
•
University
14 questions
Excel Quiz
Quiz
•
University
10 questions
Algorithm analysis: divide & conquer theory
Quiz
•
University
13 questions
Five Nights At Freddy's: Security Breach Quiz
Quiz
•
KG - Professional Dev...
10 questions
Bengkel Interpretasi Kurikulum Program DIT
Quiz
•
University
10 questions
Quiz Modul 10 - User Forms (1110)
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
29 questions
Alg. 1 Section 5.1 Coordinate Plane
Quiz
•
9th Grade
22 questions
fractions
Quiz
•
3rd Grade
11 questions
FOREST Effective communication
Lesson
•
KG
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
Discover more resources for Computers
12 questions
IREAD Week 4 - Review
Quiz
•
3rd Grade - University
7 questions
Fragments, Run-ons, and Complete Sentences
Interactive video
•
4th Grade - University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
10 questions
DNA Structure and Replication: Crash Course Biology
Interactive video
•
11th Grade - University
5 questions
Inherited and Acquired Traits of Animals
Interactive video
•
4th Grade - University
5 questions
Examining Theme
Interactive video
•
4th Grade - University
20 questions
Implicit vs. Explicit
Quiz
•
6th Grade - University
7 questions
Comparing Fractions
Interactive video
•
1st Grade - University