X-88

Tuple Python

May 14th, 2021 (edited)
482
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data = [['Lucy', 'woman', 173], ['Jake', 'men', 189], ['Celine', 'woman', 167], ['Mike', 'men', 192]]
  2. """
  3. writed by: Zephio
  4. lang: python 3xx
  5. May 2021
  6. """
  7. spr = '===================='
  8.  
  9. #1 print woman only
  10. def getwo():
  11.     for i in range(len(data)):
  12.         if data[i][1] == 'woman':
  13.             print(*data[i])
  14.            
  15.  
  16. #2 men taller then 190
  17. def getmh():
  18.     for i in range(len(data)):
  19.         if  data[i][1] == 'men' and data[i][2] > 190:
  20.             print(*data[i])
  21.  
  22.  
  23. #3. Height Average of women
  24. def getwha():
  25.     c = 0
  26.     ls = []
  27.     for i in range(len(data)):
  28.           if data[i][1] == 'woman':
  29.               ls.append(data[i][2])
  30.               c = sum(ls)
  31.               a = c / len(ls)
  32.     print(a)
  33.              
  34.  
  35. #4 contain word c
  36. def getcwc():
  37.     for x in data:
  38.         ls = ''.join(map(str, x[0]))
  39.         for y in range(len(ls)):
  40.             if ls[y].lower() == 'c':
  41.                 print(ls)
  42.                
  43.                
  44. print('Data:\n',  *data)
  45. print(spr, '\n#1. Show Woman only')
  46. getwo()
  47. print(spr, '\n#2. Show Man Height > 190CM')
  48. getmh()
  49. print(spr, '\n#3. Show Woman Height Average')
  50. getwha()
  51. print(spr, '\n#4. Show Name Contain word C')
  52. getcwc()
RAW Paste Data