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?

Recommended Answers

All 7 Replies

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..

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();
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?

When you call choices1, it isn't yet defined. The solution is pretty obvious.

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.

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?

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();

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.

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.

Actually, I'm new to programming all together. Thanks, though!

Actually, I'm new to programming all together. Thanks, though!

From where are you learning your python then? I'd like to destroy whatever the source may be...

>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:

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

commented: Doesn't the fact that he's starting programming for the first time make him more prone to make mistakes? -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.