{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture02-syntax-3pp

# The shell is good for tes3ng parts of your code and

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: thon: x=1 x == 1 x=x+1 x == 3 returns TRUE returns FALSE 31 Assignments and equality tests • “=“ always changes the value of the variable • “==“ never changes the value of the variable   Remember: == is used to “ask” ques3ons about the value of the variable In Python: x=1 x == 1 x=x+1 x == 3 The value of x remains 1! The value of x remains 2! 32 RECAP: Types, values, expressions • We always perform the computa3on on values   When these values are known at the 3me we write the program, they are called constants   When they are not known at the 3me we write the program (for example, when we ask the user), we must store them in variables • Example: the temperature is not known when we write the program 32, 5, and 9 are constants 33 11 13 ­09 ­10 RECAP: Types, values, expressions • Every expression has a value and every value has a type • Expressions may involve constants, variables, operators and func3on calls   To evaluate an expression (i.e., to ﬁnd its value) we replace variables with their values, evaluate all func3on calls, and then execute the operators (in the proper order) • The type of a value is the “kind of data” of that value, and determines what we can do (i.e., the operators and func3ons that we can use) with that value 34 VERY IMPORTANT!!! • Some of the examples in these slides is taken directly from the Python shell >>> indicates it was done in the shell!   The shell is good for tes3ng parts of your code and doing examples, but not for wri3ng actual programs • No “>>>”? Then it is a...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online