Computer Science 1026A/B Lecture 2: CompSci-Chapter 2 Notes
terubarenuka and 39895 others unlocked
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents
Document Summary
Variables: a variable is a named storage location in a computer program, there are many different types of variables, each type used to store different things. You define" a variable by telling the compiler: what name you will use to refer to it, the initial value of the variable. You use an assignment statement to place a value into a variable. *to define a variable, you must specify an initial value. Use the assignment statement "=" to place a new value into a variable cansperpack = 6 # define & initializes the variable cansperpack. Beware: the = sign is not used for comparison: It copies the value on the right side into the variable on the left side. You will learn about the comparison operator in the next chapter. The value on the right of the =" sign is assigned to the variable on the left.