CMPT 165 Lecture : CMPT165-Variables.docx

48 views5 pages

Document Summary

Sum:potash: if we want python to treat x and y as numbers, we will have to tell it to do this, to treat x and y as numbers, we will have to convert them from strings to numbers. That is, we have to change their data type: all variables have a specific data type, the data type of a variable lets python know how to treat the variable. Adding two strings together will attach them together, whereas adding two numbers together will mathematically add them: string (str) Stores a whole number (no decimal point: floating point (float) Stores a number with a decimal point: boolean (bool) Stores either true or false: for the calculator, x and y are numbers, so we could store them in either integers or floats. Sum:5. 0: our corrected calculator could still produce a runtime error for example, if the user types in a word instead of a number.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions