Types

Overview

Data Types

print("Hello, World!")

Object Type

age = 27
age_greeting = "My age is "        
age_output = age_greeting + age

print(nameOutput)
My age is 27

Variable Initialization

Why is Type relevant?

Notable Object Behaviors

.toString()

age_as_integer = 27
age_as_string = age_as_integer.toString()

.equals()

age_as_integer = 27
age_as_string = str(age_as_integer)
are_objects_equal = age_as_integer.equals(age_as_string)

What is Casting?

How to Cast

age_as_string = "27"
age_as_integer = int(age_as_string)
age_as_integer_type = type(age_as_integer)
age_as_string_type = type(age_as_string)

print(age_as_integer_type)
print(age_as_string_type)
is_name_leon = "true"
age_as_integer_type = type(age_as_integer)
age_as_string_type = type(age_as_string)

print(age_as_integer_type)
print(age_as_string_type)
nameAsObject = object("Leon Hunter")
nameAsString = str(nameAsObject)

More Casting examples

 ageAsInteger = int("27")
isMaleBoolean = bool("true")
nameAsString = str("Leon Hunter")