Variables, Asssignments, and Data Abstractions
Whats a Variable?
Variables hold data in the the code. Types of variables:
- ints
- string
- floats
- doubles
- boulen
Dont make too comlex because it would be to hard to read keep it in a consitant format that you can reconize easly. No spaces!
Int whole numbers x = 1
Floats decimal numbers to a limit x = 1.0001
doubles unlimited decimals in a number x = 1.0000000000000000000000000000000001
string Is just a word x = “Yo” or x = ‘yo’
boulien True or False x = True
list A list can be used to make variables more easy to format and store in your code as well as better use of them. x = [“y”, “k”, “o”]
Asingments Alows you to change a variable in a code.
Data Abstraction used to represnt data in a useful form
- List
- Eliments
- Index
- String
List is the whole thing eliments value in a string Index the place of a eliment in a list starts at 0
How To add Elements to a List in Python append() : append the element to the end of the list. insert() : inserts the element before the given index. extend() : extends the list by appending elements from the iterable. List Concatenation: We can use the + operator to concatenate multiple lists and create a new list.
managing complexity makes it better to read update and convert the data.
colorlist=[“green”, “red”, “pink”, “purple”, “blue”, “brown”]
for i in colorlist: print(i)