Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 18th, 2012  |  syntax: None  |  size: 0.42 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # CS Summer 2012
  2. # Andrew Slaughter
  3. # July 18, 2012
  4.  
  5. import sys
  6.  
  7. from scanner import *
  8.  
  9. def main():
  10.     s = Scanner(sys.argv[1])
  11.     x = eval(s.readtoken())
  12.     y = s.readtoken()
  13.     z = eval(s.readtoken())
  14.  
  15.     if y == '+':
  16.         print(x + z)
  17.  
  18.     elif y == '-':
  19.         print(x - z)
  20.  
  21.     elif y == '/':
  22.         print(x / z)
  23.  
  24. "calc.py" 32L, 446C                                           1,1           Top