Skip to content

Instantly share code, notes, and snippets.

@CasperEngl
Last active July 14, 2023 22:24
Show Gist options
  • Select an option

  • Save CasperEngl/0ee5d2d86f5f50cf1c203eaa63ebb9ab to your computer and use it in GitHub Desktop.

Select an option

Save CasperEngl/0ee5d2d86f5f50cf1c203eaa63ebb9ab to your computer and use it in GitHub Desktop.

Revisions

  1. CasperEngl revised this gist Jul 14, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions variables-boolean-checks.py
    Original file line number Diff line number Diff line change
    @@ -15,9 +15,9 @@

    count = 0

    count == 1 # compare count to 1
    count == 1 # compare count to 1 == False
    # count is still 0
    count == 2 # compare count to 2
    count == 2 # compare count to 2 == False
    # count is still 0

    print(count) # prints 0
  2. CasperEngl revised this gist Jul 14, 2023. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions variables-boolean-checks.py
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,12 @@
    # Variables
    # ===================

    count = 0 # assign 0 to count
    print(count) # prints 0
    count = 1 # assign 1 to count
    print(count) # prints 1
    count = 2 # assign 2 to count
    print(count) # prints 2

    # ===================
    # Boolean checks
    @@ -17,3 +21,15 @@
    # count is still 0

    print(count) # prints 0

    # ===================
    # Variables with math
    # ===================

    count = 0

    count = count + 1 # add 1 to count
    print(count) # prints 1

    count = count + 1 # add 1 to count
    print(count) # prints 2
  3. CasperEngl created this gist Jul 14, 2023.
    19 changes: 19 additions & 0 deletions variables-boolean-checks.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    # ===================
    # Variables
    # ===================

    count = 1 # assign 1 to count
    count = 2 # assign 2 to count

    # ===================
    # Boolean checks
    # ===================

    count = 0

    count == 1 # compare count to 1
    # count is still 0
    count == 2 # compare count to 2
    # count is still 0

    print(count) # prints 0