Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv
- #from os.path import exists
- script,arg1,arg2 = argv
- #multiplies
- def multi(a,b):
- return a*b
- #reads a file, turns to integer, then closes.
- def read(a):
- f1 = open(a)
- c = int(f1.readline())
- f1.close()
- return c
- #Turns b into a string, then write to a, then closes
- def write(a,b):
- c = str(b)
- f1 = open(a,'w')
- f1.write(c)
- f1.close()
- print '''We're going to take some numbers,
- write them to some files,
- then read those files,
- then multiply those numbers,
- then write to another file.\n'''
- num1 = int(raw_input('First number: '))
- num2 = int(raw_input('Second number: '))
- write(arg1,num1)
- write(arg2,num2)
- print 'Now let\'s open those files and multiply the numbers together then save to a new file'
- new_f = raw_input('New file name?: ')
- ans = multi(read(arg1),read(arg2))
- write(new_f,ans)
- #retrives answer
- print read(new_f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement