Sunday, December 20, 2020

python day 14 functions

 # -*- coding: utf-8 -*-

"""

day 14

topic: functions continue



def function_sec():

    print("secundrabad")

    

def function_erragadda():

    print("function_erragadda")

    


def function_kukatpally():

    print("function_kukatpally")

    

    


if __name__ == "__main__":

 

    function_sec()

    function_kukatpally()

    function_erragadda()

    function_kukatpally()

    function_erragadda()

    function_sec()




def funtion_one(i=5):

    print("addition:",i+6)


if __name__ == "__main__":

    funtion_one(11)



def funtion_one():

    print(args)

    print(type(args))

    i=args[0]

    j=args[1]

    k=args[2]

    l=args[3]

    m=args[4]

    print("addition:",i+j+k+l+m)


if __name__ == "__main__":

    my_list =[2,3,4,5,6]

    print(my_list)

    funtion_one(my_list)

    

# passing list

def funtion_one(my_list):

    '''print(args)

    print(type(args))

    i=args[0]

    j=args[1]

    k=args[2]

    l=args[3]

    m=args[4]

    print("addition:",i+j+k+l+m)'''

    for i in range(5):

        print(my_list[i])

   

if __name__ == "__main__":

    my_list =[2,3,4,5,6]

    #print(my_list)

    funtion_one(my_list)

    


def funtion_one(my_list):

    '''print(args)

    print(type(args))

    i=args[0]

    j=args[1]

    k=args[2]

    l=args[3]

    m=args[4]

    print("addition:",i+j+k+l+m)'''

    print(my_list)

    print(type(my_list))

   

if __name__ == "__main__":

    my_list ={2,3,4,5,6}

    print(type(my_list))

    #print(my_list)

    funtion_one(my_list)



def function_math(a,b):

    print(a**2+2*a*b+b**2)

    

    

   

if __name__ == "__main__":

    a=4

    b=3

    function_math(a,b)

    


from my_math_function import a_square_b_square_two_a_b

    

    

   

if __name__ == "__main__":

    a=4

    b=3

    a_square_b_square_two_a_b(a,b)



def function_kodi():

    print("this is kodi mundu function")

    

    def function_guddu():

        print("This is guddu mundu function")

    

    function_kodi()


if __name__ == "__main__":

    

    function_kodi()



def factorial(x):

    '''This is a recursive function

    to find the factorial of an integer'''


    if x == 1:

        return 1

    else:

        return (x * factorial(x-1))



if __name__ == "__main__":

    num = 10

    print("The factorial of", num, "is", factorial(num))


def functions_n_arguments(*myargs):

    print(myargs)


if __name__ == "__main__":

    num = 10

    functions_n_arguments(num,112,22,2,2,2,2,2)

"""

def functions_n_arguments(**kwargs):

    print(kwargs)

    print(type(kwargs))


if __name__ == "__main__":

    num = 10

    functions_n_arguments(num=10,i=11)






















































No comments:

Post a Comment

python class topic video