Help With Python Please :)
So I am required to make a really basic python game. The python dice game. Yes I know its probably laughably simple for most of you but I am not a technical person so I really need some help. Basically the game is your supposed to enter in your name and a guess of what you think the 6 diced rolled will total (guess a number and you win if the total of the dice roled is greater than your guess). I got the form all figured out in the xhtml but when I select go it just brings me to my code for the python script i.e its not really connect properly so my questions are
1) do i need to enter in the name of the html document anywhere on the python document
2) I keep getting a syntax error in my python document when I run the module..I have no idea. why... i might be doing a few things wrong. can some one please let me know
Here is my python script
import cgi
form = cgi.FieldStorage()
import random
die = random.randint(a,b)
name = form.getvalue("name")
value=(form.getvalue ("value"))
total = int(form.getvalue("total")
die1 = random.randint (1, 6)
die2 = random.randint (1, 6)
die3 = random.randint (1, 6)
die4 = random.randint (1, 6)
die5 = random.randint (1, 6)
total = int(die1) + int(die2) + int(die3) + int(die4) + int(die5)
# print HTTP/HTML headers
print """Content-type: text/html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Dice Game</title>
</head>
<body>
"""
#print HTML body using form data
print "<p>Thanks for playing, " + name + ". </p>"
print "<p>You bet the total would be at least " + str(value) +" . </p>"
print "<p>The total rolled was " + str(total) + ". </p>"
if die1 == 1:
print "<p><img src="' + str(die1) + 'die.png" alt="' + str(die1) + '" /></p>"
elif die1 == 2:
print "<p><img src="' + str(die2) + 'die.png" alt="' + str(die2) + '" /></p>"
elif die1 == 3:
print "<p><img src="' + str(die3) + 'die.png" alt="' + str(die3) + '" /></p>"
elif die1 == 4:
print "<p><img src="' + str(die4) + 'die.png" alt="' + str(die4) + '" /></p>"
elif die1 == 5:
print "<p><img src="' + str(die5) + 'die.png" alt="' + str(die5) + '" /></p>"
elif die1 == 6:
print "<p><img src="' + str(die6) + 'die.png" alt="' + str(die6) + '" /></p>"
if total == value:
print "<p> You Won! </p>"
elif value < total:
print "<p> You Won! </p>"
else:
print "<p> Sorry....You Lost.</p>"
print "</body></html>"
HERE IS MY HTML SCRIPT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Dice Game</title>
<link rel="stylesheet" href="a4.css" />
</head>
<body>
<h1>Dice Game</h1>
<form action="dice.py">
<div class="formin">Enter your name:
<input type="text" size="6" maxlength="30" name= "name" />
</div>
<div class="formin"> You bet the total will be at least:
<input type= "text" size="6" maxlength="3" name="value" />
</div>
<div class="formin">
<input type= "submit" value="Go!" />
</div>
</form>
</body>
</html>
IF someone could help me I'd really appreciate it, and of course I'd try and return the favor. I'm really good at PPC if that helps
Brittany
Landing Page Quality Score WSO
Landing Page Quality Score WSO
Eight bytes walk into a bar. The bartender asks, âCan I get you anything?â
âYeah,â reply the bytes. âMake us a double.â
Landing Page Quality Score WSO
Landing Page Quality Score WSO