3 added 149 characters in body
source | link

Jelly, 2 bytes

¬‘

Outputs 2, Try it online!

While

¬‘¬‘

Outputs 1, Try it online!

How?

The default input to a monadic chain is zero...

¬‘   - Main link: no arguments
¬    - logical not -- not the implicit input of 0 to yield 1
 ‘   - increment   -- increment 1 to yield 2
     - implicit print if this is the end of the program, otherwise...
     ...
  ¬‘ - continues the monadic chain:
  ¬  - logical not -- not the 2 to yield 0
   ‘ - increment   -- increment 0 to yield 1
     - implicit print if this is the end of the program

The two byters:

Ị‘ - insignificant (abs(z)<=1); increment
Ṇ‘ - non-vectorising logical not; increment

would work too.

Jelly, 2 bytes

¬‘

Outputs 2, Try it online!

While

¬‘¬‘

Outputs 1, Try it online!

How?

The default input to a monadic chain is zero...

¬‘   - Main link: no arguments
¬    - logical not -- not the implicit input of 0 to yield 1
 ‘   - increment   -- increment 1 to yield 2
     - implicit print if this is the end of the program, otherwise...
     ...
  ¬‘ - continues the monadic chain:
  ¬  - logical not -- not the 2 to yield 0
   ‘ - increment   -- increment 0 to yield 1
     - implicit print if this is the end of the program

Jelly, 2 bytes

¬‘

Outputs 2, Try it online!

While

¬‘¬‘

Outputs 1, Try it online!

How?

The default input to a monadic chain is zero...

¬‘   - Main link: no arguments
¬    - logical not -- not the implicit input of 0 to yield 1
 ‘   - increment   -- increment 1 to yield 2
     - implicit print if this is the end of the program, otherwise...
     ...
  ¬‘ - continues the monadic chain:
  ¬  - logical not -- not the 2 to yield 0
   ‘ - increment   -- increment 0 to yield 1
     - implicit print if this is the end of the program

The two byters:

Ị‘ - insignificant (abs(z)<=1); increment
Ṇ‘ - non-vectorising logical not; increment

would work too.

2 added 508 characters in body
source | link

Jelly, 2 bytes

¬‘

Outputs 2, Try it online!

While

¬‘¬‘

Outputs 1, Try it online!

How?

The default input to a monadic chain is zero...

¬‘   - Main link: no arguments
¬    - logical not -- not the implicit input of 0 to yield 1
 ‘   - increment   -- increment 1 to yield 2
     - implicit print if this is the end of the program, otherwise...
     ...
  ¬‘ - continues the monadic chain:
  ¬  - logical not -- not the 2 to yield 0
   ‘ - increment   -- increment 0 to yield 1
     - implicit print if this is the end of the program

Jelly, 2 bytes

¬‘

Outputs 2, Try it online!

While

¬‘¬‘

Outputs 1, Try it online!

Jelly, 2 bytes

¬‘

Outputs 2, Try it online!

While

¬‘¬‘

Outputs 1, Try it online!

How?

The default input to a monadic chain is zero...

¬‘   - Main link: no arguments
¬    - logical not -- not the implicit input of 0 to yield 1
 ‘   - increment   -- increment 1 to yield 2
     - implicit print if this is the end of the program, otherwise...
     ...
  ¬‘ - continues the monadic chain:
  ¬  - logical not -- not the 2 to yield 0
   ‘ - increment   -- increment 0 to yield 1
     - implicit print if this is the end of the program
1
source | link

Jelly, 2 bytes

¬‘

Outputs 2, Try it online!

While

¬‘¬‘

Outputs 1, Try it online!