Problems with "the big IF"


#1

Hello, it looks like my code does not work:
n = raw_input("Insert a number")
def the_flying_circus():
if (n%2 == 0):
print "The number is even"
elif (n%2 == 0) and (n != 4):
print "The number is even and different from 4"
else:
print "The number is odd"

return True


#2

You need to define what your functions takes in, also don't forget to call you function, it should look like this:

def the_flying_circus(n):  #You forgot to define your function input
    if (n % 2 == 0):
        print "The number is even"
    elif (n % 2 == 0) and (n != 4):
        print "The number is even and different from 4" 
    else:
        print "The number is odd"
        return True

n = raw_input("Insert a number")
the_flying_circus(n)                                # You forgot to call your function

#3

If it helped or not, please let something know, if solved, please click "solved" :smile: , Happy coding!


#4

no does not work, anyway i've changed the code a bit in order to pass the gate ^_-


#5

haha i passed the exercise not on purpose :stuck_out_tongue:


#6

sonny, so i did
def the_flying_circus():
ans = raw_input("what's your name?")
if ans == "Carlo" or ans == "carlo":
print "ciao carlo, welcome back!"
elif ans == "Roberto" or ans == "roberto":
print "ciao roberto, welcome back!"
else:
print"You've typed "+ans+": Wrong name, insert another name!"
return True

the_flying_circus()


#7

hi it was almosy good !Anyways thanks for the solution.Have a great day!


#8

The code above did not work because without adding int or eval in front of the input statement, the string will not convert.

def the_flying_circus():
if (n % 2 == 0):
print "The number is even"
elif (n % 2 == 0) and (n != 4):
print "The number is even and different from 4"
else:
print "The number is odd"
return True

n = int(raw_input("Insert a number"))
the_flying_circus()


#9

Thank you for your solution! ^_^


#10

Type a simple program like this

Make sure that the_flying_circus() returns True

def the_flying_circus():
if "India"=="India" or "india=india": # Start coding here!
print True# Don't forget to indent
# the code inside this block!
elif "Luck"=="Luck":
print True# Keep going here.
else:
print True# You'll want to add the else statement, too!
return True


#11

it says there is an indantation block...how do i correct it?


#12

Python is a indent sensitive language, meaning that proper indents are REALLY important in order for Python to understand your code. One wrong indent means your entire is messed up. I suggest posting your code (formatted please) so that we can see the indents and tell you what's wrong.


#13

ans = raw_input ("what is your age?")
def the_flying_circus(): #NB: do not write def the_flying_circus(ans):
if ans > 18 or ans == 18:
return True
print "You may enter"
elif ans < 18 :
return True
print "You may not enter"
else:
return True
print "Answer not valid"


#14

i'm pretty sure my code is correct but it keeps coming up saying the "the_flying-circus does not take any arguments"

Make sure that the_flying_circus() returns True

ans = raw_input ("how are you?")
def the_flying_circus(ans):
if ans == "good" or ans == "amazing":
print "thats good" # Start coding here!
return True
# Don't forget to indent
# the code inside this block!
elif ans == "bad" or "terrible":
print "thats bad"
return True
else:
"k den"
return True
# Keep going here.
# You'll want to add the else statement, too!


#15

def the_flying_circus():
if 0 <= 1: # Start coding here!
print("fly") # Don't forget to indent
return True# the code inside this block!
elif 0 == 1 or 0 == 3:
print("circus") # Keep going here.
return True# You'll want to add the else statement, too!
else:
return True

Here is how i solved it.


#19

Thank you so much, you don't know how much time it took me lol <3