0
0
Intro to Computingfundamentals~10 mins

Creating and naming files in Intro to Computing - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new file named 'notes.txt'.

Intro to Computing
file = open('notes[1]', 'w')
Drag options to blanks, or click blank then click option'
A.txt
B.doc
C.pdf
D.exe
Attempts:
3 left
💡 Hint
Common Mistakes
Using an incorrect file extension like '.exe' which is for executable files.
Forgetting to include the dot before the extension.
2fill in blank
medium

Complete the code to close the file after writing.

Intro to Computing
file = open('data[1]', 'w')
file.write('Hello')
file.[2]()
Drag options to blanks, or click blank then click option'
Aopen
Bclose
C.txt
Dread
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'open()' instead of 'close()' to close the file.
Forgetting the dot before the file extension.
3fill in blank
hard

Fix the error in the code to create a file named 'report.doc'.

Intro to Computing
file = open('report[1]', 'w')
Drag options to blanks, or click blank then click option'
A.doc
B.txt
C.docx
D.pdf
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.txt' for a Word document file.
Using '.pdf' which is a different file type.
4fill in blank
hard

Fill both blanks to create a file named 'summary.csv' and write 'data' into it.

Intro to Computing
file = open('summary[1]', '[2]')
file.write('data')
file.close()
Drag options to blanks, or click blank then click option'
A.csv
Bw
Cr
D.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'r' mode which is for reading, not writing.
Using '.txt' instead of '.csv' for the file extension.
5fill in blank
hard

Fill all three blanks to create a file named 'logfile.log', write 'error' into it, and then close it.

Intro to Computing
file = open('logfile[1]', '[2]')
file.write('[3]')
file.close()
Drag options to blanks, or click blank then click option'
A.log
Bw
Cerror
Dr
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'r' mode which is for reading, not writing.
Writing the wrong string or forgetting to close the file.