COMPSCI 1MD3 Lecture Notes - Lecture 2: Mathematical Logic, Distributive Property, Concatenation
Document Summary
Equality, written as ==, is a relation that is either true or false. It is not a relation, it is an instruction. Equality has a result, assignment has an effect. Functions in python take parameters and return a result. However, they are defined algorithmically: the body is a statement (instruction) In the simplest case, the body is a return statement: def ftoc(t): return (t-32) / 1. 8. Functions don"t need to have parameters: def answertotheultimatequestion( ): return 42. Functions can be composed by referring to other functions def square(a): return a*a def cube(a): return a*square(a) There are only two values, true and false: b and c = c if b else false, b or c = true if b else c, not b = false if b else true. These are closely relation to mathematical logic operators conjunction (^), disjunction (v), and negation ( ) Inequality can be defined by equality and negation: With unbounded integers, all familiar properties hold.