Thanks so much. I got thru the rest successfully. This was my last issue out of the 20 + problems.
Make sure you have read Chapter 6 from the Think Python book.
Write a boolean function that receives a number as a parameter and checks if it's even or odd, and display an appropropriate method.
Here is the expected output:
Sample run 1:
Enter a number: 23 Your number is odd!
Sample run 2:
Enter a number: 44 Your number is even!
# check if the input number is odd or even
# a number is even if division by 2 gives a reminder of 0
# if the remainder is 1, it is an odd number
number = int(input("Enter a number: "))
if (number % 2) == 0:
return Your number is even!
else:
return Your number is odd!
File "<ipython-input-4-3a7b155c37c3>", line 7 return Your number is even! ^ SyntaxError: invalid syntax
Comments: Again, this code needs to be within a function.
Make sure you have read Chapter 6 from the Think Python book.
Write a boolean function that receives a number as a parameter and checks if it's even or odd, and display an appropropriate method.
Here is the expected output:
Sample run 1:
Enter a number: 23 Your number is odd!
Sample run 2:
Enter a number: 44 Your number is even!
# check if the input number is odd or even
# a number is even if division by 2 gives a reminder of 0
# if the remainder is 1, it is an odd number
number = int(input("Enter a number: "))
if (number % 2) == 0:
return Your number is even!
else:
return Your number is odd!
File "<ipython-input-4-3a7b155c37c3>", line 7 return Your number is even! ^ SyntaxError: invalid syntax
Comments: Again, this code needs to be within a function.
buran write Jun-18-2021, 05:50 PM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.