Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dc8778e

Browse files
committed
revised question list.
1 parent e9d117b commit dc8778e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎100+ Python challenging programming exercises.txt‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,23 @@ def checkValue(n):
838838
checkValue(7)
839839

840840

841+
#----------------------------------------#
842+
Question:
843+
Define a function that can accept an integer number as input and print the "It is an even number" if the number is even, otherwise print "It is an odd number".
844+
845+
Hints:
846+
847+
Use % operator to check if a number is even or odd.
848+
849+
Solution
850+
def checkValue(n):
851+
if n%2 == 0:
852+
print "It is an even number"
853+
else:
854+
print "It is an odd number"
855+
856+
857+
checkValue(7)
841858

842859

843860

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /