Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn Python STATIC METHODS in 5 minutes! โšก
Play lesson

Python tutorial for beginners ๐Ÿ - Learn Python STATIC METHODS in 5 minutes! โšก

4.0 (0)
8 learners

What you'll learn

This course includes

  • 14.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

# Static methods = A method that belong to a class rather than any object from that class (instance) # Usually used for general utility functions # Instance methods - Best for operations on instances of the class (objects) # Static methods - Best for utility functions that do not need access to class data class Employee: def __init__(self, name, position): self.name = name self.position = position #INSTANCE METHOD def get_info(self): return f"{self.name} = {self.position}" @staticmethod def is_valid_position(position): valid_positions = ["Manager", "Cashier", "Cook", "Janitor"] return position in valid_positions print(Employee.is_valid_position("Rocket Scientist"))

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere