Python Forum
Need help with coding project
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with coding project
#1
HI, I'm new to python coding im trying to make a plant automation system and library. I'm trying to take a user input and run it against a list and if it is in the list call the plant_info function on please tell me if im even close to accomplishing this. I have copy of code attached . Any help would be appreciated

.py   Plant library and automation.py (Size: 1.26 KB / Downloads: 38)
Reply
#2
Post code, not links to code
buran likes this post
Reply
#3
Kindly paste your code here. then i will try to solve your issue
Reply
#4
I'm not a specialist myself, but I would have add an additional method (see def getPlant here after) to get the plant name and to check if it is the same as the input string.

class Plant:
    def __init__(self,name,family,water_level,ph,sunlight,fertilizer):
        self.name=name
        self.family=family
        self.water_level=water_level
        self.ph=ph
        self.sunlight=sunlight
        self.fertilizer=fertilizer
        
    def watering(self):
        if self.water_level=="Light":
            print("WATERING....DONE")
        elif self.water_level=="Medium":
            print("WATERING...WATERING...DONE")
        elif self.water_level=="Heavy":
            print("WATERING...WATERING...WATERING...DONE")
        else:
            print("INVALID INPUT")
            
    def plant_info(self):
        print(self.name, " is a ",self.family," and has ",self.water_level," watering requirements, ",  self.ph," PH Level"," and needs ",self.sunlight,"sunlight and a",self.fertilizer,"fertilizer")        

    def getPlant(self):
        return self.name

Pepper=Plant('Pepper','Solanaceae', 'Medium','6.0','Bright','13-13-13')
Tomatoe=Plant('Tomatoe','Solanaceae', 'Medium','6.0','Bright','13-13-13')
Broccoli=Plant('Broccoli','Brassicaceae', 'Light','5.5', 'Partial Sun','13-10-10')

Plants=[]
Plants.append(Pepper)
Plants.append(Tomatoe)
Plants.append(Broccoli)

Plant_selection=input("PLEASE INPUT PLANT: ")

for p in Plants:
    if (Plant_selection.lower() == p.getPlant().lower()): p.plant_info()
Reply
#5
class Plant:
    def __init__(self,name,family,water_level,ph,sunlight,fertilizer):
        self.name=name
        self.family=family
        self.water_level=water_level
        self.ph=ph
        self.sunlight=sunlight
        self.fertilizer=fertilizer
        
    def watering(self):
        if self.water_level=="Light":
            print("WATERING....DONE")
        elif self.water_level=="Medium":
            print("WATERING...WATERING...DONE")
        elif self.water_level=="Heavy":
            print("WATERING...WATERING...WATERING...DONE")
        else:
            print("INVALID INPUT")
    def plant_info(self):
        print(self.name, " is a ",self.family," and has ",self.water_level," watering requirements, ",  self.ph," PH Level"," and needs ",self.sunlight,"sunlight and a",self.fertilizer,"fertilizer")        
Pepper=Plant('Pepper','Solanaceae', 'Medium','6.0','Bright','13-13-13')
Tomatoe=Plant('Tomatoe','Solanaceae', 'Medium','6.0','Bright','13-13-13')
Broccoli=Plant('Broccoli','Brassicaceae', 'Light','5.5', 'Partial Sun','13-10-10')
Plants=[]
Plants.append(Pepper)
Plants.append(Tomatoe)
Plants.append(Broccoli)
Plant_selection=input("PLEASE INPUT PLANT")
for Plant_selection in Plants:
    Plant_selection.plant_info()
buran write Feb-14-2024, 02:17 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  project coding python marcel2807 2 50,179 Dec-18-2020, 08:37 PM
Last Post: LastStopDEVS
  Any Google Voice users looking for a coding project? pydiot 3 3,895 May-31-2018, 10:11 PM
Last Post: pydiot
  Error in coding project, any help? XpunksnotdeadX 0 3,102 Feb-08-2018, 05:58 PM
Last Post: XpunksnotdeadX

Forum Jump:

User Panel Messages

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