##L7 PROBLEM 7 (5 points possible) #Consider the following function definition: def rem(x, a): """ x: a non-negative integer argument a: a positive integer argument returns: integer, the remainder when x is divided by a. """ if x == a: return 0 elif x < a: return x else: #print x - a return rem(x-a, a) #print rem(2, 5), 'Should be 2', 2%5 #print rem(5, 5), 'Should be 0', 5%5 print rem(7, 5), 'Should be ', 7%5
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