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

  • SEARCH
  • Home
  • 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 7902003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:22:48+00:00 2026-06-03T09:22:48+00:00

class person(): def __init__(self): self.height = 3.0 self.weight = 240.0 self.temp = 99.23 self.statlist

  • 0
class person():
    def __init__(self):
        self.height = 3.0
        self.weight = 240.0
        self.temp = 99.23

        self.statlist = [self.height, self.weight, self.temp]

    def grow(self):
        self.statlist[1] = self.statlist[1] + 26.0

What is the best way to approach this?

The problem is that I’m trying to access these ‘stat’ attributes from a list and alter them, but I really don’t know how to call them. I need to do this so I can randomly choose a stat to modify. Should I make a stat class, so that each stat is an instance of that class?

Any help would be magnificent.

  • 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-03T09:22:50+00:00Added an answer on June 3, 2026 at 9:22 am
    import random
    
    class person():
        def __init__(self):
            self.height = 3.0
            self.weight = 240.0
            self.temp = 99.23
    
            self.attrlist = ['height', 'weight', 'temp']
    
        def grow(self):
            rand_attr = random.choice(self.attrlist)
            attr_value = getattr(self, rand_attr)
            setattr(self, rand_attr, attr_value + 26.0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Person class like this: class Person: def __init__(self, name, age): self.name
I have the following code. class person(object): def __init__(self, keys): for item in keys:
I frequently do this sort of thing: class Person(object): def greet(self): print Hello class
How come this approach of creating a private class method works: class Person def
I have the following code: #!/usr/bin/ruby class Person def self.speak p = self.new puts
I'm Java person who just started learning Python. Take this example: class Person(): def
I have an object roughly like so: class Hand(object): def __init__(self, finger_names, finger_lengths, nail_sizes):
class Person DEFAULT_MALE_NAME = Joe DEFAULT_FEMALE_NAME = Jane def give_default_name self.name = self.class.send(DEFAULT_#{gender.upcase}_NAME) end
Here is some code: class Person def initialize(age) @age = age end def age
class Person { string name; public Person(string name) { this.name = name; } public

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.