def the_flying_circus(Tip): if Tip==4: print "True" elif Tip<4: print "False" else: print "None of the above." print the_flying_circus(4) #What's wrong?I've tried several times.
Python excersise The Big If
There can be no argument passed to the function. This should have been indicated in an error message. Just create a comparison expression in each case and have it return True (write it so it does).
So it was.And what should I do?Please do me a favor.
def the_flying_circus(Tip): if Tip==4 : return True elif Tip<4 and Tip<3: return False else: return "none of all above" print the_flying_circus(4) #I tried another one,it looks better,but still don't work. #If I delete the Tip within the brackets，it will return another error"the_flying_circus() takes no arguments (1 given)"
Is this not raising an SCT error? There can be no argument.
When you call it,
As for what you use inside the function, that's open. Just satisfy the requirements given in the instructions. Use both logical and comparison operators in a mix of expressions that all return True, even the
This exercise is a perfect opportunity to practice all aspects of conditionals and control flow. The
if-elif-else statement, logical
and-or-not, and comparative expressions. In other words, go to town dreaming up expressions. Just make sure they return True.
>>> import random >>> def the_flying_circus(): tip = random.randrange(10, 35, 5) print (tip) if tip <= 15: return False or True elif tip > 20: return True and True else: return False or not False >>> print (the_flying_circus()) 15 True >>>
>>> b = [ random.randrange(10, 35, 5) for x in range(10) ] >>> b [25, 15, 25, 30, 20, 20, 15, 15, 10, 10] >>>
IT really work for me.Thanks for you generous and patient.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.