
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
Quiz - CSE
Quiz
•
University
15 questions
Pra UAS Algoritma dan Pemrograman Lanjut
Quiz
•
University
10 questions
CS100||MsWord
Quiz
•
University
15 questions
[CEH4H3] Sistem Tertanam Ganjil 1819 Kuis Online 2
Quiz
•
University
10 questions
Google Workspace
Quiz
•
University
10 questions
Software dan Hardware
Quiz
•
University
11 questions
Microsoft Word Office
Quiz
•
10th Grade - University
15 questions
Revisão - Unidade I - Teoria da Computação
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
10 questions
Probability Practice
Quiz
•
4th Grade
15 questions
Probability on Number LIne
Quiz
•
4th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
6 questions
Appropriate Chromebook Usage
Lesson
•
7th Grade
10 questions
Greek Bases tele and phon
Quiz
•
6th - 8th Grade
Discover more resources for Computers
12 questions
IREAD Week 4 - Review
Quiz
•
3rd Grade - University
20 questions
Endocrine System
Quiz
•
University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
30 questions
W25: PSYCH 250 - Exam 2 Practice
Quiz
•
University
5 questions
Inherited and Acquired Traits of Animals
Interactive video
•
4th Grade - University
20 questions
Implicit vs. Explicit
Quiz
•
6th Grade - University
7 questions
Comparing Fractions
Interactive video
•
1st Grade - University
38 questions
Unit 8 Review - Absolutism & Revolution
Quiz
•
10th Grade - University