# Demo entry 3549079

**notes**

Submitted by **div and mod**
on Jan 21, 2016 at 12:36

Language: Python 3. Code size: 1.0 kB.

#07/01/2016 #rachel mckie # div and mod #playing with div and mod #MOD = remainder after integer division #DIV= integer number of times 1 integer divides into another numvber #10 mod 3 = 1 print ("10 MOD 3 = ",10%3) # MOD uses % #10 div 3 = 3 print ("10 DIV 3 = ",10 // 3) #DIV uses // # a short number to test whether a user has entered an odd or even number: user_num = input (" enter a number?: ") #get user input = string user_num= int (user_num) #cast to an integer #test for odd or even if (user_num % 2 == 0 ) : #got odd or even number print ("%i is EVEN ...") else: #otherwise must be odd print ("%i is ODD ...") #now test for integer or float user_num = input (" enter a number?: ") #get user input = string user_num = float (user_num) # cast to decimal #test for integer if (user_num % 1 == 0 ) : #then you have an integer print ("%i is an integer ...") else: #must be a float print ("%.2f is a float ...") print ("***finished***")

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.