subject

Ineed as to why this wont run in python 3.0 but couldn't post it anywhere else
def main():
pass
if __name__ == '__main__':
main()
from random import randint
class character:
def ):
self. name = ""
self. health = 1
self. health_max = 1
def do_damage(self, enemy):
damage = min(
max(randint(0, self. health) - randint(0, enemy. health), 0),
enemy. health)
enemy. health = enemy. health - damage
if damage == 0: print "%s evades %s's attack." % (enemy. name, self. name)
else: print "%s hurts %s! " % (self. name, enemy. name)
return enemy. health < = 0
class enemy(character):
def , player):
(self)
self. name = 'a goblin'
self. health = randint(1, player. health)
class player(character):
def ):
(self)
self. state = 'normal'
self. health = 10
self. health_max = 10
def quit(self):
print "%s can't find the way back home, and dies of starvation.\nr. i.p." % self. name
self. health = 0
def (self): print commands. keys()
def status(self): print "%s's health: %d/%d" % (self. name, self. health, self. health_max)
def tired(self):
print "%s feels tired." % self. name
self. health = max(1, self. health - 1)
def rest(self):
if self. state ! = 'normal': print "%s can't rest now! " % self. name; self. enemy_attacks()
else:
print "%s rests." % self. name
if randint(0, 1):
self. enemy = enemy(self)
print "%s is rudely awakened by %s! " % (self. name, self. enemy. name)
self. state = 'fight'
self. enemy_attacks()
else:
if self. health < self. health_max:
self. health = self. health + 1
else: print "%s slept too much." % self. name; self. health = self. health - 1
def explore(self):
if self. state ! = 'normal':
print "%s is too busy right now! " % self. name
self. enemy_attacks()
else:
print "%s explores a twisty passage." % self. name
if randint(0, 1):
self. enemy = enemy(self)
print "%s encounters %s! " % (self. name, self. enemy. name)
self. state = 'fight'
else:
if randint(0, 1): self. tired()
def flee(self):
if self. state ! = 'fight': print "%s runs in circles for a while." % self. name; self. tired()
else:
if randint(1, self. health + 5) > randint(1, self. enemy. health):
print "%s flees from %s." % (self. name, self. enemy. name)
self. enemy = none
self. state = 'normal'
else: print "%s couldn't escape from %s! " % (self. name, self. enemy. name); self. enemy_attacks()
def attack(self):
if self. state ! = 'fight': print "%s swats the air, without notable results." % self. name; self. tired()
else:
if self. do_damage(self. enemy):
print "%s executes %s! " % (self. name, self. enemy. name)
self. enemy = none
self. state = 'normal'
if randint(0, self. health) < 10:
self. health = self. health + 1
self. health_max = self. health_max + 1
print "%s feels stronger! " % self. name
else: self. enemy_attacks()
def enemy_attacks(self):
if self. enemy. do_damage(self): print "%s was slaughtered by %! \nr. i.p." %(self. name, self. enemy. name)
commands = {
'quit': player. quit,
'': player.,
'status': player. status,
'rest': player. rest,
'explore': player. explore,
'flee': player. flee,
'attack': player. attack,
}
p = player()
p. name = raw_input("what is your character's name? ")
print "(type to get a list of actions)\n"
print "%s enters a dark, ominous cave, searching for adventure." % p. name
while(p. health > 0):
line = raw_input("> ")
args = line. split()
if len(args) > 0:
commandfound = false
for c in commands. keys():
if args[0] == c[: len(args[0])]:
commands[c](p)
commandfound = true
break
if not commandfound:
print "%s doesn't understand the suggestion." % p. name

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:20
Write a javascript program that reads three integers named start, end, and divisor from three text fields. your program must output to a div all the integers between start and end, inclusive, that are evenly divisible by divisor. the output integers must be separated by spaces. for example, if a user entered 17, 30, and 5, your program would output "20 25 30" (without the quotes) because those are the only integers between 17 and 30 (including 17 and 30) that are evenly divisible by 5.
Answers: 2
question
Computers and Technology, 22.06.2019 03:20
Which of these is a benefit of social networking? oa. hiding your true identity from friendsob. avoiding talking to people in personoc. spending time with friends instead of studyingod. connecting with new people
Answers: 2
question
Computers and Technology, 23.06.2019 00:10
Write a function so that the main0 code below can be replaced by the simpler code that calls function mphandminutes tomiles0. original main0 int main) l double milesperhour-70.0; double minutestraveled = 100.0; double hourstraveled; double milestraveled; hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; cout < "miles" 2 using namespace std; 4 /* your solution goes here/ 6 int maino 1 test passed 7 double milesperhour 70.0 all tests passed 8 double minutestraveled 100.0; 10 cout < < "miles: " < < mphandminutestomiles(milesper-hour, minutestraveled) < < endl; 12 return 0; 13
Answers: 1
question
Computers and Technology, 23.06.2019 08:00
Michael has written an e-mail to his employees that describes a new product special that will be introduced to the customers next week. by taking time to make sure the e-mail is well written, logical, and organized, michael has made sure his message has the characteristics of a) effective communicationb) ineffective communicationc) barriers to communicationd) workplace communication
Answers: 2
You know the right answer?
Ineed as to why this wont run in python 3.0 but couldn't post it anywhere else
def main():
Questions
question
Mathematics, 25.02.2020 00:55
question
Mathematics, 25.02.2020 00:55
question
Mathematics, 25.02.2020 00:55
Questions on the website: 13722360