We use cookies to give you the best experience possible. By continuing we’ll assume you’re on board with our cookie policy

Programming Language

The whole doc is available only for registered users

A limited time offer! Get a custom sample essay written according to your requirements urgent 3h delivery guaranteed

Order Now

True or False
1) When working with a sequential access file, you can jump directly to any piece of data in the file without reading the data that comes before it. False
2) In most languages, when you open an output file and that file already exists on the disk, the contents of the existing file will be erased. True
4)The purpose of an EOF marker is to indicate where a field ends. Files typically contain several EOF markers.
5) When an input file is opened, its read position is initially set to the first item in the file.
Algorythm Workbench
1) Design a program that opens an output file with an external name my_name.dat, writes your name to the file, and then closes the file.

Declare OutputFile myFile

//Declare the variable to hold values
//that will be read from file
Declare String name

//Open a file named_.dat on the disk
Open myFile”Your Name”

//Close the file
Close myFile
2) Design a program that opens the my_name.dat file that was created by the algorithm in question 1, reads your name from the file, displays the name on the screen, and then close the file.

Decalare InputFile myName
Declare string name
Open myName”myName.dat”

Display “Your name is: ”
While Not eof (myName)
Read myName name
Display name
End while

Close my name
3) Design an algorithm that does the following: Opens an output file with the external name number_list.dat, uses a loop to write the numbers 1 through 100 to the file and then closes the file.

Declare OutputFile numberlist
Declare interger i
Open numberList “number_list.dat”

For I = 1 To 100
Write myFile i
Next i
End For

Close numberList
4) Design an algorithm that does the following: Opens the number_list.dat file that was created by the algorithm created in question 3, reads all of the numbers from the file.

Declare InputFile numberList
Declare integer i
Open numberList “number_list.dat”

Display “Here are the numbers: “
While NOT eof (numberList)
Read numberList i
Dislpay i
End While

Close myName
Programming Exercise’s
1) File display
Assume that a file containing a series of integers is named numbers.dat and exists on the computers disk. Design a program that displays all of the numbers in the file.
Def main():
largest= None

Num_input=int(input(“How many numbers “ + “ You have to input?”))

Numbers_file= open(‘numbers.dat’,’w’)

For count in range(1, num_input+1):
Number= float(input(‘Enter the Number #’ + str(count) +str(count) + ‘:’))

If largest is None or n > largest:
Largest= n
Print(‘The largest value inputted is ‘, largest)
2) Item Counter
Assume a file containing a series of names (as strings) is named names.dat and exists on the computers’ disk. Design a program that displays the number of names that are stored in the file. (Hint: Open the file and read every string stored in it. Each time you read a string, increment a counter variable. When you’ve read all the strings from the file, the counter variable will contain the number of names stored in the file.)

Infile = Open (‘names.txt’,’r’)
Count = 0
Line = infile. readline ()
while line!= ‘’:
print (line, end=”)
count + =1
line = infile.readline ()
infile.close ()
print (“there were a total of “, count, “name(s).”)

Related Topics

We can write a custom essay

According to Your Specific Requirements

Order an essay
Materials Daily
100,000+ Subjects
2000+ Topics
Free Plagiarism
All Materials
are Cataloged Well

Sorry, but copying text is forbidden on this website. If you need this or any other sample, we can send it to you via email.

By clicking "SEND", you agree to our terms of service and privacy policy. We'll occasionally send you account related and promo emails.
Sorry, but only registered users have full access

How about getting this access

Your Answer Is Very Helpful For Us
Thank You A Lot!


Emma Taylor


Hi there!
Would you like to get such a paper?
How about getting a customized one?

Can't find What you were Looking for?

Get access to our huge, continuously updated knowledge base

The next update will be in:
14 : 59 : 59