Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nate Brunelle Today: Strings, Type Casting

Similar presentations


Presentation on theme: "Nate Brunelle Today: Strings, Type Casting"— Presentation transcript:

1 Nate Brunelle Today: Strings, Type Casting
CS1110 Nate Brunelle Today: Strings, Type Casting

2 PAs, OHs

3 Questions?

4 Last Time Values, types, operators

5 Values A “thing” Every value has a type

6 Values and Types (not exhaustive)
Operators -50 ,0 ,5, 30, 512 int 3+7, 3*7, 3-7, 3/7 0.5, 1.2, float +, *, -, / ‘hi’, “hi”, ‘hello world! ’ str +, *int print, input function print()

7 Both types of quotes in a string
Use concatenation (+) Break up the string so that each piece only had one kind of quote Use escape sequences Triple-quoted strings (‘’’, ”””)

8 How to write strings “”” ‘’’

9 Escape Sequence Format: \?
Says “the normal rule should not apply to this character = ?” \’ I really mean the single quote character \” \\ I really mean the backslash character \n The newline character

10 Casting “Reshape” a value of one type to become another type:
Functions for casting: General: {type name}(value) int(‘7’) -> the int 7 str(7) -> the str ‘7’ float(‘7.0’)-> the float 7.0 type(value) gives the type of the value


Download ppt "Nate Brunelle Today: Strings, Type Casting"

Similar presentations


Ads by Google