Professional Documents
Culture Documents
Variables in Python
Variables in Python
Kelechi
We are about making Bold Statements
in Bold Prints.
-
items_in_cart = 1
I use variables so I
dont have to write
each one by hand
product
3products
title
$price
number
@thisplace
_price
!discount
product_3
product-3
x4
price$
a_long_variable_name
product title
Programming Style
lowercase_with_words_separated_by_underscores
OK Variable Names:
producttitle
product_title
Title
title
itemPrice
item_price
aMount
amount
Variable Values
I use
variables by
setting them
to a value
Numbers:
items_in_cart = 3
Booleans:
paid = True
items_in_cart = 0
items_in_cart = 1
items_in_cart will only show 1
total_items = total_items + 1
Why does this work?
Right to Left
total_items = total_items + 1
More practice!
product_price = 129.00
product_price = 30.00
More practice!
product_price = 129.00
product_price = product_price - 70
product_price = product_price - 70
product_price -= 70