Take a look at some of the little things that have been recorded in Head first Python this time, just a few of them, and add them later if necessary.
For loop use:
For target identifier in list:Working with Code
Use of the IF statement:
If a condition is met:true GroupElse:false Group
Len () bif provides the length of a data object, or the number of items in a collection.
Isinstance () BIF checks whether an identifier is a specified type.
Using optional Parameters: Def print_lol (the_list, level = 0)
Some code is attached below:
#Code of open filedefget_coach_data (filename):Try: with open (filename) as F:data=f.readline () temp= Data.strip (). Split (',') return(athletelist (temp.pop (0), Temp.pop (0), temp)exceptIOError as E:Print('File Error:'+str (e))return(None)
# code with great style def top3 (self): return for in self]) [0:3])
#demo of PickleImportPickleTry: With open ("Data.pickle",'WB') as Mysavedata:pickle.dump ([1, 2,'three'], Mysavedata)exceptPickle. Pickleerror as E:Print('File Error:'+ str (e))
# demo of Class class athletelist (list): __init__ (Self, a_name, A_dob = None, a_times = []): = a_name = a_dob self.extend (a_times) def top3 (self): return for with self]) [0:3])
Head First Python Reading notes