Starting out with Visual C# (4th Edition)
4th Edition
ISBN: 9780134382609
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 5, Problem 5AW
Assume that a file named People.txt contains a list of names. Write a code sample that uses a while loop to read the file and display its contents in a ListBox control.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A file object’s writelines method automatically writes a newline ('\n') after writing each list item to the file.True or False
GirlNames.txt This file contains a list of the 200 most popular names given to girls born in the United States from the year 2000 through 2009.
BoyNames.txt This file contains a list of the 200 most popular names given to boys born in the United States from the year 2000 through 2009.
Write a program that reads the contents of the two files into two separate lists. The user should be able to enter a boy’s name, a girl’s name, or both, and the application will display messages indicating whether the names were among the most popular.
**programming language is python**
** must use a def main(): function**
*please include some comments*
i aslo have the .txt files but no wya to upload them
The method used to write an entire list to a file is known asa. writelinesb. writelinec. writelistsd. writelist
Chapter 5 Solutions
Starting out with Visual C# (4th Edition)
Ch. 5.1 - Prob. 5.1CPCh. 5.1 - Prob. 5.2CPCh. 5.1 - Prob. 5.3CPCh. 5.2 - What is a loop iteration?Ch. 5.2 - What is a counter variable?Ch. 5.2 - What is a pretest loop?Ch. 5.2 - Does the while loop rest its condition before or...Ch. 5.2 - What is an infinite loop?Ch. 5.3 - What messages will the following code sample...Ch. 5.3 - How many rimes will the following loop iterate?...
Ch. 5.4 - Name the three expressions that appear inside the...Ch. 5.4 - You want to write a for loop that displays I love...Ch. 5.4 - What would the following code display? for (int...Ch. 5.4 - What would the following code display? for (int...Ch. 5.5 - What is a posttest loop?Ch. 5.5 - What is the difference between the while loop and...Ch. 5.5 - How many times will the following loop iterate?...Ch. 5.6 - What is an output file?Ch. 5.6 - What is an input file?Ch. 5.6 - What three steps must be taken by a program when...Ch. 5.6 - What is the difference between a text file and a...Ch. 5.6 - Prob. 5.22CPCh. 5.6 - What type of object do you create if you want to...Ch. 5.6 - What type of object do you create if you want to...Ch. 5.6 - If you call the File.CreateText method and the...Ch. 5.6 - If you call the File.AppendText method and the...Ch. 5.6 - What is the difference between the WriteLine and...Ch. 5.6 - What method do you call to open a text file to...Ch. 5.6 - What is a files read position? Initially, where is...Ch. 5.6 - How do you read a line of text from a text file?Ch. 5.6 - How do you close a file?Ch. 5.6 - Assume inputFile references a StreamReader object...Ch. 5.7 - What is the benefit of using an Open and/or Save...Ch. 5.7 - Prob. 5.34CPCh. 5.8 - What does a Random objects Next method return?Ch. 5.8 - What does a Random objects NextDouble method...Ch. 5.8 - Write code that creates a Random object and then...Ch. 5.8 - Write code that creates a Random object and then...Ch. 5.8 - Prob. 5.39CPCh. 5.8 - What happens if the same seed value is used each...Ch. 5.9 - Prob. 5.41CPCh. 5.9 - Prob. 5.42CPCh. 5 - ListBox controls have an __________ method that...Ch. 5 - A __________ is commonly used to control the...Ch. 5 - A(n) __________ loop tests its condition before...Ch. 5 - The term __________ is used to describe a file...Ch. 5 - The term __________ file is used to describe a...Ch. 5 - A __________ file contains data that has been...Ch. 5 - When you work with a __________ file you access...Ch. 5 - Prob. 8MCCh. 5 - A __________ object is an object that is...Ch. 5 - When a program works with an input file, a special...Ch. 5 - When the user selects a file with the Open dialog...Ch. 5 - The __________ control displays a standard Windows...Ch. 5 - Once you have created a Random object, you can...Ch. 5 - Prob. 14MCCh. 5 - When you run an application, the applications form...Ch. 5 - If the ListBox is empty, the Items.Count property...Ch. 5 - To increment a variable means to increase its...Ch. 5 - When a variable is declared in the initialization...Ch. 5 - The while loop always performs at least one...Ch. 5 - The term read file is used to describe a file that...Ch. 5 - To append data to an existing file, you open it...Ch. 5 - As items are read from the file, the read position...Ch. 5 - The numbers that are generated by the Random class...Ch. 5 - Prob. 10TFCh. 5 - What is contained in the body of a loop?Ch. 5 - Write a programming statement that uses postfix...Ch. 5 - How many iterations will occur if the test...Ch. 5 - What are filename extensions? What do they...Ch. 5 - When an input file is opened, what is its read...Ch. 5 - How can you read all of the items in a file...Ch. 5 - What is a variable that is used to accumulate a...Ch. 5 - By default, the Open dialog box displays the...Ch. 5 - Prob. 9SACh. 5 - Prob. 10SACh. 5 - Write a loop that displays your name 10 times.Ch. 5 - Write a loop that displays all the odd numbers...Ch. 5 - Write a loop that displays every fifth number from...Ch. 5 - Write a code sample that uses a loop to write the...Ch. 5 - Assume that a file named People.txt contains a...Ch. 5 - Distance Calculator If you know a vehicles speed...Ch. 5 - Distance File Modify the Distance Calculator...Ch. 5 - Celsius to Fahrenheit Table Assuming that C is a...Ch. 5 - Prob. 4PPCh. 5 - Pennies for Pay Susan is hired for a job, and her...Ch. 5 - Prob. 6PPCh. 5 - Prob. 7PPCh. 5 - Prob. 8PPCh. 5 - Prob. 9PPCh. 5 - Addition Tutor Create an application that...Ch. 5 - Random Number Guessing Game Create an application...Ch. 5 - Calculating the Factorial of a Number In...Ch. 5 - Random Number File Writer Create an application...Ch. 5 - Random Number File Reader This exercise assumes...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
List six relational operators.
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Why is the study of database technology important?
Database Concepts (7th Edition)
The following algorithm is designed to print the beginning of what is known as the Fibonacci sequence. Identify...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
For each of the following activities, give a PEAS description of the task environment and characterize it in te...
Artificial Intelligence: A Modern Approach
The following statements use conditional expressions. Rewrite each with an if /else statement. A) j = k 90 ? 5...
Starting Out with C++ from Control Structures to Objects (8th 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
- True or FalseAs items are read from the file, the read position moves forward, toward the end of the file.arrow_forwardAssume the file popular_names.txt contains the 400 most popular names given to children born in the United States from the year 2000 through 2009. The file contains 400 lines, with one name per line. Write a Python program that reads the contents of the file into a list. The program should display the following string to prompt the user to enter a name: 'Entet a name: ' The program should then display a message indicating whether the name is among the most popular. If the name is found in the list, the program should display the following message: 'That was a popular name between 2000 and 2009.' If the name is not found in the list, the program should display the following message: 'That was not a popular name between 2000 and 2009.' Look carefully at the samples given. In the first example, the user enters a name that is found in the list. In the second example, the user enters a name that is not found in the list. Carefully notice the wording of the messages and the placement…arrow_forwardscreenshot of input and output import string def readfile(fname):pass#Open the file for reading#Read the contents as one long string#Close the file#Remove the punctuation#Return the lower-case contents def main():filename = "gb.txt"#Use readfile() to get the text#Create an empty list to hold the unique words#Split the text into a list of words (split on whitespace)#For each word in the list of words#If the word is not in the unique word list#Add it (append it to the unique word list)#Print the number of unique words#Print the unique words main()arrow_forward
- A for statement is a loop that iterates across a list of items. As a result, it continues to operate as long as there are items to process. Is this statement true or false?arrow_forward'''create three lists called(letters, Encoded, encryptedLettersNum)'''letters=[]Encoded=[]encryptedLettersNum=[] '''Create a String variables called(EncodedMessage) that will contain messageafter the encryption'''EncodedMessage=''theAlphabetSmall='a' '''create a for loop that add every element intheAlphabetSmall list to the letters list''' for i in range(0,26):letters.append(theAlphabetSmall)theAlphabetSmall=chr(ord(theAlphabetSmall)+1) '''print a question that tell the user to enter the messageand save it in the message variable'''message=input ("Enter your message:\n") '''create a for loop that add every character in the message variableto the letters list and add the index+1 to the encryptionLettersNum list''' for i in range(len (message)):index=letters.index(message[i])encryptedLettersNum.append(index+1) '''create a for loop in for loop that start from pointer +1and end in the last character in the messag varible'''for i in range(len (message)):for j in range(i+1,len (message)):'''…arrow_forward'''create three lists called(letters, Encoded, encryptedLettersNum)''' letters=[] Encoded=[] encryptedLettersNum=[] '''Create a String variables called(EncodedMessage) that will contain message after the encryption''' EncodedMessage='' theAlphabetSmall='a' '''create a for loop that add every element in theAlphabetSmall list to the letters list''' for i in range(0,26): letters.append(theAlphabetSmall) theAlphabetSmall=chr(ord(theAlphabetSmall)+1) '''print a question that tell the user to enter the message and save it in the message variable''' message=input ("Enter your message:\n") '''create a for loop that add every character in the message variable to the letters list and add the index+1 to the encryptionLettersNum list''' for i in range(len (message)): index=letters.index(message[i]) encryptedLettersNum.append(index+1) '''create a for loop in for loop that start from pointer +1 and end in the last character in the messag varible''' for i in range(len…arrow_forward
- # Method: Load levelsList using the data in levelsFile def readLevelsFromFile(self): try: # Set levelsList to an empty list pass # Open the file pass # Use a loop to read through the file line by line pass # This code is inside the loop: # Convert the line to a float and then append it to levelsList pass # Close the file pass except: returnarrow_forwardThis file object method returns a list containing the file’s contents.a. to_listb. getlistc. readlined. readlinesarrow_forwardPlease I really need help with this question it is confusing me a lot I don't understand how should I start, Also can you please attach the TEXT FILE Screenshot. PLEASE! Write a program that allows the user to navigate lines of text in a file. The program should prompt the user for a filename, read the file and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line number range from 1 to the number of lines in the file. If the input is 0, the program quits. Otherwise, the program prints the text associated with that number. You must also run the script and provide a screenshot of the output along with the textfile.arrow_forward
- Given helper function: (Hint: This function is to be used to complete the docstring of the function below)def is_number(value: str) -> bool: """Return True if and only if value represents a decimal number. >>> is_number('csc108') False >>> is_number(' 108 ') True >>> is_number('+3.14159') True """ return value.strip().lstrip('-+').replace('.', '', 1).isnumeric()QUESTION: Complete the docstring using the information provided. def convert_data(data: List[list]) -> None: """Convert each string in data to an int if and only if it represents a whole number, and a float if and only if it represents a number that is not a whole number. >>> d = [['abc', '123', '45.6', 'car', 'Bike']] >>> convert_data(d) >>> d [['abc', 123, 45.6, 'car', 'Bike']] >>> d = [['ab2'], ['-123'], ['BIKES', '3.2'], ['3.0', '+4', '-5.0']] >>> convert_data(d) >>> d…arrow_forwardThe python function file_first_chars takes one parameter, fname, the name of a text file, and returns a string made up of the first character from each line in the file. You may assume there are no blank lines in the file. Hint: Use a for loop to iterate over the lines of the file and accumulate the string of first characters.arrow_forwardFile Operations:Write a complete program that reads integers from a file called numbers.txt, and displays their sum on the screen. Example: If the content of numbers.txt is: 10 20 30 100 The program should print: 160arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
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