CMPT 120 Lecture : Type Conversion

22 views1 pages
meghan78 and 39786 others unlocked
CMPT 120 Full Course Notes
29
CMPT 120 Full Course Notes
Verified Note
29 documents

Document Summary

Type conversion: you know that these values are somehow similar. 10 (string: python doesn"t, there are built-in functions that convert between types, str(), int(), float() convert to their respective types, eg. int( 10 ) str(82. 21) float(14) int(9. 8) int( ten ) int( 10. 0 ) int(float( 10. 0 )) => 10. => (valueerror) this can be used to change to the type you need: eg. total=142 count=10 print total/count print float(total)/count print float(total/count) => 14. 0 these can also be used to build a string for output: eg. guess = print is it + str(guess) + ? .

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