Question

USING PYTHON!!!! Follow the instructions below: 1. Open a file and write the following to a...

USING PYTHON!!!!

Follow the instructions below:

1. Open a file and write the following to a file: Your Name INSS 250 Final Each should be on a new line.

2. With the file open, take input from a user and append it to the file. It can be any input but must be at least 10 words. I suggest do it in a loop.

3. Now as we did in class, use the file as input to count the number of letters in the file and print out a summary.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the code:

f=open("demo.txt",'w')
f.write("alexa\nINSS\n250\nFinal") #write in differnt line
word="kk"   #initialise with random word
count=0
while word!="$":
   word=input()
   if(word=="$"):
       break;
   f.write(word)   #write user entered word in the file
   f.write("\n")
   count+=1
   if(count>10):      #when words are more than 10 then
       print("you can enter $ to stop")
   pass
f=open("demo.txt",'r')
strr=f.read()
count=0
for i in strr:   #this loop will read every character
   if i is not "\n":
       count+=1;
print("no of characters in the file are:",count)

here is the ss of the program:

here is the ss of the output

I hope this will help you so please give positive ratings :)))

Add a comment
Know the answer?
Add Answer to:
USING PYTHON!!!! Follow the instructions below: 1. Open a file and write the following to a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Error: Writing a program to complete the following: Prompt the user for the name of...

    Python Error: Writing a program to complete the following: Prompt the user for the name of an input file. Open that file for input. (reading) Read the file using a "for line in a file" loop For each line,  o print the line and compute and print the average word length for that line. Close the input file Sample output: MY CODE IS WRONG AND NEED HELP CORRECTING IT!!! ------------------------------------------------------------------------------------------------------------------------ DESIRED OUTPUT: Enter input file name: Seasons.txt Thirty days hath September...

  • Write robust python code that take from the user the name of file to open. Then,...

    Write robust python code that take from the user the name of file to open. Then, take name from the user to search inside the file then display its phone number if found

  • I cant get this python program to read all the unique words in a file. It...

    I cant get this python program to read all the unique words in a file. It can only read the number of the unique words in a line. import re import string from collections import Counter # opens user inputted filename ".txt" and (w+) makes new and writes def main(): textname = input("Enter the file to search: ") fh = open(textname, 'r', encoding='utf-8' ) linecount = 0 wordcount = 0 count = {} print("Sumary of the", fh) for line in...

  • Write a Python program to read lines of text from a file. For each word (i.e,...

    Write a Python program to read lines of text from a file. For each word (i.e, a group of characters separated by one or more whitespace characters), keep track of how many times that word appears in the file. In the end, print out the top twenty counts and the corresponding words for each count. Print each value and the corresponding words, in alphabetical order, on one line. Print this in reverse sorted order by word count. You can assume...

  • Write a PYTHON program that asks the user for the name of the file. The program...

    Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...

  • IN PYTHON 3: Write a Python program to read the attached text file containing words, count...

    IN PYTHON 3: Write a Python program to read the attached text file containing words, count the occurrence of each unique word and store the words in alphabetical order in a text file listing the word and the total count of that word. You cannot use any advanced features such as dictionaries. The program requires user input to determine the name of the file. (example of the text file that needs to be read = for a brief moment I...

  • Your Python program should perform the following three tasks: 1. After getting a word of input...

    Your Python program should perform the following three tasks: 1. After getting a word of input from the user (i.e., any string), your program should use a while (or for) loop to print out each of the letters of the word. Just remember that strings in Python start with element 0! 2. Your program should then use another loop to print out each of the letters of the (same) word in reverse order! 3. Ask the user for a letter...

  • In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as...

    In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as keys and an array for key containing a list of values (words from file of respective size) associated with those keys I am reading from a file of strings, where I am only interested with words of length 4, 5, and 6 to compute my program reading the text file line by line: At first, I have an empty dictionary then to that I...

  • I need python help .. I need to know if a user were to input 3...

    I need python help .. I need to know if a user were to input 3 commands to a program and run it such as specify: Usage: ./filemaker INPUTCOMMANDFILE OUTPUTFILE RECORDCOUNT (./filemaker is the program)( (INPUTCOOMANDFUILE= a text file that contains key words that need to be searched through then decided what to do ) (RECORDCOUNT= number) Given an input file that contains the following: That specifies the text, then the output, and the number of times to be repeated...

  • IN PYTHON Write the script test3.py that creates and populates a list of OnlineStudent objects. It inputs a requested s...

    IN PYTHON Write the script test3.py that creates and populates a list of OnlineStudent objects. It inputs a requested student, then prints the fields for that student, and also the username of each student in the student's study group. See the pseudocode in Item 3 below. Use the new type of for loop that you can use for reading from a file: # Instead of writing a loop like this fin = open("input-file", "r") line = fin.readline( ) while line...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT