Advertisement
alicemiriel

Untitled

Nov 3rd, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # Zadanie 1
  2.  
  3. dupl = [1, 1, 3, 77, 23, 4, 14, 23, 9]
  4.  
  5. def remDuplAndSort(lista):
  6.   noDupl = []
  7.   for i in lista:
  8.       if i not in noDupl :
  9.           noDupl.append(i)
  10.   return sorted(noDupl)
  11.  
  12. print(remDuplAndSort(dupl))
  13.  
  14. # Zadanie 2
  15.  
  16. l1 = range(1,55,2)
  17. l2 = range(20,40,3)
  18.  
  19. def findCommon(list1, list2):
  20.   common = []
  21.   for i in list1:
  22.       if i in list2:
  23.           common.append(i)
  24.   return common
  25.  
  26. print(findCommon(l1,l2))
  27.  
  28. #Zadanie 3
  29.  
  30. def wzor(masa):
  31.     wzor2=[]
  32.     C, O, H=12, 16, 1
  33.     for x in range(15):
  34.         for y in range(15):
  35.             for z in range(15):
  36.                 if x*C + y*H + z*O == masa:
  37.                     wzor2.append(("C"+str(x) +"H"+ str(y) + "O" + str(z)))
  38.     return wzor2
  39. print(wzor(180))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement