CS 1110 Lecture 2: 8.27.15 -- Lesson 2 -- Types and Casting

21 views2 pages

Document Summary

8/27/15 -- lesson 2 -- types and casting. If you need help (particularly on assignments), go to the consultants (accel lab green room). Below are the different types of errors one may encounter: Python prefers single quotes surrounding the input string values. Since floates have more information than ints, inputs with both will yield floates. Python will always convert to the type with more information. Widening --> python does this automatically if needed. Therefore, the booleans will be converted to ints. True will become 1 and false will become 0. Precedence goes downwards (parentheses highest and logical ops lowest) The type belongs to the value, not the variable. X = 5 --> varaibel x, with value 5 (of type int) Area = 20. 1 --> variable area, w/ value 20. 1 (of type float) 1e2 is a float but 32 is a variable name. Variable on the left, =, value on the right.

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