Question
python

Create a program to open a text file for reading, find the maximum number in the file, determine if that maximum number is ev
: تم في import math 4 import os 5 • import random import re 7 import sys def readFileFunction(): rooi # Place your code here
0 0
Add a comment Improve this question Transcribed image text
Answer #1

def readFileFunction():
   f=open("C:/Users/Gaurav/Documents/input.txt","r")
   line=f.readline()
   list=[]
   while line:
       list.append(int(line))
       line=f.readline()
   f.close()
   max=list[0]
   for i in range(1,len(list)):
       if list[i]>max:
           max=list[i]
  
  
   f=open("C:/Users/Gaurav/Documents/output.txt","w")
   if max%2==0:
       f.write("Yes")
   else:
       f.write(str(max))


Screenshot:-

def readFileFunction(): f-open(C:/Users/Gaurav/Documents/input.txt,r) line=f.readline) list=[] while line: list.append(in

input - Notepad Edit Format View File Help mon

output - Notepad File Edit Format View Yes Help

Add a comment
Know the answer?
Add Answer to:
python Create a program to open a text file for reading, find the maximum number in...
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
  • Using C++, and <iostream> if possible, ​ Write a program that can compress a text file...

    Using C++, and <iostream> if possible, ​ Write a program that can compress a text file consisting of English language alphabet A-zl using run-length encoding scheme. (Weight 50%) Run-Length Encoding The key idea is to replace the repeating character by itself and the number of times that it has been repeated. Consider the following string HELLO WORLD This can be re-written as HEL20 WORLD Notice that since LL was repeated, it was repeated by L2. 2 here indicates that letter...

  • JAVA: Make a single-threaded program that counts words in a text file and prints the result...

    JAVA: Make a single-threaded program that counts words in a text file and prints the result in an output.txt example: if a input.txt file has a string "There was an apple, which was in there.", the output.txt should have: there: 2 was : 2 an : 1 apple : 1 which :1 in : 1

  • Write a C++ program that open the text file “numbers.txt”. (the numbers.txt looks like: ' 1....

    Write a C++ program that open the text file “numbers.txt”. (the numbers.txt looks like: ' 1. 6 8 ') Have a “output.txt” If summation is less than 5, your code must write last number inside “numbers.txt” in “output.txt”, else it must write the number in between in “output.txt” (use conditional statement for comparison)

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • Write a C++ program that reads text from a file and encrypts the file by adding...

    Write a C++ program that reads text from a file and encrypts the file by adding 6 to the ASCII value of each character. See section 5.11 in Starting out with C++ for information on reading and writing to text files. Your program should: 1. Read the provided plain.txt file one line at a time. Because this file has spaces, use getline (see section 3.8). 2. Change each character of the string by adding 6 to it. 3. Write the...

  • In Python Please! 16.42 Lab 13B: Palindromes with Files Overview This is a demonstration of reading...

    In Python Please! 16.42 Lab 13B: Palindromes with Files Overview This is a demonstration of reading and writing files. Objectives Be able to read from an input file, perform string manipulation on each line of the file, and write to an output file. Provided input file: A single input file named myinput.txt is provided that contains a few lines of text. bob sees over the moon never odd or even statistics dr awkward Provided output file: A single output file...

  • PYTHON The text file motifFinding.txt contains two strings of DNA code, separated by a new-line character....

    PYTHON The text file motifFinding.txt contains two strings of DNA code, separated by a new-line character. Write a program that opens the file, and stores its contents into two strings, s and t, respectively.   Write code that will find all instances of the string t within the string s. At the end, your program should output the number of times the sub-string t occurs within s, along with the index of the starting position of each occurrence of t within...

  • In Python Provide me with your code file, output file and the text file Create a...

    In Python Provide me with your code file, output file and the text file Create a file having different integers than the first one. Save it as numbers1. txt . Write a program that reads all the number and calculates their average. Important: The two files that you are creating will contain different numbers.

  • 16.43 Lab 13C: Palindromes with Files and Functions Overview This is a demonstration of reading and...

    16.43 Lab 13C: Palindromes with Files and Functions Overview This is a demonstration of reading and writing files, along with using user-defined functions. Objectives Be able to read from an input file, perform string manipulation on each line of the file within a function, and write to an output file. Provided input file: A single input file named myinput.txt is provided that contains a few lines of text. bob sees over the moon never odd or even statistics dr awkward...

  • JAVA Code: Complete the program that reads from a text file and counts the occurrence of...

    JAVA Code: Complete the program that reads from a text file and counts the occurrence of each letter of the English alphabet. The given code already opens a specified text file and reads in the text one line at a time to a temporary String. Your task is to go through that String and count the occurrence of the letters and then print out the final tally of each letter (i.e., how many 'a's?, how many 'b's?, etc.) You can...

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