default values python
class Test:
    def __init__(self, val, num = 0):
        self.val = val
        self.num = num
# you can write this:
t = Test(1)
print(t.num) # prints 0
# OR this
t = Test(1, 2)
print(t.num) # prints 2
                                
                            default values python
class Test:
    def __init__(self, val, num = 0):
        self.val = val
        self.num = num
# you can write this:
t = Test(1)
print(t.num) # prints 0
# OR this
t = Test(1, 2)
print(t.num) # prints 2
                                
                            optional argument python
def myfunc(a,b, *args, **kwargs):
      c = kwargs.get('c', None)
      d = kwargs.get('d', None)
      #etc
myfunc(a,b, c='nick', d='dog', ...)
                                
                            optional parameter in python
def to_smash(total_candies, n_friends=3):
    return total_candies % n_friends
  
 #Here n_friends is Optional Parameter
                                
                            optional arguments python
def some_function (self, a, b, c, d = None, e = None, f = None, g = None, h = None):
    #code
                                
                            Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us