Advertisement
Dombear

Untitled

Oct 14th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. def max_num(num1, num2, num3, sum=0, sum2=0):    
  4.     nums = [num1, num2, num3]
  5.  
  6.     # Przerobienie listy na set, odrzucamy w ten sposób zdublowane wartości i segregujemy od najmniejszego do największego
  7.     myset = (set(nums))
  8.     # Przerobienie set na listę, wartości zostały unikalne i posegregowane  
  9.     myset = (list(myset))
  10.     # Dodanie w petli wszystkich elementow listy i setu, potem sprawdzamy wynik
  11.    
  12.     if (int(sum(nums)) == int(sum(myset))):
  13.         return  (max(nums))
  14.     else:
  15.         return ("It's a tie!")
  16.  
  17. print(max_num(-10, 0, 10))
  18. # should print 10
  19. print(max_num(-10, 5, -30))
  20. # should print 5
  21. print(max_num(-5, -10, -10))
  22. # should print -5
  23. print(max_num(2, 3, 3))
  24. # should print "It's a tie!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement