Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Complete the following tasks and submit a Pull Request

<details open>
<summary><h3>1. Add your details: </h3></summary>
<summary>
<h3>1. Add your details: </h3>
</summary>
<ul>
<li> Name: </li>
<li> Roll Number: </li>
<li> Branch: </li>
<li> Name: Comet Assistant </li>
<li> Roll Number: N/A </li>
<li> Branch: Computer Science </li>
</ul>
</details>

<details>
<summary><h3> 2. Implement a program to check if a number is even or odd. </h3></summary>
<summary>
<h3> 2. Implement a program to check if a number is even or odd. </h3>
</summary>
<ul>
<li> Create a new file in the repository and add your code. </li>
<li> Use any programming language of your choice. </li>
Expand Down
22 changes: 22 additions & 0 deletions check_even_odd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Program to check if a number is even or odd

def check_even_odd(number):
"""
Check if a number is even or odd.

Args:
number (int): The number to check

Returns:
str: 'even' if the number is even, 'odd' if the number is odd
"""
if number % 2 == 0:
return "even"
else:
return "odd"

if __name__ == "__main__":
# Test the function
test_number = int(input("Enter a number: "))
result = check_even_odd(test_number)
print(f"The number {test_number} is {result}.")