--- a/conditionals/questions.rst Wed Nov 10 12:32:16 2010 +0530
+++ b/conditionals/questions.rst Wed Nov 10 13:25:46 2010 +0530
@@ -75,6 +75,27 @@
.. A minimum of 2 questions here (along with answers)
-1.
+1. Given a number, say, n. If it is divisible by 10, print the
+ quotient when divided by 10, otherwise if it is divisible by 5,
+ print the corresponding quotient, otherwise, print the number.
+
+
+ Answer::
-2.
+ if n%10==0:
+ print n/10
+ elif n%5==0:
+ print n/5
+ else:
+ print n
+
+2. Given a number, say, n. Write an if block to multiply n by three
+ and add 1, if it is odd, otherwise halve it.
+
+ Answer::
+
+ if n % 2:
+ n = n*3+1
+ else:
+ n /= 2
+