Posts

Function in Python Examples

  1. Find the Max Hr work in the list   >>> my_List=[('java',100),('oracle',4000),('python',300)] >>> def emp_check(work_hours): curr_max =0 emp_of_month ='' for emp,hr in work_hours: if hr > curr_max: curr_max = hr emp_of_month = emp else: pass return(emp_of_month,curr_max) >>> emp_check(my_List) ('oracle', 4000)

List Examples

  List Searching  pos = -1 def search1(list1,n):         i = 0         while i<len(list1):                 if list1[i] == n:                         globals()['pos']=i                         return True                 i =i+1         return False l = [1,2,3,4,50] print(l) n = int(input('enter the number to find the list: ')) if search1(l,n):         print('found',pos) else:         print('not found',pos) About log :     User will enter the value to find in the list.     Create the search function     While loop       Finding the index is using  When  globals()  is called from a function or method, it returns the di...