|
|
@@ -0,0 +1,39 @@
|
|
|
+import os
|
|
|
+
|
|
|
+def divideableBy3(number):
|
|
|
+ "Check if passed number is divideable by three"
|
|
|
+ # Use modulo to check if number is divideable by three
|
|
|
+ divideable = (number % 3 == 0)
|
|
|
+
|
|
|
+ # Return bool variable
|
|
|
+ return divideable
|
|
|
+
|
|
|
+def divideableBy2(number):
|
|
|
+ "Check if passed number is divideable by two"
|
|
|
+ # Use modulo to check if number is divideable by two
|
|
|
+ divideable = (number % 2 == 0)
|
|
|
+
|
|
|
+ # Return bool variable
|
|
|
+ return divideable
|
|
|
+
|
|
|
+# Clear screen
|
|
|
+os.system("clear") # Mac or Linux
|
|
|
+# os.system("cls") # Windows
|
|
|
+
|
|
|
+# Prompt for input from user
|
|
|
+number = int(input("Input a number: "))
|
|
|
+
|
|
|
+# Call function divideableBy2 and store return in variable test2
|
|
|
+test2 = divideableBy2(number)
|
|
|
+# Call function divideableBy3 and store return in variable test23
|
|
|
+test3 = divideableBy3(number)
|
|
|
+
|
|
|
+# Test results from function calls, and base output on the results
|
|
|
+if test2 and test3:
|
|
|
+ print("{} is divideable by 2 and 3".format(number))
|
|
|
+elif test2:
|
|
|
+ print("{} is divideable by 2".format(number))
|
|
|
+elif test3:
|
|
|
+ print("{} is divideable by 3".format(number))
|
|
|
+else:
|
|
|
+ print("{} is not divideable by 2 or 3".format(number))
|