Tuesday, March 5, 2019

Dylan Nguyen - Makeup classwork from yesterday 3/5/19

Today, I worked on the classwork from yesterday. I missed yesterday classwork so I am going to make u the working using the time of robot club. I learned to read in a text file and parse  and manipulate the lines of the text file. These are the files I obviously used to finish the 6 challenges.



#challengel
file=open('zimTextFile.txt')
print(file)

#challenge2/3
c=0
file=open('zimTextFile.txt')
for text in file:
    char in file.read()
print(len(char),"lines")

c=0
file=open('zimTextFile.txt')
for text in file:
    c=c+1
print(c,"lines")

#challenge4
xfile=open('zimTextFile.txt')
counterOfLines=0
zim=0
for cheese in xfile:
    counterOfLines=counterOfLines+1
    if not 'Zim' in cheese:
            continue
        cheese = cheese.rstrip()
        zim=zim+1
#       print(cheese)
print(zim,"total Zims")
 # if text, startswith('zim'):
 #      print(text)

#challenge5
xfile=open('zimTextFile.txt')
counterOfLines=0
mail=0
for cheese in xfile:
    counterOfLines=counterOfLines+1
    if not 'email' in cheese:
        continue
    cheese = cheese.rstrip()
    mail=mail+1
print(mail,"total Emails")

#challenges 6

xfile=open('zimTextFile.txt')
counterOfLines=0
mail=0
for cheese in xfile:
    counterOfLines=counterOfLines+1
    if not 'email' in cheese:
        continue
    cheese = cheese,rstrip()
    print(cheese)



http://www.steamclown.org/mechatronics/units/Unit-6-Programming/RaspberryPi-Python/Lesson-13-Files/PythonLab-ReadingFiles.pdf

http://www.steamclown.org/mechatronics/units/Unit-6-Programming/RaspberryPi-Python/Lesson-13-Files/Pythonlearn-07-Files.pdf

No comments:

Post a Comment