""" Purpose: demonstrate assignment only effects the variable being assigned """ # y = x # what is x? i havent seen x yet. ERROR: You can't use a variable before it is defined! x = 10 # variable x is assigned value 10 y = x # variable y is assigned the value of variable x y = x + y # we can do this because x and y already exist. this is updating the value of y to include a # previous value of y, then adding x. Little complicated, so we'll come back to this another day x = 20 # variable x is assigned value 20. this overwrites the previous assignment x = "Charles" # variables can hold different types of values (strings, integers, decimal numbers, etc) # snake_case: The way we stylistically name variables in python. We use all lowercase letters, # and replace spaces with underscores (_). EX: this_is_snake_case # Charles needs to be surrounded by quotes during assignment if we want the string "Charles". # without the quotes, python will think we have a variable named Charles # line 9 is assigning the variable the value of the string "Charles" # anything between quotes "" is a literal string. You can put any characters between the quotes # having readable code makes it easier for us to give you partial credit (: # pro tip: BE COMFY WITH INFO SHEET AND MODULE TAB. you can use it on exams # use comments to make your code more readable. comment tricky/complicated things, or leave comments # if you're attempting to do something but cant figure it out. No need for excessive amounts of comments print( "x:", x ) # x was most recently assigned to 20, so the value is 20 print( "y:", y ) # y was given the value of x when x's value was still 10. changing the value of x # later wont effect the value of y # using the string "x:" and then the variable x lets us label out output. # print( "x:" ) will literally print out x:, then print( x ) will print the value of the variable x # we can combine these print statements like: print( "x:", x ), where the comma separates the things # we print. (and in the output, python will put a space between the string "x:" and the value of x) # running your code will save it