Question

Please write this code in python programming and provide a screen short of the code. Reading:...

Please write this code in python programming and provide a screen short of the code.

Reading: P4E 7; Tut 7.2, 7.2.1

Upload an original Python script that satisfies the following criteria:

  • It has at least two functions
    • Function 1:
      • This function has one parameter, a string containing the path to an existing text file that will be read by your function
      • Using a with statement, the function opens the file indicated by the parameter for reading
      • The function counts the number of lines in the file that contain the letter "j" (a for loop is your friend)
      • The function returns the final count of lines containing "j"
    • Function 2:
      • This function has two parameters:
        • a string containing the path where a text file will be written by your function (if a file already exists at that location, it will be overwritten)
        • an integer containing a count that will be written to the file
      • Using a with statement, the function opens the file indicated by the first parameter for writing
      • The function writes the count in the second parameter to the file
      • The function returns None implicitly (in other words, it has no return statement)
  • It has an if __name__ == '__main__': statement that does the following:
    • Calls the first function, passing a filename as an argument, and captures the return value in a variable
    • Calls the second function, passing another filename and the result of the first function as arguments
  • The script adheres to the style guide; this includes, among other things, having a script docstring and function docstrings.
0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Please write this code in python programming and provide a screen short of the code. Reading:...
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 Write the function getSpamLines(filename) that read the filename text file and look for lines of the form &#...

    python Write the function getSpamLines(filename) that read the filename text file and look for lines of the form 'SPAM-Confidence: float number'. When you encounter a line that starts with "SPAM-Confidence:" extract the floating-point number on the line. The function returns the count of the lines where the confidence value is greater than 0.8. For example, if 'spam.txt' contains the following lines along with normal text getSpamLines('spam.txt') returns 2. SPAM-Confidence: 0.8945 Mary had a little lamb. SPAM-Confidence: 0.8275 SPAM-Confidence: 0.7507 The...

  • I am having a little trouble with my Python3 code today, I am not sure what...

    I am having a little trouble with my Python3 code today, I am not sure what I am doing wrong. Here are the instructions: and here is my code: update: I have seen I did not close x in sumFile and I am still only getting a 2/10 on the grader. any help appreciated. Lab-8 For today's lab you going to write six functions. Each function will perform reading and/or write to a file Note: In zybooks much like on...

  • Please answer this question using python programming only and provide a screen short for this code....

    Please answer this question using python programming only and provide a screen short for this code. Homework 3 - Multiples not less than a number Question 1 (out of 3) This homework is a SOLO assignment. While generally I encourage you to help one another to learn the material, you may only submit code that you have composed and that you understand. Use this template to write a Python 3 program that calculates the nearest multiple of a number that...

  • Sample program run - Needs to be coded in python -Enter the text that you want to search for, Or DONE when finished: val...

    Sample program run - Needs to be coded in python -Enter the text that you want to search for, Or DONE when finished: valiant paris The valiant Paris seeks for his love. -Enter the text that you want to search for, or DONE when finished: Romeo and Juliet Enter Romeo and Juliet aloft, at the WIndow -- Enter the text that you want to search for, DONE when finished: DONE   # copy the following two lines into any # program...

  • python program please Write a function called backwards which takes two parameters. The first is a...

    python program please Write a function called backwards which takes two parameters. The first is a file object that has already been opened in read mode called essayfile. The second is called filename, which contains the filename for the output file that will need to be properly opened and closed in your function. The function should read from already opened file object line by line. Each line in the file should have the words on the line reversed. For example,...

  • PYTHON 3.6 (Short and Simple Codes Please) Write a recursive function, reverse, that accepts a parameter...

    PYTHON 3.6 (Short and Simple Codes Please) Write a recursive function, reverse, that accepts a parameter containing a string value and returns the original string in reverse. For example, calling reverse('goodbye') would return 'eybdoog'. Reversing a string involves: No action if the string is empty or only has 1 character Concatenating the last character with the result of reversing the string consisting of the second through next-to-last character, followed by the first character

  • PYTHON 1- Write a function that receives a string value as a parameter, converts its first...

    PYTHON 1- Write a function that receives a string value as a parameter, converts its first character to uppercase and returns the first character. 2- Test your function by writing a main, which calls your function and prints its return value. 3- Save your program in a file called firstChar.py and use the following link to submit your file.  

  • write a function: Names(path): that reads from a file at location path and returns a dictionary...

    write a function: Names(path): that reads from a file at location path and returns a dictionary mapping from column names to lists containing the data in those columns. The format of the file is a csv file. The first line is a comma separated set of string names for the columns contained in the file. The function will accumulate a dictionary mapping from year to the list of years, from name to the list of names (in the same order),...

  • Task 1: Reading files Part A - Read a word Implement a function word from.file(file) that...

    Task 1: Reading files Part A - Read a word Implement a function word from.file(file) that takes a file as input and returns the first word in the file. Hint: the string methods split and strip will be useful. Example: calling word from file('files/task1A.txt') returns 'Once'. Part B - Read a table Implement a function nested int.list from file(file) that takes a file containing lines of integers that are separated by commas as input and returns the file contents formatted...

  • need this in c programming and you can edit the code below. also give me screenshot...

    need this in c programming and you can edit the code below. also give me screenshot of the output #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #define LINE_SIZE 1024 void my_error(char *s) { fprintf(stderr, "Error: %s\n", s); perror("errno"); exit(-1); } // This funciton prints lines (in a file) that contain string s. // assume all lines has at most (LINE_SIZE - 2) ASCII characters. // // Functions that may be called in this function: // fopen(), fclose(), fgets(), fputs(),...

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
ADVERTISEMENT