Skip to main content

Posts

Showing posts with the label Enter the number from the user and depending on whether the number is even or odd

Enter the number from the user and depending on whether the number is even or odd, print out an appropriate message to the user.

  Enter the number from the user and depending on whether the number is even or odd, print out an appropriate message to the user.   Sample Solution :- Python Code: num = int ( input ( "Enter a number: " ) ) mod = num % 2 if mod > 0 : print ( "This is an odd number." ) else : print ( "This is an even number." ) Sample Output: Enter a number: 5 This is an odd number.