Counting Down

In an attempt to demonstrate division to a primary class, you use the following python program to calculate 1 ÷ 0.1 1 \div 0.1 .

1
2
3
4
5
6
7
8
9
dividend = 1
divisor = 0.1
quotient = 0

while divisor != 0:
   dividend -= divisor
   quotient += 1

print quotient

What does the program output?


Inspired by Currency Calculations

10 No output, due to an error 9, due to an off-by-one error No output, the program never halts 11, due to an off-by-one error

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...