# How does division work in Python? def function_being_tested(a, b): return a/b def test(): test_cases = [ ((0, .5), 0), ((0, 1), 0), ((6, 2), 3), ((7, 2), 3), ((7.0, 2.0), 3.5), ] passes = 0 for (args, expected_result) in test_cases: result = function_being_tested(*args) if result != expected_result: print "Failed when input was: ", args, ". Expected: ", expected_result, " Got: ", result else: passes = passes + 1 print passes, " out of ", len(test_cases), " test cases passed." test()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question