Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Odd or Even Program

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Odd or Even Program. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

A Tavant utility needs to classify an integer before applying a processing rule. Write a function that determines whether the given number is odd or even.

Formal Specification

Implement classify_parity(number), which accepts one integer and returns the string "even" if the number is divisible by 2, or "odd" otherwise. Zero is considered even, and the function must support positive, zero, and negative integers.

Constraints

  • -10^9 <= number <= 10^9
  • number is an integer
  • Return exactly "even" or "odd"

Function Signature

def classify_parity(number):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output