Last Time (§§ 4,5)
There are three sequence types.
- lists: a mutable heterogeneous sequence type
- tuples: an immutable heterogeneous sequence type
- strings: an immutable sequence of characters
We also learned about the Python documentation and the builtin functions and types pages.
§§ 11-13 discuss pooling, aliasing and the "pointing relationship" that has been a theme in class. Reading these will clarify a lot for you.
Truthy, Falsy and None
An object is truthy if when it is cast to a boolean,
the result is True
.
An object is falsy if when it is cast to a boolean,
the result is True
.
None
is Python's graveyard type.
None
is falsy.
Comments
print
and its Many Powers (§ 8)
# what does this do?
# this is the comment token
# python ignores everything from it to the end of the line.
print("Hello")
print(1,2,3, True, "cows", [1,2,3])
print(1,2,3, True, "cows", [1,2,3], sep = " * ")
print(1,2,3, True, "cows", [1,2,3], sep = "|")
print(1,2,3, True, "cows", [1,2,3], end = "FOO")
print("a", end="")
print("b", end="")
print("a", end="")
print("c", end="")
print("d", end="")
The Symbol Table and Expressions (§ 9)
When you create a variable you write on the symbol table.
* ** *** **** ***** ******
#thinnk of two ways or more that you can make
#the little triangle of stars
#Riley
for i in range(7):
print("*" * i)
# Chris A
print('\n'.join(['*'*i for i in range(1, 7)]))
#Al Pagar
star = "*"
for i in range(6):
print(star)
star = star + "*"
#Ari E
print('*','**','***','****','*****','******', sep ='\n')
print("*")
print("**")
print("***")
print("****")
print("*****")
print("******")
print('''*
**
***
****
*****
******''')
print("*\n**\n***\n****\n*****\n******")
* * * * * * * * * * * * * * * * * * * * * * * * *#Ari E print(''' * * * * * * * * * * * * * * * * * * * * * * * * *''') for i in range(1,7): print(' '*(7-i), ' ', ('* '*i)) for i in range(1, 3): print(' '*7, '* *') for i in range(1, 9): if i > 6: print(f'{"* *":^30}') else: spaced = ('* '*i).strip() print(f'{spaced:^30}') print(" *\n * *\n * * *\n * * * *\n * * * * *\n * * * * * *\n* * * * * * * \n * *\n * *")