Advanced Functions: ================ 1) Passing of string object as an argument/a parameter to the function: ====================================================== Syntax: def function-name(str-object): function-body # Passing of a string object to a function def strFunction(str): print(str) strFunction("Hello Guys.") strFunction("Good Morning.") strFunction("have a great day.") =========================== # WAP IN PYTHON TO CREATE A FUNCTION WHICH ACCEPTS A STRING DATA AND CAN RETURN THE COUNT FOR THE NUMBER OF VOWELS. def countVowels(strData): count = 0 for ch in strData: if ch in "AEIOUaeiou": count = count + 1 return count s1 = "Python Programming" s2 = "Object Oriented Programming" print("The Total number of vowels in {} is = {}".format(s1,countVowels(s1))) count_vowels = countVowels(s2) print("The Total number of vowels in {} is = {}".format(s2,count_vowels)) ============================================== Returning of string data from function: ============================= Syntax: def function-name(parameter): function-body return string-object # returning a string by the function def strFunction(): a = 100 b = 200 if a < b: smaller = a else: smaller = b # result = ("The Smallest number among the given two numbers is = {}".format(smaller)) # result = 'The Smallest number among given two numbers is = ',smaller result = "The Smallest number among the given integers is = %s"%(smaller) return result output = strFunction() print(output) ====================================================== Passing of List data as an arguments to the function: ======================================== Syntax: def function-name(list-data-object): function body # passing a list data to a function def listFunction(listData): sum_even = 0 for se in listData: if se % 2 == 0: sum_even += se return sum_even ld = eval(input("Enter some list data:")) print("The Sum of all even elements of list {} is = {}".format(ld,listFunction(ld))) ====================================== Passing of Tuple data as an argument to the function: ========================================= (1,2,3) 1,2,3 Syntax: def function-name(tuple-object): function-body # Passing a tuple data to a function as an argument def tupleFunction(tupleData): for i in tupleData: print(i,end = "\t") td = eval(input("Enter a tuple data:")) tupleFunction(td) ============================================ Passing of a dictionary as an argument to the function: ========================================= Syntax: def function-name(dictionary-data): function-body # Passing a dictionary as an argument to the function def dictFunction(dictData): print("The Name of the student is = ",dictData['name']) print("The Roll of the student is = ",dictData['roll']) print("The Marks of the student is = ",dictData['marks']) student = {'name' : "Rajesh", 'roll' : 10, 'marks' : "72.90%"} dictFunction((student)) ================================================== Assignment: ========== 1) WAP TO DEFINE A FUNCTION WHICH ACCEPTS A SET DATA AS AN ARGUMENT AND RETURN THE BIGGEST NUMBER FROM THE SET. {1,9,7,3,5} BIGGEST ==> 9