Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8911693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:00:46+00:00 2026-06-15T04:00:46+00:00

Possible Duplicate: TypeError: ‘module’ object is not callable This is my very first Python

  • 0

Possible Duplicate:
TypeError: ‘module’ object is not callable

This is my very first Python attempt, just trying to regain basic programming knowledge after a 10 year silence in a, for me, new language, Python. The basic idea is a tiny battly engine which decides the better hit. The bugging code is next.

self.__power = self.__att*random(2,4)/dier.__defn

As my python knowledge is extremely basic, I’m rather scared of saying the right things so Im gonna put my code down below (47 lines), you..ll notice it is really transparant so I dont suspect this will give any problem. The errorline is 16. I tried renaming the att variable to atta as well as some repositionings though new bugs come, I solve them and in the end its always the same error on the same line.

class Character:
def __init__(self,name="", att=0,defn=0,lvl=0,leven=0,exp=0, power=0):
        self.__att = att
        self.__defn = defn
        self.__lvl = lvl
        self.__leven = leven
        self.__name = name
        self.__xp = exp
        self.__power = power

    def batl(self):
        import random
        while self.__lvl <= 3:
            dier = Character("Anaconda",1,1,50,1,0,0)
            print "You encountered an " + dier.__name + " and fight it."
            **self.__power = self.__att*random(2,4)/dier.__defn**
            dier.__power = (dier.__att*random(1,4))/self.__defn
            if self.power > dier.power:
                growth = dier.__lvl*dier.__atta
                groei()
            else:
                dmg = dier.lvl*dier.att
                leven = leven-dmg
            if leven < 0:
                print "Alas, you're done for."
                exit()
            else:
                print "You took " + dmg + "damage and have " + leven + "life left."


    def groei(self):
        if (growth+exp) > 100:
            lvl += 1
            exp = growth-100
            print "You won and gained " + str(growth) + " and grew from level " + str(lvl-1) + " to level " + str(lvl) + "."
        else:
            exp = growth + exp
            print "You won and gained " + str(growth) + "."

def main():

hero = Character("Nevery",2,1,2,100,0,0)
hero.batl()

if name == ‘main‘:
main()

As you can see ive got my character class, in which i have defined the battle() method and the groei() method, very basic. Can anyone point me what I’m missing out on, been looking at it for hours. Thanks in Advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:00:47+00:00Added an answer on June 15, 2026 at 4:00 am

    random is the module, not the function. You need to call random.random. You could also from random import random, but I’d go with the first option in this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: getElementByClass().setAttribute doesn't work Why this: document.getElementsByClassName('cke_source').setAttribute('name', mymessage) Is returning: TypeError: Object #<NodeList>
Possible Duplicate: “uncaught TypeError: Object is not a function” in JavaScript my full js
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: If Javascript has first-class functions, why doesn’t this work? In Chrome, the
Possible Duplicate: jquery autocomplete this.source is not a function error I have an autocomplete
Possible Duplicate: Cyclic module dependencies and relative imports in Python Consider the following example
Possible Duplicate: Python hashlib problem TypeError: Unicode-objects must be encoded before hashing Here is
Possible Duplicate: Is there any way to kill a Thread in Python? So this
Possible Duplicate: How can I modify a Python traceback object when raising an exception?
Possible Duplicate: builtins.TypeError: must be str, not bytes I wrote a program to write

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.