Advertisement
Riju21

8_fn

Mar 27th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # simple fun:
  2.  
  3. def department(dep):
  4.     return 'department: ' + dep
  5. print(department('cse'))
  6. print(department('eee'))
  7. print(department('civil'))
  8.  
  9.  
  10. # example
  11.  
  12. id = [60, 59, 58, 57]
  13.  
  14. def depart(dep):  
  15.     return dep == 'cse' or dep == 'eee' or dep == 'civil' or dep == 'geb'
  16.    
  17. def check_dep(dep):
  18.     if depart(dep):
  19.         print(dep)
  20.     else:
  21.         print('invalid')
  22. check_dep('cse')
  23. print('\n\n\n')
  24.  
  25. def check_dep_by_id(code):    
  26.     index = id.index(code)
  27.     if id[index] == 60:
  28.         print('cse')
  29.     elif id[index] == 59:
  30.         print('eee')
  31.     elif id[index] == 58:
  32.         print('civil')
  33.     elif id[index] == 57:
  34.         print('geb')
  35.     else:
  36.         print('invalid')
  37. check_dep_by_id(59)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement