Saturday 15 January 2022

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. 

 

No comments:

Post a Comment

The Future of Web Development: Why Next.js is Going Viral

  Are you ready to level up your web development game? Look no further than Next.js, the latest sensation in the world of web development th...