Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a.txt file with the following contents: HelloWorldHelloWorldHelloWorldHel

ID: 3581698 • Letter: C

Question

Create a.txt file with the following contents: HelloWorldHelloWorldHelloWorldHelloWorld GoodnightMoonGoodnightMoonGoodnightMoon HelloWorldHelloWorldHelloWorldHelloWorld GoodnightMoonGoodnightMoonGoodnightMoon Write a program that accepts a file name is an input, opens said file, and processes input. You will write the results to an output file. For processing, count the number of upper case letters on each line and write that number to the output file along with the line number that is associated with that number, i.e.: Line #2 has 6 uppercase letters.

Explanation / Answer

def countword(line):
    word = 0
    for i in xrange(0,len(line)):
        if line[i]==',':
            word = word + 1
    if word>= 0 and len(line) > 0:
        word = word + 1
    return word

inputfile = raw_input("Enter the input filename: ")
outputfile = raw_input("Enter the output filename: ")
count = 0

fout = open(outputfile, 'w')
print "The output has been printed to", outputfile

with open(inputfile) as fin:
   for line in fin:
    result = " words = re.findall(r'w+', fin) + " "
    fout.write(result)
    count = count + countNum(line)
    linenumber = linenumber + 1
result = "The file " + str(inputfile) + " contained " + str(count) + " uppercase letter "
fout.write(result)

fin.close()
fout.close()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote