conditionals/script.rst
changeset 438 4523b2048663
parent 437 0840aa06d2e6
--- a/conditionals/script.rst	Wed Nov 10 12:32:16 2010 +0530
+++ b/conditionals/script.rst	Wed Nov 10 13:25:46 2010 +0530
@@ -126,10 +126,19 @@
 
 Following is an exercise that you must do. 
 
-%% %% 
+%% %% Given a number, num. Write an if else block to print num, as is,
+      if it is divisible by 10, else print 10 * num.                  
 
 Please, pause the video here. Do the exercise and then continue. 
 
+:: 
+
+  if num%10 == 0:
+      print num
+  else:
+      print 10*num
+
+
 In addition to these conditional statements, Python provides a very
 convenient ternary conditional operator. Let us take the following
 example where we read the marks data from a data file which is
@@ -155,10 +164,15 @@
 
 Following is an exercise that you must do. 
 
-%% %%     
+%% %% Given a number, num. Write a ternary operator to print num, as is,
+      if it is divisible by 10, else print 10 * num. 
 
 Please, pause the video here. Do the exercise and then continue. 
 
+:: 
+
+   print num if num%10 == 0 else 10*num
+
 Moving on, there are certain situations where we will have no
 operations or statements within a block of code. For example, we have
 a code where we are waiting for the keyboard input. If the user enters