D335 Introduction to Programming in Python Test
Quizzes with Answers Verified 100% Correct
Percent decrease formula
amount * (1 - (percentageAmnt / 100))
Read file
open("file.txt") || open("file.txt", "r") || with open("file") as file:
Write file
open("file.txt", "w")
Append file
open("file.txt", "a")
Multiple file actions
open("file.txt", "initialAction+")
Set cursor (place in file) (to beginning)
file.seek(0)
Use CSV library
import csv
Read csv file
with open("file.csv") as file: csv.reader(file)
Read csv file as dictionary
with open("file.csv") as file: csv.DictReader(file)
Trim (remove whitespace)
" string ".strip()
Quizzes with Answers Verified 100% Correct
Percent decrease formula
amount * (1 - (percentageAmnt / 100))
Read file
open("file.txt") || open("file.txt", "r") || with open("file") as file:
Write file
open("file.txt", "w")
Append file
open("file.txt", "a")
Multiple file actions
open("file.txt", "initialAction+")
Set cursor (place in file) (to beginning)
file.seek(0)
Use CSV library
import csv
Read csv file
with open("file.csv") as file: csv.reader(file)
Read csv file as dictionary
with open("file.csv") as file: csv.DictReader(file)
Trim (remove whitespace)
" string ".strip()