SHARE
TWEET

Untitled

a guest May 15th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def max(a, b):
  2.     if a > b:
  3.         return a
  4.     else:
  5.         return b
  6.  
  7. numbers = input(':').split()
  8.  
  9. system_digits = ['0','1','2','3','4','5','6','7','8','9']
  10. system_letters = ['A','B','C','D','E','F']
  11. list_of_digits = []
  12.  
  13. letter_check = False
  14. unknown_system = False
  15.  
  16. for number in numbers:
  17.     for symbol in number:
  18.         list_of_digits.append(symbol)
  19.  
  20. unknown_system_check = list(set(list_of_digits) - set(system_digits + system_letters))
  21.  
  22. for number in numbers:
  23.     if number[0] == '0':
  24.         print('Неизвестная система счисления.')
  25.         unknown_system = True
  26.         break
  27.     else:                                                            
  28.         for symbol in list_of_digits:
  29.             for system_digit in system_digits:
  30.                 bigger_number = 0
  31.                 if symbol == system_digit:
  32.                     bigger_number = symbol
  33.                     max_number = max(int(symbol), int(bigger_number))
  34.                 else:
  35.                     for system_letter in system_letters:
  36.                         if symbol == system_letter:
  37.                             letter_check = True
  38.  
  39. if unknown_system:
  40.     pass
  41. else:
  42.     if unknown_system_check != []:
  43.         print('Неизвестная система счисления.')
  44.     else:
  45.         if max_number < 2 and letter_check == 0:
  46.             print('Двоичная система счисления.')
  47.         elif max_number < 8 and letter_check == 0:
  48.             print('Восьмеричная система счисления.')
  49.         elif max_number < 10 and letter_check == 0:
  50.             print('Десятичная система счисления.')
  51.         elif letter_check:
  52.             print('Шестнадцатиричная система счисления.')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top