diff --git a/max submission/6_9_HW.py b/max submission/6_9_HW.py index cd0e28f..97570d8 100644 --- a/max submission/6_9_HW.py +++ b/max submission/6_9_HW.py @@ -26,6 +26,7 @@ #example for "When an instance method object is created by retrieving a user-defined function object from a class via one of its instances, #its __self__ attribute is the instance, and the method object is said to be bound. The new method’s __func__ attribute is the original function #object." +""""" class MyClass: def my_method(self): print("Hello, world!") @@ -42,10 +43,12 @@ print(method_object.__func__) # Output: # Calling the method through the method object method_object() # Output: Hello, world! +""""" #async def: # the async def syntax is used to define an asynchronous function, also known as a coroutine. An asynchronous function allows concurrent # execution of multiple tasks by allowing the program to proceed to other tasks while waiting for certain operations to complete. +""""" import asyncio async def my_coroutine(): @@ -55,7 +58,7 @@ async def my_coroutine(): # Calling the coroutine asyncio.run(my_coroutine()) - +""""" #Static method and class method: #In Python, static methods and class methods are two types of methods that can be defined within a class. #Static methods: @@ -82,6 +85,7 @@ def main(): number1 = 5 number2 = 10 sum_result = add_numbers(number1, number2) + breakpoint() # Set breakpoint here product_result = multiply_numbers(sum_result, number2) print("Product:", product_result) @@ -89,21 +93,16 @@ if __name__ == "__main__": main() # question 3: -def foo(): - a = 10 - b = 20 - return a + b -def bar(): +def main(): x = 5 - y = 7 - return x * y - -result = foo() + bar() -print(result) -# In this example, using "Step Over" and "Step Into" may not yield different results, but the behavior is -# dependent on the implementation of the functions being called. + y = 2 + breakpoint() + result = x + y # Line of interest + print(result) + +main()