Respuesta :
Python Code with Explanation:
# import random module to use randint function
import random
# generate a random number between 300 to 400
num = random.randint(300,400)
# check whether the generated random number is divisible by 2 then it is even
if num % 2==0:
print("The generated number is even: ", num)
# if it is not even number then it must be an odd number
else:
print("The generated number is odd: ", num)
Output Results:
The generated number is odd: 303
The generated number is even: 386


Answer:
import random
x = random.randrange(300, 400)
if x%2 == 0:
print(x, "is an even number")
else:
print(x, "is an odd number")
Explanation:
The code is written in python
The question ask us to generate a random number and confirm if the generated number is an even number or odd number.
import random
This line of code is use to import the function random . The function is use to generate a random number.
x = random.randrange(300, 400)
The code generate a random number between the range 300 and 400.
if x%2 == 0:
If x(x is the generated random number) divided by 2 has no remainder the value is an even number.
print(x, "is an even number")
The code means print the generated number is an even number if the number is even.
else:
otherwise
print(x, "is an odd number")
The code means print the generated number is an odd number if the number is an odd number.