Skip to content
Snippets Groups Projects
fragment.py 341 B
Newer Older
  • Learn to ignore specific revisions
  • tuhe's avatar
    tuhe committed
    from cpp_course.fractions import Fraction, from_string
    
    f1 = Fraction(1, 2)  # Represents 1/2  
    f2 = Fraction(3, 5)  # Represents 3/5
    print(f"Result of {f1} + {f2} is", f1 + f2)
    
    # Now do some compound tests:
    s = " 1 / 4 * 1 / 2"
    print("Result of", s, "is", from_string(s))
    s = "5 / 2 div 10 / 3"
    print("Result of", s, "is", from_string(s))