-
Notifications
You must be signed in to change notification settings - Fork 0
Chapter 2
Jarlin Almanzar edited this page Oct 22, 2019
·
16 revisions
Contain
- Only letters
- Only numbers
- Only underscores
- Can start with an underscore or letters, not numbers
Can't Contain
- spaces
- keywords
- function names
Variables are labels for values variable_name = variable_value
Strings
A series of characters
Anything inside "this" or 'this' is considered a string
" " allow for for quotes and apostrophes , while '' does not
f" " Allows us to insert a variable into a string, called f-strings
f being for format, b/c Python formats the string by replacing the name of any variable in brace
#variable
message = "Hello World"
print(message)
# title() => changes each word to title case, where each word begins with a capital letter
message = "hello world"
print(message.title())
# upper() => changes each character to be capitalized
# lower() => changes each character to be lower case
message = "hello world"
print(message.upper())
print(message.lower())
first_name = "Ava"
last_name = "Montecristo"
full_name = f"{first_name} {last_name}"
print(f"Hello, {full_name.title()}!")