Day 6
= called assignment operator |
print("3"+"4") = 34 |
print(4**2) = 16 |
Day 10
total = 0 |
set = {} --> sets can't have duplicates |
set.add() --> add element |
set.remove() - remove element |
set.update(set2) --> adds from another set |
set.union(set2) - combines 2 sets without dup |
set.intersection(set2) --> finds dups |
For Loop Names
names = ['Bob', 'Kat', 'Ray']
for each_name in names:
\tab print(each_name)
--------------
Rob
Kat
Ray
|
|
|
Day 7
len(name) --> # of char |
name.capitalize() --> cap first letter |
name.title() --> cap first each word |
name.upper() --> entire string cap |
name.strip() --> removes lead/trail space |
name.replace('','') --> 'with what' 'replacing' |
intput() --> user input |
name = "Mary", name[0:3] = Mar |
Day 11
dictionary = {'name': 'Mary'} --> key/value pairs |
print(dictionary['name']) = Mary |
dictionary['age'] = 21 --> adds a new key/value pair to exist dic |
list.append(dictionary) --> add dictionaries to list |
dictionary.pop(' ') --> remove a key/value |
Function Multiple Paramater
def welcom(name,greeting):
\tab print(f'Hey, {name}. {greeting}.')
welcome('Liz, 'How\'s it?')
---------------
Hey, Liz. How's it?
|
|
|
Day 8
phrase.partition() = splits into three parts of " " |
phrase.split(' ') = splits into as many words |
tuple = () --> can't be changed |
list = [] --> modified |
list --> tuple name = list(tuple) |
name.append() = adds to end of list |
name.remove() = removes from list |
number = 2.3211 --> print(f'{number:.2f}') = 12.32 |
Day 14
def hello():
print("hi')
hello()
------
hi
|
Day 14
def hello():
\tabprint("hi')
hello()
------
hi
|
Day 9
range(5) --> 5 char --> 1,2,3,4,5 |
range(1,6) --> 5 char --> 1,2,3,4,5 |
range(1,7,2) --> 1,3,5 |
range(6,0,-1) --> 6,5,3,3,2,1 |
i = index/everything |
\t = adds a tab before text |
|