samedi 12 novembre 2022

returning even or odd number in function python

I'm super stuck on this problem and dont know how to proceed with the code that I have :/ The instructions dont say to use an if / else statement when checking the value, but just to "determine" if it even or odd

here's the problem:

  1. Write a function called main that generates 20 random numbers between 1 and 300.

  2. Write a value returning function named isEven that accepts a random number as an argument and determines if the random number is even or odd.

3.Call the isEven function in the main function

4.The main function should display if the random number generated is even or odd.



def main():
    import random
    a = random.sample(range(1,300),20)

def isEven(a):
  
    

       



Aucun commentaire:

Enregistrer un commentaire