Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.2, Problem 14CP
Assume the file data.txt exists and contains several lines of text. Write a short
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
please I need the best answer
Write the code that opens an output file with the filename fifty.txt, uses a loop to write the numbers 1 through 50 to the file, and closes the file.
The code to open up the file test.txt and display every line in the file on theconsole. The while loop will stop the program when the end of the file is reached.
6. Average Number of WordsIf you have downloaded the source code from the Premium Companion Website you willfind a file named text.txt in the Chapter 08 folder. The text that is in the file is storedas one sentence per line. Write a program that reads the file’s contents and calculates theaverage number of words per sentence.
Chapter 6 Solutions
Starting Out with Python (4th Edition)
Ch. 6.1 - What is an output file?Ch. 6.1 - What is an input file?Ch. 6.1 - What three steps must be taken by a program when...Ch. 6.1 - Prob. 4CPCh. 6.1 - Prob. 5CPCh. 6.1 - When writing a program that performs an operation...Ch. 6.1 - If a file already exists, what happens to it if...Ch. 6.1 - What is the purpose of opening a file?Ch. 6.1 - What is the purpose of closing a file?Ch. 6.1 - Prob. 10CP
Ch. 6.1 - In what mode do you open a file if you want to...Ch. 6.2 - Write a short program that uses a for loop to...Ch. 6.2 - Prob. 13CPCh. 6.2 - Assume the file data.txt exists and contains...Ch. 6.2 - Prob. 15CPCh. 6.3 - Prob. 16CPCh. 6.3 - Prob. 17CPCh. 6.3 - Prob. 18CPCh. 6.4 - Prob. 19CPCh. 6.4 - Prob. 20CPCh. 6.4 - What type of exception does a program raise when...Ch. 6.4 - Prob. 22CPCh. 6 - A file that data is written to is known as...Ch. 6 - A file that data is written to is known as...Ch. 6 - Before a file can be used by a program, it must be...Ch. 6 - When a program is finished using a file, it should...Ch. 6 - The contents of this type of file can be viewed in...Ch. 6 - This type of file contains data that has not been...Ch. 6 - When working with this type of file, you access...Ch. 6 - When working with this type of file, you can jump...Ch. 6 - This is a small holding section" in memory that...Ch. 6 - This marks the location of the next item that will...Ch. 6 - When a file is opened in this mode, data will be...Ch. 6 - This is a single piece of data within a record. a....Ch. 6 - Prob. 13MCCh. 6 - Prob. 14MCCh. 6 - Prob. 15MCCh. 6 - When working with a sequential access file, you...Ch. 6 - When you open a file that file already exists on...Ch. 6 - The process of opening a file is only necessary...Ch. 6 - Prob. 4TFCh. 6 - When a file that already exists is opened in...Ch. 6 - Prob. 6TFCh. 6 - You can have more than one except clause in a...Ch. 6 - Prob. 8TFCh. 6 - Prob. 9TFCh. 6 - Describe the three steps that must be taken when a...Ch. 6 - Why should a program close a file when it's...Ch. 6 - What is a read position? where is the read...Ch. 6 - If an existing file is opened in append mode, What...Ch. 6 - If a file does not exist and a program attempts to...Ch. 6 - Write a program that opens an output file with the...Ch. 6 - Write a program that opens the my_name.txt file...Ch. 6 - Write code that does the following: opens an...Ch. 6 - Prob. 4AWCh. 6 - Modify the code that you wrote in problem 4 so it...Ch. 6 - Write code that opens an output file with the...Ch. 6 - A file exists on the disk named students. txt. The...Ch. 6 - A file exists on the disk named students txt. The...Ch. 6 - Prob. 9AWCh. 6 - Prob. 10AWCh. 6 - File Display Assume a file containing a series of...Ch. 6 - File Head Display Write a program that asks the...Ch. 6 - Line Numbers Write a program that asks the user...Ch. 6 - Item Counter Assume a file containing a series of...Ch. 6 - Sum of Numbers Assume a file containing a series...Ch. 6 - Average of Numbers Assume a file containing a...Ch. 6 - Random Number File Writer Write a program that...Ch. 6 - Random Number File Reader This exercise assumes...Ch. 6 - Prob. 9PECh. 6 - Golf Scores The Springfork Amateur Golf Club has a...Ch. 6 - Personal Web Page Generator Write a program that...Ch. 6 - Average Steps Taken A Personal Fitness Tracker is...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Code an SQL statement that creates a table with all columns from the parent and child tables in your answer to ...
Database Concepts (8th Edition)
How would the following strings be converted by the CDec function? a. 48.5000 b. 34.95 c. 2,300 d. Twelve
Starting Out With Visual Basic (7th Edition)
The command from the JDK compiles a Java program.
Java How To Program (Early Objects)
Modify the Product_T table by adding an attribute QtyOnHand that can be used to track the finished goods invent...
Modern Database Management (12th Edition)
(Implement the String class) The String class is provided in the Java library. Provide your own implementation ...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Look at the following code. int x = 7; int iptr = x; What will be displayed if you send the expression iptr to ...
Starting Out with C++ from Control Structures to Objects (9th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- General Instructions: Use code blocks or online compiler to do the given program Write / copy paste the program in the space provided or upload the file. Write a program that accepts 10 integers from the user using loops and then displays the sum of odd numbers and sum of even numbers.arrow_forwardWhat does the following python code do? f = open("sample.txt", "a") Choose all that apply. Select 3 correct answer(s) Question 15 options: opens a file called sample.txt for reading reads the file called sample.txt starting from the top writes "a" to the file called sample.txt opens a file called sample.txt for appending If the file called sample.txt exists, it writes at the bottom of the file closes a file called sample.txt if the file sample.txt exists, deletes everything in it if the file sample.txt does not exist, it creates the file and opens it for writingarrow_forwardThis is a C PROGRAM. Not C++ <3 <3arrow_forward
- Blood sugar is considered normal if its rate is Ines than 140 and greater than 70 , it is considered high its rate is greater man or equal to 140 , and it is considered low its rate is less than or equal to 70 . Write a program that read form a file called " patient.txt " the data for unknown number of patients , each line in the file contain : First and the last name of the patient Age The rate of the blood sugar . Print on Screen the following : • The data of each patient ( in one line ) in addition to the string " Height " , " Low " or " Normal " depending of the rate . • The number of patients with normal blood sugar . The number of patients with high blood sugar . • The number of patients with low blood sugar . The total number of patients in the file .arrow_forwardWhat does the following python code do? f = open("sample.txt", "r") Choose all that apply. Select 2 correct answer(s) Question 13 options: writes "r" to the file called sample.txt If the file called sample.txt exists, it writes at the bottom of the file closes a file called sample.txt opens a file called sample.txt for reading if the file sample.txt does not exist, it creates the file and opens it opens a file called sample.txt for appending reads the file called sample.txt starting from the top if the file sample.txt exists, deletes everything in itarrow_forwardPython program Write a program for a string is given and you have to write this in a file named news.txt and screenshot are mustarrow_forward
- PYTHON without def function Problem Statement Suppose an input file (called "paragraph.txt") contains a paragraph of text. Read in the file and then count/print the number of times the word "book" is in the file. Hint: Punctuation should be ignored, i.e., "book?" and "book!" should increase the count. The program should also be case-insensitive. Sample Input (File paragraph.txt) I have a book. It's called Harry Potter. It's a pretty good book! Do you want to buy my BOOK? Sample Output The word 'book' appears 3 time(s).arrow_forwardWhat does the following python code do? f = open("sample.txt", "w") Choose all that apply. Select 2 correct answer(s) Question 14 options: If the file called sample.txt exists, it writes at the bottom of the file writes "w" to the file called sample.txt closes a file called sample.txt opens a file called sample.txt for appending opens a file called sample.txt for reading reads the file called sample.txt starting from the top if the file sample.txt exists, deletes everything in it if the file sample.txt does not exist, it creates the file and opens it for writingarrow_forwardProgram 5: Word Frequencies (Concordance) Use a text editor to create a text file (ex: myPaper.txt) It should contain at least 2 paragraphs with around 200 or more words. Write a Python program (HW19.py) that asks the user to provide the name of the text file. Be SURE to check that it exists!Do NOT hard-code the name of the file! Use the entry provided by the user! read from the text file NOTE: (write your program so that it ONLY works if it reads from the file specified by the user). Your program will produce a dictionary of words with the number of times each occurs. It maps a word to the number of times the word occurs Key: a word Value: the number of times the word occurs in the text. The report should be an ALPHABETIZED output table, listing the word and the number of occurrences. NOTES: The input sequence can be words, numbers or any other immutable Python object, suitable for adict Ignore case – apple is the same as Apple is the same as APPLE, etc. Discard all…arrow_forward
- Python Program Language Write a program that takes in a sentence a user inputs, turns in into title case and appends it to a file on a new line called title.txt. At the end of the sentence add the word count.arrow_forwardThe read position advances towards the end of the file when items from the file are read. the report True or False:arrow_forward(Inventory) Create an ASCII file with the following data, or use the shipped.dat file available on this book’s Web site. The headings aren’t part of the file but indicate what the data represents Using this data file, write a C++ program that reads the file and produces a report listing the shipped date, part number, first name, last name, and company name.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License