
Class Notes Day 1
A basic over view of variable types. I haven't even installed Python yet and my brain is so tired.
I'm trying my best not to skip ahead and follow everything in order, but haveing programmed in FORTRAN, COBAL, PHP, JavaScript, LightScript, BasicA, QBasic, Visual Basic and others... the first few days are going to be like pulling teeth.
Overall, Python seems a lot easier than most of the other languages I've scrambled through (looking at you, C#) and it's easy see why it is getting so popular.
I'm not sure if I'll drop jQuery for Python, but PHP needs to watch its back.
01.py
# -- Math stuff
# int and float
a = input('Gimme a number: ')
b = input('Gimme a better number: ')
a,b = int(a),int(b) #convert into number
def pFun( mf ):
print (f'{mf} : {type(mf)}' ) # formated string
pFun (a ** b) # to the power of
pFun (a / b) # simple division
pFun (a // b) # divide and round
pFun (a % b) # divide and show remainder
print ('----------')
pFun (a - b)
pFun (abs(a - b)) # return absolute value
print ('----------')
c = bin(a * b) # binary valuse
pFun ( c )
pFun (int( c ,2 )) # turn binary to int
print ('----- Strings -----')
smStr = 'abcdefghijklmnopqrstuv'
pFun( smStr[3] ) # index at
pFun( smStr[20:] ) # start till done
pFun( smStr[:5] ) # start till index
pFun( smStr[12:18] ) # start, end
pFun( smStr[0:26:3] ) # start, end, skip every
lgStr = '''burger time
fun time
run time '''
pFun(lgStr)
pFun(len(lgStr)) # length
pFun(lgStr.upper()) # uppercase
pFun(lgStr.replace('time','butts')) # replace