COMPSCI 1MD3 Lecture Notes - Lecture 2: Mathematical Logic, Distributive Property, Concatenation

87 views3 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents