CMPT 120 Lecture : Calculations and Functions

45 views2 pages
meghan78 and 39786 others unlocked
CMPT 120 Full Course Notes
29
CMPT 120 Full Course Notes
Verified Note
29 documents

Document Summary

Doing calculations: we will need to do some calculations to implement most algorithms, an expression is any kind of calculation that produces a result, numeric expressions produce a number as a result, eg. in guessing game: guess+1. 10 + 2 * 3 => 16 (10 + 2) * 3 => 36 so far, all we can do with the result of an expression is print it: print 18/2 -1. => 8: we will do more with them later, expressions can also be used to create strings, eg. cmpt + 120 => cmpt120 . => try two : a string in python must be in quotes, print hi , single quotes are also okay: Print hi" so, 10 and 10 are different things: 10 is a number (ten, 10 is a strong ( 1 then 0 , eg. => 20 (a number) Functions: an expression can include the evaluation of functions, a function takes some arguments and returns a result.

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

Related Questions