Question

Exercise: create01 Description Write a function that receives no parameters and returns a Pencil object constructed with 3 lepYTHON

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

main.py:

from pencil import pencil

def create01():
    
    obj = pencil(3,10)
    
    return obj
    
    
    
p=create01()
print(p.get_num_leads())
print(p.get_current_lead_length())



pencil.py:

class pencil:
    
    def __init__(self,lead,length):
        self.leads=lead
        self.leadlength=length
        
    def get_num_leads(self):
        return self.leads
        
    def get_current_lead_length(self):
        return self.leadlength
        
        
        

Output:

Run Debug Stop Share A Save {} Beautify C++ re. main.py pencil.py 1 class pencil: 2 3- def _init__(self, lead, length): 4 sel

Add a comment
Know the answer?
Add Answer to:
pYTHON Exercise: create01 Description Write a function that receives no parameters and returns a Pencil object...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT