<jupyter_start><jupyter_text>Office Hours workshop with Anade (<NAME>)Working with Loop & Lists in Python Interger = NumberFloat = Numbers with DecimalsString = Sequence of Characters (Words, letters, numbers, integers, floats, and etc.)Object = All Characters (Strings and Objects have become synonymous)List = A sequence of objects/strings...Example: me = ('Laya', 45, 'Alt') (Lists are Tuples by default unless you add Brackets)Brackets = Make it a List [Means you can change values withing variable aka mutable]Tuple = Parenthesis (Means you cannot changel values within variable unless you recreate variable aka immutable)Regex = Regular expressions Dictionary = Create key values (used heavily in NoSQL)NoSQL = (Not Only Structured Query Languate) = Language used to work with unstructured dataNoSQL Softwares =  Mondodb, Cassandra, Redis, Amazon Dynamo DBSQL = (Structured Query Language) = Language usted to work with structured dataSQL Softwares = PostreSQL, Microsoft SQL, MySQL, SQLiteLoops = perform a task over and over againRange Function = Outputs an ordered sequence as a list<jupyter_code>Laya=[33,55,25,20,18,13,2,6,6,51,67]
#You noticed we can change the variable
#This is called a mutable function aka list
Laya
#We want to change out 3rd position to the number 5
Laya [2] = 5
Laya
#Now change the 9th position to letter T
Laya [5] = "T"
Laya
#Because we use PARENTHESES instead of BRACKETS, this is called
#an IMMUTABLE function aka a TUPLE
Laya2 = (21,4,24,6,4)
Laya2
#This cell will not run, because you cannot work with positions in a tuple
Laya2 [2] = 5
#define another variable money with a List [using brackets]
Money = ['Dollars','Gold Coins','Pesos','Columbian Pesos']
Money
#find out what type object Money is
type(Money)
#the first data point in a list
#because indexing starts at 0, ex. 0,1,2 = 1st,2nd,3rd
Money[0]
#this indexing function will access the 3rd position in the list
Money[2]
#Code to replace a value in a list
Money[1]='Silver'
Money
#the first number represents our starting point
#the second number in a slice will tell you what position to end at
#but the end position will not be included in the output
Money[0:2]
Money[0:3]
#leaving off the end position will give you the remainder of the list
Money[1:]
#leaving off the first position will give you all values BEFORE the ending position
Money[:3]
Money
#this reverses your list
Money[::-1]
#but it doesn't make the change permanent
print(Money)
#it starts from 0 in Money dataframe
#It goes backwards and access the point at the -3 position
print(Money[0:-3])
#the curly brackets now make it a Set aka an Unordered List
Laya3 = {1,4,3,53,63,645,76,.91}
#when you call the Set, it orders them for you in ascending order
#notice the Float is listed first, as it's value is less than 1
Laya3
#this is the range function
#as you see, it creates a range, starting at 0, with the number of values you select
for x in range(9):
  print(x)
#what's the use case for this?
#quick math, quick calculations, quick ratios
#used by many Engineers, Developers and Coding Tests

#below we multiply all the numbers in the range by 6, individually
for x in range (9):
  print(x * 6)
#now we create a range within a range
#this is similar to a slice, where the first number tells where the range starts
for x in range(1,6):
  print(x)
#here is an example of how to get only 3 values in a range of 8 (0-7)
#remember 0 is the first position
for y in range(5,8):
  print(y)
#now let's do some math between our range
#the 6 tells you what position to start
#the 49 tells you what position to end
#the 7 tells you how many positions to 'step' with each outcome
for x in range(6, 49, 7):
  print(x)
#adding an else function
#note the b can be anything you want, it is totally a made up thing
for b in range(8):
  print(b)
else:
  print('Done!')
#define the variable Playdate
Playdate = "Laya Plays All Days"

#define the variable x
x = 0

#create a LOOP that begins at the first position
#and ends when it reaches the last position
for i in Playdate:
  x=x+1
  print(Playdate[0:x])
#define another variable that will start the function at the 2nd position
y = 1

for i in Playdate:
  y = y + 1
  print(Playdate[1:y])
#note the number you assign the variable tells how many postions to start with
#the number you add in the loop function tells how many to add each time
y = 4

for i in Playdate:
  y = y + 4
  print(Playdate[1:y])

#example of a FOR LOOP an how to BREAK it
#first define the List
Pay = ['Silver','Gold','Platinum','Cash','Bitcoin']
#then test the base of the loop function
for x in Pay:
  print(x)
#now break the loop when it gets to 'Cash'
for x in Pay:
  print(x)
  if x == 'Cash':
      break<jupyter_output>Silver
Gold
Platinum
Cash<jupyter_text>*   if the x input is True the the Loop breaks immediately      case use: Automated Survey            when you answer a question with an answer they are not looking for, you cannot continue the survey... like when employers require a Bachelor's degree for a job applicant, and you don't lie about it, you can't get to the interview process :)<jupyter_code>#if you move the print() function to AFTER the break...
#the output will not include the 'breaking point' I totally just made up that term
#just another monkey with a typewriter 'not' quoting Shakespeare
for x in Pay:
  if x == 'Cash':
      break
  print(x)<jupyter_output>Silver
Gold
Platinum<jupyter_text>While Loops are repeated as long as the expression is True.**Conditional Statements**Equals: x == yDoes Not Equal: x != yLess Than: x < yLess Than OR Equal To: x <= yGreater Than: x > yGreater Than OR Equal To: x >= y**note**: most spaces in Python are irrelevant, they can be or not be, doesn't affect outputs<jupyter_code>#if payment doesn't equal cash we print it
for x in Pay:
  if x != 'Cash':
    print(x)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07454265686442127, 'fraction_numerical': 0.01897760300906138, 'mean_word_length': 4.503292568203198, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '638608', 'license': 'MIT', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1736, 'n_words': 924, 'path': '9_1_20WkshpLoops&Lists.ipynb', 'repo_name': 'TLeahSpencer/Loops_Lists_Wkshp', 'size': '5857'}