how to create 12 people identites that could be male or female with their own weight, height and gender

Question:

The question wants me to create 12 persons on python these 12 people can be males, females randomly generated with their own height weight and gender all taken randomly, then to find the average weight of the males. I’m not sure how I can create the people.

Asked By: Kamel Awad

||

Answers:

Well you’ll probably gonna use classes for this task :

What is OOP

OOP focuses on the objects that are
required to be manipulated instead of logic.

  • It makes development and maintenance easier
  • It provides data hiding
  • It provides ability to simulate real-world
  • less memory and organized
  • reusable

Here’s an example on how you can achieve this using classes in python

class Person:
    # class constructor
    def __init__(self, age, gender, height, weight):
        self.height = height
        self.width = width
        self.age = age
        self.gender = gender

person1 = Person(18, "Male", 5, 20)
print(person1.height)
Answered By: Yasha_ops
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.