Skip to content

Added try..except blocks to prevent any errors during execution as well as added commented docs to the script file 'Odd or Even.py' #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 37 additions & 5 deletions Odd Or Even.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
a = int(input("Enter Any Number = "))
"""
Odd or Even

if a%2 == 0:
print("EVEN")
else:
print("ODD")
A python script to check wheter the user entered number is odd or even number.

Author : Anirudha Taliyan (https://github.com/anirudhataliyan/)
Created on :

Last modified by : Rishav Das (https://github.com/rdofficial/)
Last modified on : May 12, 2021

Changes made in last modification :
1. Filled the entire code inside try..except block in order to prevent any errors that may occur during the execution of the script.
2. Added commented docs as well as comment lines between the codes.

Authors contributed to this script (Add your name below if you have contributed) :
1. Anirudha Taliyan (github:https://github.com/anirudhataliyan/, email:[email protected])
2. Rishav Das (github:https://github.com/rdofficial/, email:[email protected])
"""

try:
# Asking the user to enter the number
number = int(input('Enter a number : '))

if (number % 2) == 0:
# If the user entered number is even

print(f'\n[ The specified number ({number}) is even ]')
else:
# If the user entered number is odd

print(f'\n[ The specified number ({number}) is odd ]')
input('Press enter key to continue...')
except Exception as e:
# If there are any errors encountered during the execution, then we display the error message on the console screen

input(f'\n[ Error : {e} ]\nPress enter key to continue...')
exit()