100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

2025 - INF1511 - ASSESSMENT 7 - EXPECTED QUESTIONS AND ANSWERS - SEMESTER 1

Rating
-
Sold
-
Pages
9
Grade
B
Uploaded on
07-02-2025
Written in
2024/2025

This document contains different assessments, all with scores ranging from 90% to 100%. Using it appropriately ensures passing with distinction.

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
February 7, 2025
Number of pages
9
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

2025 – INF1511 – ASSESSMENT 7 – QUESTIONS AND ANSWERS



Assessment 7
Started on Sunday, 22 September 2024,
State Finished
Completed on Sunday, 22 September 2024,
Time taken
Marks 15.00/15.00
Grade 100.00 out of 100.00


Question 1
What is the output from the execution of the code?


myLine = 'Python is a great language'
#open the file
myFile='testfile.txt'
f = open(myFile, 'w')
#write or read
f.write('\n%s' %myLine)
#close the file
f.close()
#open the file
f = open(myFile)
#read the file
while True:
line = f.readline()
if len(line) == 0:
break
print (line,)
#close the file
f.close()

a.
Python is a great language
b.

1

, 2025 – INF1511 – ASSESSMENT 7 – QUESTIONS AND ANSWERS


myLine
c.
IO error
d.
syntax error



Question 2
What is the function of the following code?


#comment
nCount=int(input('How may lines? '))
#comment
myFile='testfile.txt'
f = open(myFile, 'a' )
for i in range(0, nCount):
myLine=input('Enter the line : ')
f.write("\n%s" %myLine)
f.close()

a.
to modify lines in a file
b.
to delete lines in a file
c.
to append lines to a file
d.
to select lines in a file



Question 3
What is the output from the execution of the following code?


myFile='testfile.txt'
f = open(myFile, 'r')


2

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
sotholesacademicachievers University of Cape Town
Follow You need to be logged in order to follow users or courses
Sold
16
Member since
11 months
Number of followers
0
Documents
53
Last sold
2 months ago

4.0

2 reviews

5
1
4
0
3
1
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions