Which of the following describes what happens when a piece of data is written to a file quizlet?

What will be the output after the following code is executed and the user enters 75 and 0 at the first two prompts?

def main():

try:

total = int(input("Enter total cost of items? "))

num_items = int(input("Number of items "))

average = total / num_items

except ZeroDivisionError:

print('ERROR: cannot have 0 items')

except ValueError:

print('ERROR: number of items cannot be negative')

main()

What will be the output after the following code is executed and the user enters 75 and 0 at the first two prompts?

def main():

try:

total = int(input("Enter total cost of items? "))

num_items = int(input("Number of items "))

average = total / num_items

except ZeroDivisionError:

print('ERROR: cannot have 0 items')

except ValueError:

print('ERROR: number of items cannot be negative')

main()

What will be the output after the following code is executed and the user enters 75 and 0 at the first two prompts?

def main():

try:

total = int(input("Enter total cost of items? "))

num_items = int(input("Number of items "))

average = total / num_items

except ZeroDivisionError:

print('ERROR: cannot have 0 items')

except ValueError:

print('ERROR: number of items cannot be negative')

main()

What will be the output after the following code is executed and the user enters 75 and 0 at the first two prompts?

def main():

try:

total = int(input("Enter total cost of items? "))

num_items = int(input("Number of items "))

average = total / num_items

except ZeroDivisionError:

print('ERROR: cannot have 0 items')

except ValueError:

print('ERROR: number of items cannot be negative')

main()

What will be the output after the following code is executed and the user enters 75 and 0 at the first two prompts?

def main():

try:

total = int(input("Enter total cost of items? "))

num_items = int(input("Number of items "))

average = total / num_items

except ZeroDivisionError:

print('ERROR: cannot have 0 items')

except ValueError:

print('ERROR: number of items cannot be negative')

main()

Upgrade to remove ads

Only SGD 41.99/year

  1. Science
  2. Computer Science

  • Flashcards

  • Learn

  • Test

  • Match

  • Flashcards

  • Learn

  • Test

  • Match

Terms in this set (31)

If a file with the specified name already exists when the file is opened and the file is opened in 'w' mode, then an alert will appear on the screen.

False

When a piece of data is read from a file it is copied from the file into the program.

False

Closing a file disconnects the communication between the file and the program.

True

In Python there is nothing that can be done if the program tries to access a file to read that does not exist

True

Python allows the programmer to work with text and number files.

False

Strings can be written directly to a file with the write method but numbers must be converted to strings before the can be written.

True

It is possible to create a while loop that determines when the end of a file has been reached.

True

If the last line in a file is not terminated with /n the readline method will return the line without /n.

True

Which of the following is associated with a specific file and provides a way for the program to work with that file?

the file object

What is the process of retrieving data from a file called?

reading data

Which of the following describes what happens when a piece of data is written to a file?

The data is copied from a variable in RAM to a file.

Which step creates a connection between a file and a program?

open the file

How many types of files are there?

two

A(n)________ access file is also known as a direct access file.

Random Access file

Which type of file access jumps directly to a piece of data in the file without having to read all the data that comes before it?

Random

A single piece of data within a record is called a

Field

Which mode specifier will erase the contents of a file if it already exists and create the file if it does not already exist?

'w'

Which mode specifier will open a file but not let you change the file or write to it?

'r'

Which method could be used to convert a numeric value to a string?

str

Which method will return an empty string when it has attempted to read beyond the end of a file?

read

Given that the customer file references a file object, and the file was opened using the 'w' mode specifier how would you write the strong 'Mary Smith' to the file?

customer.write('Mary Smith')

When a file has been opened using the 'r' mode specifier ,which method will return the file's contents as a string?

read

Which of the following is the correct way to open a file named users.txt in 'r' mode?

infile = open('users.txt', 'r')

Which of the following is the correct way to open a file named users.txt to write it?

outfile = open('users.txt', 'w')

When a program needs to save data for later use, it writes the data in a(n)________

File

When data is written to a file, it is described as a(n)_______ file.

Output

If data is retrieved from a file by a program, this is known by the term______ file.

Read

A(n) ________ file contains data that has been encoded as text using as scheme such as ASCII.

Text

A(n)______ access file retrieves data from the beginning of the file to the end of the file.

Sequential

A(n) _________ file contains data that has not been converted to text.

Binary

A filename________ is a short sequence of characters that appear at the end of a filename, preceded by a period.

Extension

Recommended textbook solutions

Which of the following describes what happens when a piece of data is written to a file quizlet?

Computer Organization and Design MIPS Edition: The Hardware/Software Interface

5th EditionDavid A. Patterson, John L. Hennessy

220 solutions

Which of the following describes what happens when a piece of data is written to a file quizlet?

Introduction to the Theory of Computation

3rd EditionMichael Sipser

389 solutions

Which of the following describes what happens when a piece of data is written to a file quizlet?

Introduction to Algorithms

3rd EditionCharles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

720 solutions

Which of the following describes what happens when a piece of data is written to a file quizlet?

Starting Out with Java: From Control Structures Through Objects

6th EditionTony Gaddis

1,224 solutions

Sets with similar terms

Starting Out with Python, 3e Ch 6

55 terms

Adam_Turnbull5

Chapter 6 python

17 terms

Brandon_Messinger7

Chapter 6 prelab

15 terms

candilocks

CS ch. 6

15 terms

mary_jenkins8

Sets found in the same folder

Introduction to Programming - Chapter 6

25 terms

tmobile805

Introduction to Programming - Chapter 8

25 terms

billy_ball_77

Introduction to Programming - Chapter 7

25 terms

billy_ball_77

Ch 7

29 terms

tmobile805

Other sets by this creator

Chapters 1-3 review

60 terms

thomasho29

Chapter 4 Python

37 terms

thomasho29

Verified questions

COMPUTER SCIENCE

True/False: Items can be removed from a list with the del operator.

Verified answer

COMPUTER SCIENCE

A variable must be _______ before it can be used in a program.

Verified answer

COMPUTER SCIENCE

You have devised a new page-replacement algorithm that you think may be optimal. In some contorted test cases, Belady’s anomaly occurs. Is the new algorithm optimal? Explain your answer.

Verified answer

COMPUTER SCIENCE

This is an operator that raises a number to a power. a. % b. * c. ** d. /

Verified answer

Other Quizlet sets

com sci 113xw final

12 terms

Josephine_Gates8

Programming CHP 6

30 terms

Andrea_stambaughPLUS

Chapter 6 Quiz

40 terms

Megan_Mehta1

chapter 6 CSC121

40 terms

tmobile805

Related questions

QUESTION

The data type that describes text, a combination of text and numbers, or numbers that are not used in calculations, such as a ZIP code is:

15 answers

QUESTION

The structure and organization of data in a database is called a data

2 answers

QUESTION

T/F: A disadvantage of the relational database management system (RDBMS) is its inability to hide the complexities of the relational model from the user.

15 answers

QUESTION

True or False: When you create a dashboard component to display your tabular report, you can use the dashboard component editor to override the settings you chose in Dashboard Settings.

2 answers

When data is written to a file it is described as?

What is an output file? a file that data is written to. It is called an output file because the program stores output in it.

What is the process of retrieving data from a file called quizlet?

What is the process of retrieving data from a file? Known as reading data from the file.

What is the term used to describe a file that data is read from?

What is the term used to describe a file that data is read from? Input file.

Is any piece of data that is passed into a function when the function is called?

An argument is any piece of data that is passed into a function when the function is called. A parameter is a variable that receives an argument that is passed into a function.