Reading and Writing Files with Python Intro

Flashcard
•
Computers
•
9th - 12th Grade
•
Easy
Wayground Content
Used 1+ times
FREE Resource
Student preview

9 questions
Show all answers
1.
FLASHCARD QUESTION
Front
What is the correct way to open the file file_in.txt for reading? Options: open('file_in.txt', 'r'), open('file_in.txt','r+'), open('file_in.txt','w'), open('file_in.txt','a')
Back
open('file_in.txt', 'r')
2.
FLASHCARD QUESTION
Front
What is the best way to read an entire file into a single string?
Back
.read()
3.
FLASHCARD QUESTION
Front
What is the best way to read the first line of a file? Options: .read(), .readline(), .readlines(), .read(all)
Back
.readline()
4.
FLASHCARD QUESTION
Front
When reading text files, what are the hidden characters typically at the end of each line? Options:
, #, @, »
Back
\n
5.
FLASHCARD QUESTION
Front
Which is the best type of loop to write a file in? Options: While loop, for loop, repeat loop
Back
for loop
6.
FLASHCARD QUESTION
Front
What command can you use to separate parts of a line? Options: separate(), split(), divide(), cut()
Back
split()
7.
FLASHCARD QUESTION
Front
If I want to add to the end of a text file, I should: MyCipher = open("MyCipher.txt", "a")
Back
MyCipher = open("MyCipher.txt", "a")
8.
FLASHCARD QUESTION
Front
Which method will overwrite any existing content in a file? Options: "w", "a", "r", "x"
Back
"w"
9.
FLASHCARD QUESTION
Front
What will this code snippet do if this file exists? Options: It will ask the user for an input to write into stuff.txt. It will only read the first line in the stuff file. Read the entire stuff file at one time as a single string. Read the stuff file one line at a time.
Back
Read the stuff file one line at a time.
Similar Resources on Wayground
13 questions
Photoshop Certification Advanced

Flashcard
•
9th - 12th Grade
10 questions
Personal Finance - Filing a 1040

Flashcard
•
11th Grade
9 questions
WCE Objective 6: Manage Media Library

Flashcard
•
9th - 12th Grade
10 questions
2024 Photoshop Vocab Quick Review

Flashcard
•
9th - 12th Grade
10 questions
Chromebook Shortcuts

Flashcard
•
KG - University
11 questions
Java String Objects & Methods

Flashcard
•
12th Grade
10 questions
Image Editing Class 8/13 Formattive

Flashcard
•
9th Grade
12 questions
MS Word Practice Exam 2, Projects 1 - 3

Flashcard
•
11th - 12th Grade
Popular Resources on Wayground
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
10 questions
Ice Breaker Trivia: Food from Around the World

Quiz
•
3rd - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
20 questions
ELA Advisory Review

Quiz
•
7th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Multiplication and Division Unknowns

Quiz
•
3rd Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
30 questions
Computer Terminology Exercise #1 ( Fill Ins)

Quiz
•
9th Grade
15 questions
MLA Formatting

Quiz
•
9th Grade
20 questions
Typing Practice

Quiz
•
7th - 12th Grade
14 questions
Inputs and Outputs: Computer Science Intro

Lesson
•
5th - 9th Grade
20 questions
Google Sheets Quiz

Quiz
•
9th Grade