Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (loser66):

I am trying python and get stuck at syntax. Anyone helps me, please

OpenStudy (loser66):

def the_flying_circus(answer): if answer<5: return True elif answer>5: return False else: return 0 print the_flying_circus(4) and they said "Oops, try again. Make sure to use at least one boolean operator! " I feel like an idiot when everybody can do but me.

OpenStudy (dan815):

try ans=the_flying_circus(4) print ans

OpenStudy (anonymous):

Your function works fine when I try running it in the python translator on codeacademy. Just slide the last print statement to the beginning rather than indenting it.

OpenStudy (dan815):

ya it works for me too

OpenStudy (dan815):

@hail.b3nt are you doing python course right now?

OpenStudy (anonymous):

I am @dan815

OpenStudy (dan815):

cool

OpenStudy (dan815):

are u having fun

OpenStudy (anonymous):

I sure am!!

OpenStudy (dan815):

i found a good site to get some practice with programming and learning math wanna try the problems there

OpenStudy (anonymous):

Sure! Thanks

OpenStudy (dan815):

http://projecteuler.net/problems

OpenStudy (dan815):

im still on the first few questions

OpenStudy (dan815):

theyre interesting problems, learning new ways to use python

OpenStudy (anonymous):

Wow! There are so many. I'll enjoy this thanks.

OpenStudy (dan815):

some of those questions later on look crazy

OpenStudy (dan815):

solve like 50! become a pro hacker! haha

OpenStudy (anonymous):

Lolz

OpenStudy (dan815):

tell me when u get to like question 3

OpenStudy (dan815):

i need to work out my code, its a little blaahh i wanna rewrite it with while loops but dont know how

OpenStudy (loser66):

@dan815

OpenStudy (dan815):

oh we fixed this problem for u already

OpenStudy (loser66):

It didn't work,

OpenStudy (dan815):

you are writing your print command in your function

OpenStudy (dan815):

paste code here

OpenStudy (loser66):

def the_flying_circus(a): if a<5: return True elif a>=5: return False else: return 0 print a(5) print a(7)

OpenStudy (dan815):

what what is a(5)??

OpenStudy (dan815):

that wont do anything

OpenStudy (dan815):

def the_flying_circus(a): if a<5: return True elif a>=5: return False else: return 0 print the_flying_circus(5) print the_flying_circus(7)

OpenStudy (dan815):

python is very particular on indent if you write something in the indent you are saying this is still part of the function

OpenStudy (loser66):

this is the previous lecture, and I passed it, the problem I got stuck is review def greater_less_equal_5(answer): if answer>5: return 1 elif answer<5 : return -1 else: return 0 print greater_less_equal_5(4) print greater_less_equal_5(5) print greater_less_equal_5(6)

OpenStudy (dan815):

okay is there something still wrong with your code?

OpenStudy (dan815):

def the_flying_circus(a): if a<5: return True elif a>=5: return False else: return 0 print the_flying_circus(5) print the_flying_circus(7)

OpenStudy (dan815):

why do u have = in this code then

OpenStudy (dan815):

def the_flying_circus(a): if a<5: return True elif a>5: return False else: return 0 print the_flying_circus(5) print the_flying_circus(7)

OpenStudy (dan815):

try this

OpenStudy (loser66):

I did, still not work

OpenStudy (dan815):

i dont know the specification of your program but if you have a>=5 then the return 0 for else is redundant for all integer inputs

OpenStudy (loser66):

def the_flying_circus(a): if a<5: return True elif a>=5: return False else: return 0 print the_flying_circus(5) print the_flying_circus(7)

OpenStudy (dan815):

no you cannot put print like that

OpenStudy (dan815):

remove the indent

OpenStudy (loser66):

Oops, try again. Your indentation looks a bit off. Check the Hint if you need help!

OpenStudy (dan815):

def the_flying_circus(a): if a<5: return True elif a>=5: return False else: return 0 (no space here)print the_flying_circus(5) print the_flying_circus(7)

OpenStudy (loser66):

File "python", line 4 elif a>=5: ^ IndentationError: unindent does not match any outer indentation level

OpenStudy (dan815):

def the_flying_circus(a): if a<5: return True elif a>5: return False else: return 0 print the_flying_circus(5) print the_flying_circus(7)

OpenStudy (dan815):

copy paste that code exactly

OpenStudy (dan815):

|dw:1389046531409:dw|

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!