title: Converting a calculated decimal number into 8 bit binary
body: <p>I am currently making a python program that is byte adder related, it will prompt the user to enter 2 integers, add them together and if it's within the range of the actual size of a byte (0 to 255) display that number and also give the corresponding value in its 8 bit binary form, for example, the calculation is equal to 1, show the binary number which python declares as the correct one.</p>
  
  <p>This is the task that I am doing ~</p>
  
  <p>"The program must check the input data for the data type permitted and the data value limitations (the value of the integer must not exceed the actual size of byte-coded integers, i.e. min 00000000 and max 11111111 in Base 2 or min 0 and max 255 in Base 10 for positive integers" Input in both binary and decimal format with conversion to binary</p>
  
  <pre><code>def add():
      Num1 = int(input("Input the first number between 0 and 255, the calculated answer must not be above 255: "))
      Num2 = int(input("Input the second number between 0 and 255, the calculated answer must not be above 255: "))
  
      calculatedanswer = Num1+Num2
  
      if calculatedanswer &gt;= 0 and calculatedanswer &lt;=255:
          print("The answer in decimal is" ,calculatedanswer,)
  
          **bin(calculatedanswer)**
  
      elif calculatedanswer &lt; 0 and calculatedanswer &gt;255:
          print("Please ensure the added numbers are above 0 and below 255")
          add()
  </code></pre>
  
  <p>This is my code so far, I have no trouble getting it to display the standard decimal number, but I really can't get the <code>bin(calculatedanswer)</code> to show the binary equivalent of it. I tried using this method that I found on YouTube.</p>
  
  <p>I think my main problem here is my lack of understanding of how "bin" works on python as this is really the first time I am using it.</p>
  
  <p>I have put asterisks around the line that I am having trouble with.</p>