title: Python if elif program to calculate wavelength of light
body: <p>I am working on a Python programming which asks the user for wavelength value and prints a description of the corresponding part of the electromagnetic spectrum, as given in the following table.</p>
  
  <pre><code>| Type          | Wavelength             | Frequency                |
  |---------------+------------------------+--------------------------|
  | Radio Waves   | 10^–3 to 10^–1         | 3 × 10^9 to 3 × 10^11    |
  | Microwaves    | 10^–3 to 10^–1         | 3 × 10^9 to 3 × 10^11    |
  | Infrared      | 7 × 10^–7 to 10^–3     | 3 × 10^11 to 4 × 10^14   |
  | Visible Light | 4 × 10^–7 to 7 × 10^–7 | 4 × 10^14 to 7.5 × 10^14 |
  | Ultraviolet   | 10^–8 to 4 × 10^–7     | 7.5 × 10^14 to 3 × 10^16 |
  | X-Rays        | 10^–11 to 10^–8        | 3 × 10^16 to 3 × 10^19   |
  | Gamma Rays    | &lt; 10^–11               | &gt; 3 × 10^19              |
  </code></pre>
  
  <p>Now I am trying to use multiple if elif statements to get to the result, but somehow I am getting indentation errors and I know I am somewhat incorrect in the entire coding as well. I am a beginner programmer who is learning Python as a starting language(just started a week ago). Here's the code I have been working on. Can someone please kindly help me with the code?</p>
  
  <pre><code>wavelength = int(input('Please enter the wavelength...'))
  
  if wavelength &gt; 1E-1:
      frequency &lt; 3E9, Wtype = Radio Waves
  
  elif 1E-3 &lt;= wavelength &lt;= 1E-1:
      3E9 &lt;= frequency &lt;= 3E11, Wtype = Microwaves
  
  
  elif 7E-7 &lt;= wavelength &lt;= 1E-1:
      3E11 &lt;= frequency &lt;= 4E14, Wtype = Infrared
  
  elif 4E-7 &lt;= wavelength &lt;= 7E-7:
      4E14 &lt;= frequency &lt;= 7.5E14, Wtype = Visible Light
  
  elif 1E-8 &lt;= wavelength &lt;= 4E-7:
      7.5E14 &lt;= frequency &lt;= 3E16, Wtype = Ultraviolet
  
  elif 1E-11 &lt;= wavelength &lt;= 1E-8:
      3E16 &lt;= frequency &lt;= 3E19, Wtype = X-Rays
  
  
  
  elif  wavelength &lt;= 1E-11:
      frequency &gt; 3E19, Wtype = Gamma Rays
  
  
  print('Your wavelength is{0}'.format(Wtype))
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>I have improvised some on the code.</p>
  
  <p>Ben, thank you for your input. I have improvised on the code per the given requirement. Here it is. No matter what input I put, it gives "Gamma Rays" as the output.</p>
  
  <pre><code>while True:
      wavelength = float(input('Please enter the wavelength...'))
  
  
  
      if 1E-3 &lt;= wavelength &lt;= 1E-1:
          Wtype = 'Radio Waves'
  
      elif 1E-3 &lt;= wavelength &lt;= 1E-1:
          Wtype = 'Microwaves'
  
  
      elif 7E-7 &lt;= wavelength &lt;= 1E-1:
          Wtype = 'Infrared'
  
      elif 4E-7 &lt;= wavelength &lt;= 7E-7:
          Wtype = 'Visible Light'
  
      elif 1E-8 &lt;= wavelength &lt;= 4E-7:
          Wtype = 'Ultraviolet'
  
      elif 1E-11 &lt;= wavelength &lt;= 1E-8:
          Wtype = 'X-Rays'
  
      elif  wavelength &gt;= 1E-11:
          Wtype = 'Gamma Rays'
  
  
      print('Your wavelength is {0}'.format(Wtype))
  </code></pre>