Python Practice Creating and Using Functions in Python Practice Functions That's Odd

Blue DiamondXD
Blue DiamondXD
4,865 Points

what shoul i put in between the () it doesent say what to add

create_a_function.py
def is_odd(num):
    if 

2 Answers

Josh Keenan
Josh Keenan
17,379 Points

What you have between the () currently, num, is perfectly fine.

Now you have to figure out if a number is odd, to check if a number is divisible by 2 you need to use the % operator. It checks if there is a remainder, so if there is a remainder we know it is an odd number.

Hope this helps, feel free to ask for help if needed, good luck!

Blue DiamondXD
Blue DiamondXD
4,865 Points

but how do i use the % im kind of connufuss

Josh Keenan
Josh Keenan
17,379 Points

If we wanted to know if a number was divisible by 3, it would look like this:

if num % 3 == 0:

This says, if the number is divisible by 3, then we can do whatever.

You want to check if it is NOT divisible by 2

Blue DiamondXD
Blue DiamondXD
4,865 Points

ohhh i get it now thanks i migth have a idea now

Josh Keenan
Josh Keenan
17,379 Points

You got this, I believe in you!

Blue DiamondXD
Blue DiamondXD
4,865 Points

by the way should i make a variable for num???

Josh Keenan
Josh Keenan
17,379 Points

num is already like a variable itself, you don't ever need to make a variable for a parameter, you can just use the parameter in the same way.

Blue DiamondXD
Blue DiamondXD
4,865 Points

def id_odd(num): if num % 4 == 2: answer = True elif num % 5 == 1: answer = False return answer

result = int(input("fagagaaga"))

i try is but it doesent work

Josh Keenan
Josh Keenan
17,379 Points

You were close:

def is_odd(num):
    if num % 2 != 0:
        return True
Blue DiamondXD
Blue DiamondXD
4,865 Points

thank you for you time you a great person thank you for you time

Josh Keenan
Josh Keenan
17,379 Points

!= is the not equal to operator