| | |
"X not defined"?
![]() |
•
•
Join Date: Jun 2009
Posts: 3
Reputation:
Solved Threads: 0
Python Syntax (Toggle Plain Text)
print "INSERT QUIZ INTRO" choices1(); def choices1(): print "The SNES Star Fox games ran off of/was used to advertise what advancement?" print "1: 32 Bit color" print "2: Argonaut's Super FX Chip" print "3: Voice-like sound effects" print "4: Higher Frame rates" 001();
There's code past this but I imagine this is where it matters. When I run this, it says "NameError: name 'choices1' is not defined"
What can I do to fix this?
Last edited by pupspark; Jun 15th, 2009 at 7:17 pm.
•
•
•
•
Python Syntax (Toggle Plain Text)
print "INSERT QUIZ INTRO" choices1(); def choices1(): print "The SNES Star Fox games ran off of/was used to advertise what advancement?" print "1: 32 Bit color" print "2: Argonaut's Super FX Chip" print "3: Voice-like sound effects" print "4: Higher Frame rates" 001();
There's code past this but I imagine this is where it matters. When I run this, it says "choices1 not defined"
What can I do to fix this?
I think you should define the quote before u call it..
[QUOTE=pupspark;891264]
Python Syntax (Toggle Plain Text)
def choices1(): print "The SNES Star Fox games ran off of/was used to advertise what advancement?" print "1: 32 Bit color" print "2: Argonaut's Super FX Chip" print "3: Voice-like sound effects" print "4: Higher Frame rates" 001(); print "INSERT QUIZ INTRO" choices1();
•
•
•
•
Python Syntax (Toggle Plain Text)
print "INSERT QUIZ INTRO" choices1() def choices1(): print "The SNES Star Fox games ran off of/was used to advertise what advancement?" print "1: 32 Bit color" print "2: Argonaut's Super FX Chip" print "3: Voice-like sound effects" print "4: Higher Frame rates" 001();
There's code past this but I imagine this is where it matters. When I run this, it says "choices1 not defined"
What can I do to fix this?
python Syntax (Toggle Plain Text)
def choices1(): print "The SNES Star Fox games ran off of/was used to advertise what advancement?" print "1: 32 Bit color" print "2: Argonaut's Super FX Chip" print "3: Voice-like sound effects" print "4: Higher Frame rates" # 001(); This is guaranteed to raise an error on you. print "INSERT QUIZ INTRO" choices1()
Btw, Python doesn't need semi-colons as line delimiters. Go read a tutorial.
Last edited by scru; Jun 15th, 2009 at 7:22 pm.
•
•
Join Date: Jun 2009
Posts: 3
Reputation:
Solved Threads: 0
Thanks! It worked! I didn't know it needed to be previously defined. Thank you!
While you're at it, could you tell me why line 7 is invalid syntax?
While you're at it, could you tell me why line 7 is invalid syntax?
Python Syntax (Toggle Plain Text)
def loss(): print "Game Over. Try again!" "--------" begin(); def input2(): choice = input('Enter choice number:') if (choice == 1) loss(); if (choice == 2) loss(); if (choice == 3) choices3(); if (choice == 4) loss(); print "--------" def choices2(): print "What was the name of the Sharpclaw leader?" print "Andross" print "Sauria" print "General Scales" print "President Scales" "--------" def input1(): choice = input('Enter choice number:'); if (choice == 1): loss(); if (choice == 2): choices2(); if (choice == 3): loss(); if (choice == 4): loss(); "--------" def choices1(): print "The SNES Star Fox games ran off of/was used to advertise what advancement?" print "1: 32 Bit color" print "2: Argonaut's Super FX Chip" print "3: Voice-like sound effects" print "4: Higher Frame rates" input1(); "--------" print "Welcome to Pizearke's Star Fox quiz! Simply type the number of the correct choice after where it asks you to enter the choice number and press enter to play. There are ten questions. The quiz will restart if you get one wrong. Don't worry though, it's pretty easy. Try to get all the way through!" print"--------" choices1();
Last edited by pupspark; Jun 15th, 2009 at 7:42 pm.
•
•
Join Date: Jun 2009
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Seems like you are transitioning from c++/c to python. ( BTW when you have an if statement, you don't have to have parenthesizes around your expression). When you call a function, there is no need to put a semicolon next to it. Taking it away should resolve the problem.
>While you're at it, could you tell me why line 7 is invalid syntax?
Line 7 would have made sense if you had followed the proper syntax of the code tags:
[code=python]
// the code which goes here will have
// line numbers at left side
[/code]
Anyways, it turns out that you don't even know the proper syntax of if statement. If was not a bad thing if you were migrating from another language, but the fact is that you are starting programming for the first time.
Anyways, this is the proper syntax:
>I'd like to destroy whatever the source may be...
I would be glad to help you.
PS: Please follow a definitive tutorial or book to study python. The good part is: that there are enormous resources available for you to learn and most of them are free. You could start learning by the official Python Tutorial or perhaps "How to think Like a Computer Scientist" is also a valuable resource
Line 7 would have made sense if you had followed the proper syntax of the code tags:
[code=python]
// the code which goes here will have
// line numbers at left side
[/code]
Anyways, it turns out that you don't even know the proper syntax of if statement. If was not a bad thing if you were migrating from another language, but the fact is that you are starting programming for the first time.
Anyways, this is the proper syntax:
python Syntax (Toggle Plain Text)
if <condition> : #notice the colon //do something when //the condition is true
>I'd like to destroy whatever the source may be...
I would be glad to help you.
PS: Please follow a definitive tutorial or book to study python. The good part is: that there are enormous resources available for you to learn and most of them are free. You could start learning by the official Python Tutorial or perhaps "How to think Like a Computer Scientist" is also a valuable resource
Siddhant Sanyam
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
![]() |
Similar Threads
- why should we always use "CALLBACK" and "WINAPI" these words (C)
- "already defined" error (C++)
- google "keyword" question (Search Engine Optimization)
- Deitel's "C++ How To Program" exercise 2.18 (C++)
- <@ import Namespace "MathService"> , or was not found. (ASP.NET)
- inputing system("date /t") and system("time /t") into a file (C++)
Other Threads in the Python Forum
- Previous Thread: Separating Numeric Lines from Text
- Next Thread: "_imaging C module is not installed" thrown in PIL
| Thread Tools | Search this Thread |
alarm app beginner cipher cmd coordinates cx-freeze data decimals development dictionary directory dynamic error examples feet file float format function generator getvalue gui halp homework http images import input ip itunes java keycontrol leftmouse line linux list lists loop maintain maze millimeter module mouse mysqldb number numbers output parsing path port prime programming projects push py2exe pygame pyglet pymailer pyqt python queue random recursion schedule screensaverloopinactive script scrolledtext slicenotation split sqlite ssh string strings sudokusolver table terminal text thread threading time tlapse tuple tutorial ubuntu unicode url urllib urllib2 variable variables ventrilo verify vigenere web webservice wikipedia wx.wizard wxpython xlwt






