Numbers
Integer = Number
Float = Decimal Number
Code Example:
Integer:
answer = 42
Float:
pi = 3.14159
Complex Number (Python 3):
Easy TypeCast
int(pi) == 3
float(answer) == 42.0
String:
Python 2: ASCII
Python 3: Unicode
String Can be defined using:
'Jello World' = "Jello World" = """Jello World """
Example:
"hello.capatalize() == "Hello"
"hello".replace("e" , "a") == "Hallo"
"hello".isalpha() == True
"123".isdigit()== True #Useful when converting to Int
Advanced
"Some, csv, values".split(",") = ["some","csv","values"]
String Format
name = "PythonGo"
Machine = 'BAL"
"Great meeting you {0}. I am {1}".format(name,machine)
Python 3.6
String Interpolation:
f"Great meeting you {name}. I am {machine}
Boolean and None:
python_book = True
java_book = False
Used often with If Statement
Note - Both Start with Capital Letter T and Capital F
int(python_book) == 1
int(java_book)==0
ste(python_book) == "True"
aliens_found= None
Integer = Number
Float = Decimal Number
Code Example:
Integer:
answer = 42
Float:
pi = 3.14159
Complex Number (Python 3):
Easy TypeCast
int(pi) == 3
float(answer) == 42.0
String:
Python 2: ASCII
Python 3: Unicode
String Can be defined using:
'Jello World' = "Jello World" = """Jello World """
Example:
"hello.capatalize() == "Hello"
"hello".replace("e" , "a") == "Hallo"
"hello".isalpha() == True
"123".isdigit()== True #Useful when converting to Int
Advanced
"Some, csv, values".split(",") = ["some","csv","values"]
String Format
name = "PythonGo"
Machine = 'BAL"
"Great meeting you {0}. I am {1}".format(name,machine)
Python 3.6
String Interpolation:
f"Great meeting you {name}. I am {machine}
Boolean and None:
python_book = True
java_book = False
Used often with If Statement
Note - Both Start with Capital Letter T and Capital F
int(python_book) == 1
int(java_book)==0
ste(python_book) == "True"
aliens_found= None