<jupyter_start><jupyter_text>1-7.1 Intro Python `while()` loops & increments- **while `True`  or forever loops**- **incrementing in loops**- Boolean operators in while loops-----  > Student will be able to- **create forever loops using `while` and `break`**- **use incrementing variables in a while loop**- control while loops using Boolean operators  &nbsp; Concepts `while True:` Using the 'while True:' loop[![view video](https://iajupyterprodblobs.blob.core.windows.net/imagecontainer/common/play_video.png)]( http://edxinteractivepage.blob.core.windows.net/edxpages/f7cff1a7-5601-48a1-95a6-fd1fdfabd20e.html?details=[{"src":"http://jupyternootbookwams.streaming.mediaservices.windows.net/f43862cd-7cdc-45a3-adb1-a07dcbd9ae16/Unit1_Section7.1-while-forever.ism/manifest","type":"application/vnd.ms-sstr+xml"}],[{"src":"http://jupyternootbookwams.streaming.mediaservices.windows.net/f43862cd-7cdc-45a3-adb1-a07dcbd9ae16/Unit1_Section7.1-while-forever.vtt","srclang":"en","kind":"subtitles","label":"english"}])**`while True:`** is known as the **forever loop** because it ...loops forever  Using the **`while True:`** statement results in a loop that continues to run forever   ...or, until the loop is interrupted, such as with a **`break`** statement   `break` in a `while` loop, causes code flow to exit the loop  a **conditional** can implement **`break`** to exit a **`while True`** loop    &nbsp; Examples `while True` loops forever unless a `break` statement is used<jupyter_code># Review and run code
# this example never loops because the break has no conditions
while True:
    print('write forever, unless there is a "break"')
    break
# [ ] review the NUMBER GUESS code then run - Q. what cause the break statement to run?
number_guess = "0"
secret_number = "5"

while True:
    number_guess = input("guess the number 1 to 5: ")
    if number_guess == secret_number:
        print("Yes", number_guess,"is correct!\n")
        break
    else:
        print(number_guess,"is incorrect\n")
# [ ] review WHAT TO WEAR code then run testing different inputs
while True:
    weather = input("Enter weather (sunny, rainy, snowy, or quit): ") 
    print()

    if weather.lower() == "sunny":
        print("Wear a t-shirt and sunscreen")
        break
    elif weather.lower() == "rainy":
        print("Bring an umbrella and boots")
        break
    elif weather.lower() == "snowy":
        print("Wear a warm coat and hat")
        break
    elif weather.lower().startswith("q"):
        print('"quit" detected, exiting')
        break
    else:
        print("Sorry, not sure what to suggest for", weather +"\n")<jupyter_output>Enter weather (sunny, rainy, snowy, or quit): humid

Sorry, not sure what to suggest for humid

Enter weather (sunny, rainy, snowy, or quit): rainy

Bring an umbrella and boots<jupyter_text>&nbsp; Task 1 `while True`  [ ] Program: Get a name forever ...or until done- create variable, familar_name, and assign it an empty string (**`""`**)- use **`while True:`**- ask for user input for familar_name (common name friends/family use) - keep asking until given a non-blank/non-space alphabetical name is received (Hint: Boolean string test)- break loop and print a greeting using familar_name<jupyter_code># [ ] create Get Name program
familar_name=""
while True:
    familar_name=input("Enter a familar, common, friend's, or family's name: ")
    if familar_name.isalpha():
        break
    else:
        print("That is not a name without spaces")
print(familar_name,"sounds like cool name to have")<jupyter_output>Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: 
That is not a name without spaces
Enter a familar, common, friend's, or family's name: <NAME>
That is not a name without spaces
Enter a fami[...]<jupyter_text>&nbsp; Concept Incrementing a variable[![view video](https://iajupyterprodblobs.blob.core.windows.net/imagecontainer/common/play_video.png)]( http://edxinteractivepage.blob.core.windows.net/edxpages/f7cff1a7-5601-48a1-95a6-fd1fdfabd20e.html?details=[{%22src%22:%22http://jupyternootbookwams.streaming.mediaservices.windows.net/cc7925d2-0652-4659-93fb-f4cc8d09ac51/Unit1_Section7.1-increment.ism/manifest%22,%22type%22:%22application/vnd.ms-sstr+xml%22}],[{%22src%22:%22http://jupyternootbookwams.streaming.mediaservices.windows.net/cc7925d2-0652-4659-93fb-f4cc8d09ac51/Unit1_Section7.1-increment.vtt%22,%22srclang%22:%22en%22,%22kind%22:%22subtitles%22,%22label%22:%22english%22}]) Incrementing `votes = votes + 1` &nbsp; &nbsp; or &nbsp;  `votes += 1` Decrementing  `votes = votes - 1` &nbsp; &nbsp; or &nbsp; `votes -= 1`  &nbsp; Examples<jupyter_code># [ ] review and run example
votes = 3
print(votes)

votes = votes + 1
print(votes)

votes += 2
print(votes)
print(votes)

votes -= 1
print(votes)
# [ ] review the SEAT COUNT code then run 

seat_count = 0
while True:
    print("seat count:",seat_count)
    seat_count = seat_count + 1

    if seat_count > 4:
        break
# [ ] review the SEAT TYPE COUNT code then run entering: hard, soft, medium and exit

# initialize variables
seat_count = 0
soft_seats = 0
hard_seats = 0
num_seats = 4

# loops tallying seats using soft pads vs hard, until seats full or user "exits"
while True:
    seat_type = input('enter seat type of "hard","soft" or "exit" (to finish): ')
    
    if seat_type.lower().startswith("e"):
        print()
        break
    elif seat_type.lower() == "hard":
        hard_seats += 1
    elif seat_type.lower() == "soft":
        soft_seats += 1
    else:
        print("invalid entry: counted as hard")
        hard_seats += 1  
    seat_count += 1
    if seat_count >= num_seats:
        print("\nseats are full")
        break
        
print(seat_count,"Seats Total: ",hard_seats,"hard and",soft_seats,"soft" )<jupyter_output>enter seat type of "hard","soft" or "exit" (to finish): soft
enter seat type of "hard","soft" or "exit" (to finish): hard
enter seat type of "hard","soft" or "exit" (to finish): soft
enter seat type of "hard","soft" or "exit" (to finish): george
invalid entry: counted as hard

seats are full
4 Seats Total:  2 hard and 2 soft<jupyter_text>&nbsp; Task 2 incrementing in a `while()` loop Program: Shirt Count- enter a sizes (S, M, L)- tally the count of each size- input "exit" when finished- report out the purchase of each shirt size<jupyter_code># [ ] Create the Shirt Count program, run tests
small_shirts=0
medium_shirts=0
large_shirts=0
while True:
    order=input("Enter the shirt size you wish to order(S,M,L,done): ").upper()
    if order=="S":
        small_shirts+=1
    elif order=="M":
        medium_shirts+=1
    elif order=="L":
        large_shirts+=1
    elif order=="DONE":
        print("Thank you for your order :)")
        break
    else:
        print("Enter a valid shirt size")
print("You ordered:\n",small_shirts,"Small Shirts\n",medium_shirts,"Medium Shirts\n",large_shirts,"Large shirts")<jupyter_output>Enter the shirt size you wish to order(S,M,L,done): f
Enter a valid shirt size
Enter the shirt size you wish to order(S,M,L,done): S
Enter the shirt size you wish to order(S,M,L,done): S
Enter the shirt size you wish to order(S,M,L,done): D
Enter a valid shirt size
Enter the shirt size you wish to order(S,M,L,done): L
Enter the shirt size you wish to order(S,M,L,done): E
Enter a valid shirt size
Enter the shirt size you wish to order(S,M,L,done): S
Enter the shirt size you wish to order(S,M,L,done): M
Enter the shirt size you wish to order(S,M,L,done): M
Enter the shirt size you wish to order(S,M,L,done): L
Enter the shirt size you wish to order(S,M,L,done): done
Thank you for your order :)
You ordered:
 3 Small Shirts
 2 Medium Shirts
 2 Large shirts<jupyter_text>CHALLENGE: Shirt Register (optional)  Update the **Shirt Count** program to calculate cost- use shirt cost (S = 6, M = 7, L = 8)- to calculate and report the subtotal cost for each size - to calculate and report the total cost of all shirts<jupyter_code># [ ] Create the Shirt Register program, run tests
small_shirts=0
medium_shirts=0
large_shirts=0
small_cost=6
medium_cost=7
large_cost=8
while True:
    order=input("Enter the shirt size you wish to order(S,M,L,done): ").upper()
    if order=="S":
        small_shirts+=1
    elif order=="M":
        medium_shirts+=1
    elif order=="L":
        large_shirts+=1
    elif order=="DONE":
        print("Thank you for your order :)")
        total_small=small_shirts*small_cost
        total_medium= medium_shirts*medium_cost
        total_large=large_shirts*large_cost
        total_cost=total_small+total_medium+total_large
        break
    else:
        print("Enter a valid shirt size")

print("You ordered:\n",small_shirts,"Small Shirts which costs",total_small,"\n",medium_shirts,"Medium Shirts which cost",total_medium,"\n",large_shirts,"Large shirts which cost",total_large,"\n")
print("Your total order price is",total_cost)<jupyter_output>Enter the shirt size you wish to order(S,M,L,done): S
Enter the shirt size you wish to order(S,M,L,done): S
Enter the shirt size you wish to order(S,M,L,done): S
Enter the shirt size you wish to order(S,M,L,done): M
Enter the shirt size you wish to order(S,M,L,done): D
Enter a valid shirt size
Enter the shirt size you wish to order(S,M,L,done): L
Enter the shirt size you wish to order(S,M,L,done): L
Enter the shirt size you wish to order(S,M,L,done): M
Enter the shirt size you wish to order(S,M,L,done): M
Enter the shirt size you wish to order(S,M,L,done): L
Enter the shirt size you wish to order(S,M,L,done): S
Enter the shirt size you wish to order(S,M,L,done): M
Enter the shirt size you wish to order(S,M,L,done): M
Enter the shirt size you wish to order(S,M,L,done): S
Enter the shirt size you wish to order(S,M,L,done): L
Enter the shirt size you wish to order(S,M,L,done): LK
Enter a valid shirt size
Enter the shirt size you wish to order(S,M,L,done): done
Thank you for your order :)
[...]
{'fraction_non_alphanumeric': 0.11873770952336361, 'fraction_numerical': 0.020226612978743327, 'mean_word_length': 4.281899109792285, 'pattern_counts': {'":': 19, '<': 17, '<?xml version=': 0, '>': 20, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '9970', 'license': 'MIT', 'n_tokens_mistral': 3656, 'n_tokens_neox': 3460, 'n_words': 1232, 'path': 'Python Absolute Beginner/Module_4_3_Absolute_Beginner.ipynb', 'repo_name': 'svescuso/pythonteachingcode', 'size': '10693'}