No modules can be imported. 1. Write a program called diff.py that asks the user
ID: 662459 • Letter: N
Question
No modules can be imported.
1. Write a program called diff.py that asks the user for two files and displays the differences between the characters in each file. 1. Your program should ask the user for the path to two different files 2. For every character that is in the same position in each file but is different between the two files your program should display the index of those characters (starting from 0) as well as the value of those two characters. 3. If one file is longer than the other your program should report the index of each of the characters as well as the fact that it could not find a matching character
4. Examples:
1. Assume ex1.txt contains the contents:
Explanation / Answer
def getChoice(menu):
print menu
choice = int( raw_input("Select a choice(1-4): ") )
return choice
def path(diplays):
name = raw_input("path to two different files: ")
myFile = os.path.dirname(os.path.realpath(__file__))
path[diplays] = myFile
def main():
theMenu = '''
1) Add Entry
2) Remove Entry
3) Find Entry
4) Quit and save
'''
theBook = {}
readBook(theBook)
choice = getChoice(theMenu)
while choice != 4:
if choice == 1:
path(display)
elif choice == 2:
different_between_two_file(display)
elif choice == 3:
index(display)
else: print "Invalid choice, try again"
choice = getChoice(theMenu)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.