Python Forum
Creating a script with a class have specific properties
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a script with a class have specific properties
#1
I have a small txt file with fields Block, Plot, Species, and DBH. I need to create a script with a class having those properties. Within the class I need to include a method that calculates "DIB = DBH * (1/1.09)". DBH is the diameter 4.5 feet from the ground. Once I am completely done I need to run a script that imports the class and prints the results in this format:
Output:
Report 1 Block: Plot: Species: DBH: DIB: Report 2 etc.
There are a total of 9 objects. So far I am working the class but not sure I got it correct. I got no errors but I also didn't get any returns. Here is where I am. By the way I am the beginner of beginners so please don't laugh. If you do please help once you stop.

class Tree:
    def __init__(self,Block,Plot,Species,DHB):
        self.Block = Block
        self.Plot = Plot
        self.Species = Species
        self.DHB = DHB

    def assessment(self):
        if self.DHB == 4.5:
            rate = (1/1.09)
        assessment = self.DHB * rate
        return assessment
Reply


Messages In This Thread
Creating a script with a class have specific properties - by dvldgs05 - Oct-11-2018, 04:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I need help writing this code for string properties and methods hannah71605 4 3,264 Mar-22-2021, 12:36 PM
Last Post: menator01
  Creating Email Message Class in Python QuavoJ 1 2,268 Jul-20-2020, 08:30 PM
Last Post: Yoriz
  Sort objects by protected properties. Sigriddenfeta 1 1,979 Mar-17-2020, 04:11 AM
Last Post: Larz60+
  Creating class with getters and setters. amandacstr 3 2,455 Jun-19-2019, 07:10 PM
Last Post: nilamo
  newbie questions about objects properties... slowbullet 2 2,791 Aug-12-2018, 01:12 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020