D335: Questions With Apposite Solutions
Percent decrease formula Correct Answer - amount * (1 -
(percentageAmnt / 100))
Read file Correct Answer - open("file.txt") || open("file.txt",
"r") || with open("file") as file:
Write file Correct Answer - open("file.txt", "w")
Append file Correct Answer - open("file.txt", "a")
Multiple file actions Correct Answer - open("file.txt",
"initialAction+")
Set cursor (place in file) (to beginning) Correct Answer -
file.seek(0)
Use CSV library Correct Answer - import csv
Read csv file Correct Answer - with open("file.csv") as file:
csv.reader(file)
Read csv file as dictionary Correct Answer - with
open("file.csv") as file: csv.DictReader(file)
Trim (remove whitespace) Correct Answer - " string ".strip()
Trim (remove whitespace) from beginning Correct Answer - "
string".lstrip()