Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Else if
#1
I don't understand what the (answer), (4), (5), or (6) they want.

def greater_less_equal_5(answer):
    if 2 + 2:
        return 1
    elif 6 - 1:          
        return -1
    else:
        return 0
        
print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)
On line 2, fill in the if statement to check if answer is greater than 5.
On line 4, fill in the elif so that the function outputs -1 if answer is less than 5

Those are the instructions but I am confused because I don't know if they want line 2 to print out 4 what conditional I need to use to get the code to return -1. I know the greater, less than equal to permutations but do i need the logical operators in if/elif code?
Reply


Messages In This Thread
Else if - by JohnnyCanuck - Jul-20-2017, 06:45 PM
RE: Else if - by ichabod801 - Jul-20-2017, 07:25 PM
RE: Else if - by JohnnyCanuck - Jul-20-2017, 07:43 PM
RE: Else if - by cygnus_X1 - Jul-20-2017, 07:53 PM
RE: Else if - by JohnnyCanuck - Jul-20-2017, 08:17 PM
RE: Else if - by cygnus_X1 - Jul-20-2017, 08:32 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020