Advertisement
Stosswalkinator

File output of multiples

Jul 15th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. # Define the values
  2. x = 3
  3. y = 5
  4.  
  5. # Create a file
  6. f = open('C:\Users\user_name\My Documents\python.txt', 'w')
  7. n = x
  8. while n < 1000: # Until the multiples reach 1000, this keeps going
  9.     f.write(n) # Writes each result to the text file
  10.     n += x
  11.     f.write("End of 3") # This signifies the end of the multiples of 3 in the file
  12. n = y
  13. while n < 1000: # Same thing as above
  14.     f.write(n)
  15.     n += y
  16. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement