,Book,Codesnippet,Codetype,Page,Code,Correctness 7071,"Think Python, 2nd Edition",x = math.sin(degrees / 360.0 * 2 * math.pi),simpleAssign,23,Yes,Yes 2497,"Think Python, 2nd Edition",for c in s:,forsimple,96,Yes,Yes 96,"Learning Python, 5th Edition",self.acct = value,simpleattr,1260,Yes,Yes 12272,"Learning Python, 5th Edition",class M(type):,simpleclass,1381,Yes,Yes 28234,Python for Kids,"starts = [-3, -2, -1, 1, 2, 3]",simpleList,203,Yes,Yes 3254,"Learning Python, 5th Edition",import sys,importfunc,695,Yes,Yes 17339,Python Projects for Kids,print(first_number + second_number),printfunc,21,Yes,Yes 1487,"A python book Beginning python, advanced python, and python exercises",def test(names):,simplefunc,257,Yes,Yes 25089,"Learning Python, 5th Edition",acctlen = 8 # Class data,simpleAssign,1257,Yes,Yes 29515,"Learning Python, 5th Edition","localfile = open(filename, 'wb')",openfunc,1506,Yes,Yes 19331,Python Crash Course,u >>> favorite_language = favorite_language.rstrip(),simpleAssign,27,Yes,Yes 23757,"Learning Python, 5th Edition","print(X, end=' ')",printfunc,610,Yes,Yes 28905,Programming in Python 3- a complete introduction to the Python language,import test_Atomic,importfunc,427,Yes,Yes 6803,Python 3 for Absolute Beginners,"time obj = datetime.datetime.strptime(guess, ""%d %b %Y, %H:%M"")",simpleAssign,257,Yes,Yes 26057,Python Crash Course,"bicycles = ['trek', 'cannondale', 'redline', 'specialized']",simpleList,38,Yes,Yes 22022,"Learning Python, 5th Edition",return onCall,return,1303,Yes,Yes 26758,Python Crash Course,return full_name.title(),return,142,Yes,Yes 26711,"Core Python Programming, Second Edition (2006)",data = [line.strip() for line in f.readlines()],simpleListComp,335,Yes,Yes 15709,2019 Book A Beginner's Guide To Python 3 Program,return a value from a function. In Python this can be,return,115,No,No 17102,"A python book Beginning python, advanced python, and python exercises","@trace('tracing func2') def",decaratorfunc,228,Yes,Yes 12487,Programming in Python 3- a complete introduction to the Python language,"b = [""Retention"", 3, None]",simpleList,21,Yes,Yes 22225,Programming in Python 3- a complete introduction to the Python language,"NEW_REGISTRATION=( lambda self, *args: self.new_registration(*args))",simpleTuple,464,Yes,Yes 22265,"Learning Python, 5th Edition","print(open('temp2', 'rb').read())",openfunc,366,Yes,Yes 25419,Python 3 for Absolute Beginners,"output file = open(outfile name,'w')",openfunc,277,Yes,Yes 10709,Programming in Python 3- a complete introduction to the Python language,"@abc.abstractmethod def",decaratorfunc,382,Yes,Yes 6341,Making Use of Python,def my_method_example(self):,simplefunc,166,Yes,Yes 25087,Python 3 for Absolute Beginners,self. gender = 'neuter',simpleattr,203,Yes,Yes 20146,Python 3 for Absolute Beginners,"return int(damage), int(potential damage)",return,212,Yes,Yes 29790,Making Use of Python,"8 TCP_Server_Socket = socket(AF_INET, SOCK_STREAM)",simpleAssign,276,Yes,Yes 25856,Python for Kids,return 0;,return,290,Yes,Yes 17048,"A python book Beginning python, advanced python, and python exercises",terms = [],simpleList,118,Yes,Yes 30294,"A python book Beginning python, advanced python, and python exercises",line = line.upper(),simpleAssign,20,Yes,Yes 23220,Python Crash Course,"SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')",simpleTuple,476,Yes,Yes 24149,"Learning Python, 5th Edition",B = D.copy() # Instead of B = D (ditto for sets),simpleAssign,299,Yes,Yes 4519,"A python book Beginning python, advanced python, and python exercises",In [107]: a = u'abcd',simpleAssign,18,Yes,Yes 9687,Python Crash Course,u if len(aliens) == 0:,simpleAssign,282,Yes,No 11368,"Think Python, 2nd Edition",def random_word(h):,simplefunc,157,Yes,Yes 23077,Python Crash Course,bullets = Group(),simpleAssign,270,Yes,Yes 10405,"Learning Python, 5th Edition","class Person: ...same... class Manager(Person):",inheritclass,838,Yes,Yes 2518,2019 Book A Beginner's Guide To Python 3 Program,print('James' == 'James'),printfunc,38,Yes,Yes 25645,"Core Python Programming, Second Edition (2006)",return True,return,32,Yes,Yes 23810,"Learning Python, 5th Edition","return the new client class. Therefore, they are often used for managing or augmenting",return,1359,No,No 28009,2019 Book A Beginner's Guide To Python 3 Program,import a,importfunc,282,No,No 10235,Programming in Python 3- a complete introduction to the Python language,total = 0,simpleAssign,152,Yes,Yes 4794,Programming in Python 3- a complete introduction to the Python language,if not director:,simpleif,478,Yes,Yes 12214,2019 Book A Beginner's Guide To Python 3 Program,def display(self):,simplefunc,290,Yes,Yes 28720,Making Use of Python,def displayError(self):,simplefunc,336,Yes,Yes 21848,"Core Python Programming, Second Edition (2006)",import hooks,importfunc,495,Yes,Yes 23319,"A python book Beginning python, advanced python, and python exercises","self.tokenType, self.token, self.lineNo = \",simpleattr,128,Yes,Yes 4220,Programming in Python 3- a complete introduction to the Python language,"def __int__(self): return round(self.__value) def __float__(self): return self.__value The __bool__() special method converts the instance to a Boolean, so it must al- ways return either True or False. The __int__",recursivefunc,249,No,No 10944,"Learning Python, 5th Edition","print(""Number of instances created: %s"" % Spam.numInstances)",printfunc,1028,Yes,Yes 22134,"Learning Python, 5th Edition",def __init__(self),__init__,1250,Yes,Yes 16665,Python Crash Course,u score_str = str(self.stats.score),simpleAssign,302,Yes,Yes 25214,"Learning Python, 5th Edition","for (a, b, c) in [(1, 2, 3), (4, 5, 6)]:",fortuplename,348,Yes,Yes 31196,Head First Python,print(),printfunc,126,Yes,Yes 3219,"Core Python Programming, Second Edition (2006)",int(12.34) = 12,simpleAssign,444,Yes,No 23528,Making Use of Python,C=Cookie.Cookie(),simpleAssign,332,Yes,Yes 18917,"Learning Python, 5th Edition",self.name = name # These trigger __set__ calls too!,simpleattr,1262,Yes,Yes 19165,"Learning Python, 5th Edition","print(fact0(6), fact1(6), fact2(6), fact3(6), fact4(6))",printfunc,1484,Yes,Yes 16747,Programming in Python 3- a complete introduction to the Python language,"LEFT_ALIGN_PNG = b""""""\",simpleAssign,217,Yes,Yes 5485,Programming in Python 3- a complete introduction to the Python language,"return math.hypot(self.x, self.y)",return,236,Yes,Yes 23725,Programming in Python 3- a complete introduction to the Python language,if c in left_for_right:,simpleif,201,Yes,Yes 3703,"Learning Python, 5th Edition",print(x * 3),printfunc,1491,Yes,Yes 2980,"Learning Python, 5th Edition","def __init__(self, acct, name, age, addr)",__init__,1265,Yes,Yes 9655,Python for Kids,x = 1,simpleAssign,69,Yes,Yes 29161,"Core Python Programming, Second Edition (2006)",14 ss = xl.Workbooks.Add(),simpleAssign,959,Yes,Yes 29477,Python 3 for Absolute Beginners,vel min = velocity,simpleAssign,97,Yes,Yes 31039,Making Use of Python,"the __init__()",__init__,167,No,No 7092,Programming in Python 3- a complete introduction to the Python language,return abs(self.distance_from_origin - self.radius),return,243,Yes,Yes 12432,Head First Python,import athletemodel,importfunc,339,Yes,Yes 20071,Python Crash Course,return long_name.title(),return,179,Yes,Yes 19774,Head First Python,connection = sqlite3.connect('coachdata.sqlite'),simpleAssign,320,Yes,Yes 21766,Python for Kids,print('Try lower'),printfunc,134,Yes,Yes 7653,"Core Python Programming, Second Edition (2006)","key=name, value=earth",simpleAssign,255,Yes,Yes 30718,Python for Kids,return True at x.,return,240,Yes,Yes 3063,2019 Book A Beginner's Guide To Python 3 Program,print(self.board),printfunc,413,Yes,Yes 12293,Python 3 for Absolute Beginners,"fruits = ['avocados', 'bananas', 'oranges', 'grapes', 'mangos']",simpleList,76,Yes,Yes 24621,Programming in Python 3- a complete introduction to the Python language,def run(self):,simplefunc,445,Yes,Yes 10261,"Core Python Programming, Second Edition (2006)",return count,return,533,Yes,Yes 8270,Python 3 for Absolute Beginners,while True:,whilesimple,67,Yes,Yes 28970,"Think Python, 2nd Edition",t = list(s),simpleAssign,113,Yes,Yes 17897,"A python book Beginning python, advanced python, and python exercises",gen = genTokens(infile),simpleAssign,119,Yes,Yes 21618,2019 Book A Beginner's Guide To Python 3 Program,"Great Pretender', year=1987))",simpleAssign,44,Yes,Yes 23407,Python 3 for Absolute Beginners,"print(""You enter the"", self.name)",printfunc,212,Yes,Yes 30289,Programming in Python 3- a complete introduction to the Python language,return fake objects—third-party modules that provide,return,423,No,No 14105,"Learning Python, 5th Edition",print(X),printfunc,874,Yes,Yes 26913,2019 Book A Beginner's Guide To Python 3 Program,"p1 = Person('Jason', 36)",simpleAssign,197,Yes,Yes 29191,2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,210,Yes,Yes 12868,Python 3 for Absolute Beginners,"from a module, you can use one of two Python constructs. import modulename",importfromsimple,244,No,No 13640,Programming in Python 3- a complete introduction to the Python language,def __repr__(self):,simplefunc,239,Yes,Yes 499,2019 Book A Beginner's Guide To Python 3 Program,print(b2.name),printfunc,312,Yes,Yes 24184,Making Use of Python,import qty_mod,importfunc,139,Yes,Yes 14129,"A python book Beginning python, advanced python, and python exercises",for item in child:,forsimple,134,Yes,Yes 14926,"Think Python, 2nd Edition",print(pair),printfunc,143,Yes,Yes 21417,"Core Python Programming, Second Edition (2006)","class C(P): def __init__(self): super(C, self).__init__() print ""calling C's constructor"" The nice thing about using super() is that you do not need to give any base class name explicitly... it does all the legwork for you! The importance of using super() is that you are not explicitly specifying the parent class. This means that if you change the class hierarchy, you only need to change one line (the class statement itself) rather than tracking through what could be a large amount of code in a class to find all mentions of what is now the old class name. 13.11.3. Deriving Standard Types Not being able to subclass a standard data type was one of the most significant problems of classic classes. Fortunately that was remedied back in 2.2 with the unification of types and classes and the introduction of new-style classes. Below we present two examples of subclassing a Python type, one mutable and the other not. Immutable Type Example Let us assume you wanted to work on a subclass of floating point numbers to be used for financial applications. Any time you get a monetary value (as a float), you always want to round evenly to two decimal places. (Yes, the Decimal class is a better solution than standard floats to accurately store floating point values, but you still need to round them [occasionally] to two digits!) The beginnings of your class can look like this: class RoundFloat(float): def __new__(cls, val):",metaclass3,555,No,No 10981,2019 Book A Beginner's Guide To Python 3 Program,"r4 = list(itertools.islice(values, 3, 6))",simpleAssign,387,Yes,Yes 25267,Head First Python,"def status_update(msg, how_long=2):",funcdefault,282,Yes,Yes 13295,2019 Book A Beginner's Guide To Python 3 Program,print('Welcome to TicTacToe'),printfunc,413,Yes,Yes 8721,Programming in Python 3- a complete introduction to the Python language,print(data[0]),printfunc,457,Yes,Yes 20577,"Core Python Programming, Second Edition (2006)","one variable. When foo2 = foo1 occurs, foo2 is directed to the same object as foo1 since Python deals",simpleAssign,101,No,No 29612,Python Crash Course,print(answer),printfunc,201,Yes,Yes 14833,Head First Python,"julie = data.strip().split(',')",simpleAssign,152,Yes,Yes 16670,"Learning Python, 5th Edition","return values that you might be interested in retaining, you can call these functions with",return,356,No,No 19548,"Learning Python, 5th Edition","def __init__(self, *args, **kargs)",__init__,1319,Yes,Yes 14627,2019 Book A Beginner's Guide To Python 3 Program,"print('calling ', func.__name__)",printfunc,333,Yes,Yes 5853,"Core Python Programming, Second Edition (2006)",13 ppoint = win32.gencache.EnsureDispatch('%s.Application' % app),simpleAssign,963,No,No 24172,"Learning Python, 5th Edition",def __get__(*args): print('get'),privatemethod,1229,Yes,No 17977,"Learning Python, 5th Edition","as well as in an augmented assignment (a += [1, 2]",simpleList,464,No,No 8651,Python Crash Course,"print(""Python"")",printfunc,26,Yes,Yes 7912,"Learning Python, 5th Edition",def func():,simplefunc,623,Yes,Yes 21175,Python Projects for Kids,print(9),printfunc,53,Yes,Yes 28342,"Core Python Programming, Second Edition (2006)","range(1,5))",rangefunc,915,Yes,Yes 17813,Programming in Python 3- a complete introduction to the Python language,self=self.__class__,__class__,257,Yes,Yes 9154,Python 3 for Absolute Beginners,"test phrase = profile['Name'] + "" buys themself some equipment""",assignwithSum,112,Yes,Yes 5040,Programming in Python 3- a complete introduction to the Python language,x = None,simpleAssign,93,Yes,Yes 13416,"Learning Python, 5th Edition",print('finally run'),printfunc,1105,Yes,Yes 22953,"Learning Python, 5th Edition",print(I.X),printfunc,874,Yes,Yes 1288,Python for Kids,import i_am_a_python_module_that_is_not_very_useful,importfunc,294,Yes,Yes 7753,"Learning Python, 5th Edition",fout.write(line.upper()),write,1119,Yes,Yes 1227,"Learning Python, 5th Edition",print(item * 3),printfunc,165,Yes,Yes 30173,Making Use of Python,"6 ServerAddress = (Hostname, PortNumber)",simpleTuple,275,Yes,Yes 13514,"Learning Python, 5th Edition","def __add__(self, other): return self.__wrapped + other # Or getattr(x, '__add__",recursivefunc,1324,Yes,No 2638,"Learning Python, 5th Edition",U = S.encode('utf-8') # 7 bytes when encoded as utf-8,simpleAssign,1200,Yes,Yes 24624,Programming in Python 3- a complete introduction to the Python language,"equation = (""{0}x\N{SUPERSCRIPT TWO} + {1}x + {2} = 0""",simpleAssign,94,Yes,Yes 15395,Python for Kids,"if self.x > 0: if self.y != 0:",simpleif,264,Yes,Yes 14689,"A python book Beginning python, advanced python, and python exercises",content = tmp_file.read(),read,33,Yes,Yes 27000,"Learning Python, 5th Edition",c = spam.Spam(),simpleAssign,1027,Yes,Yes 2744,"A python book Beginning python, advanced python, and python exercises",Other ways of reading from a file/stream object: my_file.read(),read,70,No,No 13952,"A python book Beginning python, advanced python, and python exercises",for url in url_list:,forsimple,213,Yes,Yes 8135,"Learning Python, 5th Edition",self.subject = Parrot(),simpleattr,1497,Yes,Yes 2874,"Core Python Programming, Second Edition (2006)",return true if the membership is confirmed and False otherwise.,return,159,No,No 11282,Python 3 for Absolute Beginners,purchase = input('Would you like to buy some equipment? '),simpleAssign,95,Yes,Yes 16657,"Core Python Programming, Second Edition (2006)",7 self.data = seq,simpleAssign,577,Yes,No 1092,Programming in Python 3- a complete introduction to the Python language,"name = re.sub(r""(\w+(?:\s+\w+)*)\s+(\w+)"", r""\2, \1"", name)",assignwithSum,501,Yes,No 14653,"Learning Python, 5th Edition",allsizes = [],simpleList,1499,Yes,Yes 8925,"Core Python Programming, Second Edition (2006)",for eachLine in data:,forsimple,654,Yes,Yes 11315,"Think Python, 2nd Edition",for c in s:,forsimple,96,Yes,Yes 17963,"Think Python, 2nd Edition",return res,return,132,Yes,Yes 15162,Python Crash Course,u if age >= 18:,simpleAssign,83,Yes,No 15098,Python Crash Course,def run_game():,simplefunc,268,Yes,Yes 19612,"Think Python, 2nd Edition",def example3():,simplefunc,134,Yes,Yes 6863,Programming in Python 3- a complete introduction to the Python language,if i == -1:,simpleif,74,Yes,Yes 9731,Python Crash Course,username = get_stored_username(),simpleAssign,213,Yes,Yes 19779,"Learning Python, 5th Edition","open('temp', 'rb').read()",read,1199,Yes,Yes 21275,"Core Python Programming, Second Edition (2006)",Function composition in math is defined like this: (g · f)(x) = g(f(x)). For consistency in Python:,simpleAssign,430,No,No 26097,"A python book Beginning python, advanced python, and python exercises",anObj = MyClass(),simpleAssign,29,Yes,Yes 17668,Making Use of Python,return an error after the connection is closed.,return,257,No,No 1188,"Learning Python, 5th Edition",self.name = name # These trigger __set__ calls too!,simpleattr,1260,Yes,Yes 22437,Python 3 for Absolute Beginners,"print(""You need"", round(total length, 2), ""meters of cloth for "", round(price, 2))",printfunc,60,Yes,Yes 3643,Making Use of Python,return multiple values by using a return statement? You can do this by using a tuple,return,109,No,No 20795,"Learning Python, 5th Edition","open('temp.txt', 'r').read()",read,1203,Yes,Yes 11180,"Learning Python, 5th Edition","while True: reply = input('Enter text:') if reply == 'stop': break elif not reply.isdigit(): print('Bad!' * 8) else:",whileelse,332,Yes,Yes 19746,"Learning Python, 5th Edition",for srcdir in sys.path:,forsimple,1500,Yes,Yes 5584,Python Crash Course,"if len(aliens) == 0: # Destroy existing bullets, speed up game, and create new fleet.",simpleif,300,Yes,Yes 10575,"Core Python Programming, Second Edition (2006)","return the original one as well, we need a string to reverse, so the best candidate is just a copy",return,939,No,No 19898,"Core Python Programming, Second Edition (2006)","39 sh.Cells(row, 3).Value = chg",simpleAssign,968,Yes,Yes 1441,"A python book Beginning python, advanced python, and python exercises","opts, args = getopt.getopt(args, 'h', ['help'])",simpleAssign,74,Yes,Yes 4968,"Core Python Programming, Second Edition (2006)",return global_str + local_str,return,460,Yes,Yes 3208,"Learning Python, 5th Edition",Namespace Dictionaries: __dict__,__dict__,696,No,No 16595,Programming in Python 3- a complete introduction to the Python language,cursor = db.cursor(),simpleAssign,479,Yes,Yes 20509,"Learning Python, 5th Edition",class GetAttribute(object):,simpleclass,1245,Yes,Yes 17854,Python Crash Course,alien.x = alien_width + 2 * alien_width * alien_number,assignwithSum,271,Yes,Yes 5532,"Think Python, 2nd Edition",return sum,return,188,Yes,Yes 19973,Programming in Python 3- a complete introduction to the Python language,return object.__repr__(self),return,278,Yes,Yes 5472,"Core Python Programming, Second Edition (2006)",from sys import maxint,importfromsimple,689,Yes,Yes 19691,"Learning Python, 5th Edition","a, b, c = Spam(), Spam(), Spam()",simpleAssign,1028,Yes,Yes 30931,Head First Python,for t in sarah_data[‘Times’]]))[0:,forsimple,182,Yes,Yes 12704,"Core Python Programming, Second Edition (2006)","10 fac_list = range(1, num_num+1)",assignwithSum,248,Yes,No 12024,Python 3 for Absolute Beginners,change type = 7,simpleAssign,98,Yes,Yes 16397,"Learning Python, 5th Edition","func(name='Bob', age=40, job='dev')",simpleAssign,533,Yes,No 8037,"Learning Python, 5th Edition",import sys,importfunc,369,Yes,Yes 24677,"Learning Python, 5th Edition",found = False,simpleAssign,467,Yes,Yes 27597,Python 3 for Absolute Beginners,"print(dave, '\t', fred, '\t', pete)",printfunc,106,Yes,Yes 25705,"Core Python Programming, Second Edition (2006)",def f1():,simplefunc,464,Yes,Yes 30652,"Learning Python, 5th Edition",sorted(L1) == sorted(L2) # Similar but results ordered,simpleAssign,170,Yes,Yes 3518,"Core Python Programming, Second Edition (2006)",return (shallow) copy of,return,284,No,No 27296,Python Crash Course,import csv,importfunc,353,Yes,Yes 11309,2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name)",__init__,316,Yes,Yes 2885,"Learning Python, 5th Edition","print(mymap(pow, [1, 2, 3], [2, 3, 4, 5]))",printfunc,618,Yes,Yes 28518,"Core Python Programming, Second Edition (2006)",86 <FORM><INPUT TYPE=button VALUE=Back,simpleAssign,878,No,No 22568,"Learning Python, 5th Edition","func(*(1, 2), **{'d': 4, 'c': 3}) # Same as func(1, 2, d=4, c=3)",simpleAssign,536,No,No 11817,Python 3 for Absolute Beginners,import strings,importfunc,242,Yes,Yes 4749,"A python book Beginning python, advanced python, and python exercises","if len(args) != 0: usage()",simpleif,74,Yes,Yes 31065,2019 Book A Beginner's Guide To Python 3 Program,"if isinstance(other, int): else:",simpleif,236,Yes,No 12637,"Learning Python, 5th Edition",from . import mod2,fromrelative,738,Yes,Yes 11654,Programming in Python 3- a complete introduction to the Python language,"def print_args(*args, **kwargs):",funcwith2star,177,Yes,Yes 17318,2019 Book A Beginner's Guide To Python 3 Program,self.y = y,simpleattr,328,Yes,Yes 14107,Python 3 for Absolute Beginners,print(),printfunc,234,Yes,Yes 4372,Python for Kids,self.tk = Tk(),simpleattr,234,Yes,Yes 7565,"A python book Beginning python, advanced python, and python exercises","extent = (width1, height1)",simpleTuple,101,Yes,Yes 27351,Python for Kids,top = False,simpleAssign,281,Yes,Yes 22515,Python for Kids,self.current_image_add = -1,simpleattr,261,Yes,Yes 17238,Programming in Python 3- a complete introduction to the Python language,"return dir = (os.path.dirname(self.filename)",return,582,No,No 26354,"A python book Beginning python, advanced python, and python exercises","self.tokens = genTokens(self.infile, infileName)",simpleattr,127,Yes,Yes 6663,Programming in Python 3- a complete introduction to the Python language,bike = _bike_from_record(record),simpleAssign,331,Yes,Yes 6148,Python Crash Course,import the,importfunc,180,No,No 20820,2019 Book A Beginner's Guide To Python 3 Program,class DivideByYWhenZeroException(Exception):,simpleclass,265,Yes,Yes 10387,"Learning Python, 5th Edition","def mymap(func, *seqs):",funcwithstar,617,Yes,Yes 16248,Programming in Python 3- a complete introduction to the Python language,for writing out the incidents in XML:,forsimple,316,No,No 29507,Python Crash Course,"if pop_dict['Year'] == '2010': country = pop_dict['Country Name']",simpleif,369,Yes,Yes 21755,Head First Python,resp = app.dialogGetResponse().result,simpleAssign,280,Yes,Yes 14962,"Learning Python, 5th Edition",import recur1,importfunc,776,Yes,Yes 1109,"A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,33,Yes,Yes 3769,"A python book Beginning python, advanced python, and python exercises","n2 = Animal('raven', 'black')",simpleAssign,217,Yes,Yes 6870,"A python book Beginning python, advanced python, and python exercises",return contentstr,return,67,Yes,Yes 27422,"Core Python Programming, Second Edition (2006)","dict6 = {'abc': 123, 98.6: 37}",simpleDict,258,Yes,Yes 27910,"Learning Python, 5th Edition","attr' in B.__dict__, 'attr' in A.__dict__",__dict__,1381,No,No 21989,Programming in Python 3- a complete introduction to the Python language,"user = process_line(line, usernames)",simpleAssign,147,Yes,Yes 9199,"Core Python Programming, Second Edition (2006)",def odd(n):,simplefunc,317,Yes,Yes 16507,"Learning Python, 5th Edition",import statements,importfunc,672,No,No 2622,Programming in Python 3- a complete introduction to the Python language,"for lino, line in enumerate(fh, start=2):",forsimple,519,Yes,No 9538,Programming in Python 3- a complete introduction to the Python language,enumerate(),enumfunc,136,Yes,Yes 18126,"Learning Python, 5th Edition",print(pair),printfunc,1118,Yes,Yes 23813,Python Projects for Kids,Tanvir = 1.,simpleAssign,107,Yes,Yes 3752,"Learning Python, 5th Edition",module = importlib.import_module(modname) # Import by name string,simpleAssign,765,Yes,Yes 3745,"Think Python, 2nd Edition",total += x,assignIncrement,111,Yes,Yes 5601,Python 3 for Absolute Beginners,"dict.fromkeys(iterable, value=None)",simpleAssign,285,No,No 16429,"A python book Beginning python, advanced python, and python exercises","lparen = Literal(""("")",simpleAssign,140,No,No 13134,Python 3 for Absolute Beginners,"stuff = [str(item) for item in self.inv if issubclass(type(item), Thing)]",simpleListComp,211,Yes,No 15101,"Learning Python, 5th Edition","a, b = seq[0], seq[1:] # First, rest: traditional",simpleAssign,347,Yes,Yes 19808,"A python book Beginning python, advanced python, and python exercises","if opt in ('-h', '--help'): usage()",simpleif,137,Yes,Yes 18929,Python 3 for Absolute Beginners,"return False or True. When this method is not defined, len ()",return,198,No,No 19737,"Learning Python, 5th Edition",glob.var += 1 # Change global var,assignIncrement,499,Yes,Yes 4168,Python Crash Course,"import the",importfunc,429,No,No 5236,"Learning Python, 5th Edition",from . import string,fromrelative,727,Yes,Yes 13725,Python Crash Course,stats.score += ai_settings.alien_points * len(aliens),assignIncrement,309,Yes,Yes 28824,Making Use of Python,the __init__(),__init__,168,No,No 24865,"Core Python Programming, Second Edition (2006)",The fileArgs() function is used only by myopen() (see below),openfunc,406,No,No 23538,"Learning Python, 5th Edition","if choice in branch: ... print(branch[choice])",simpleif,374,Yes,Yes 3510,2019 Book A Beginner's Guide To Python 3 Program,"Account[567] - Phoebe, investment account = 12.45",simpleAssign,249,No,No 25513,Python for Kids,self.y = -3. But don’t try to run the game now—we,simpleattr,210,No,No 13529,2019 Book A Beginner's Guide To Python 3 Program,finished = False,simpleAssign,138,Yes,Yes 15325,"Core Python Programming, Second Edition (2006)",import feature,importfunc,501,Yes,Yes 19537,"Core Python Programming, Second Edition (2006)",Attempting to access __dict__,__dict__,540,No,No 24403,"Think Python, 2nd Edition","3 + = 3$6 does not. In chemistry H2O is a syntactically correct formula, but 2Zz is",simpleAssign,5,No,No 13592,"Learning Python, 5th Edition",return 'addboth(%s)' % self.data # As-code string,return,915,Yes,Yes 5286,Making Use of Python,course=fs[‘studcourse’].value,simpleAssign,233,Yes,Yes 5859,Programming in Python 3- a complete introduction to the Python language,"lambda x, y: x + y.",lambda,393,Yes,Yes 14791,"Learning Python, 5th Edition",from functools import reduce,importfromsimple,1484,Yes,Yes 11798,2019 Book A Beginner's Guide To Python 3 Program,"print('Modulus division 4 % 2:', 4 % 2)",printfunc,56,Yes,Yes 29578,"Learning Python, 5th Edition","stmt=""L = [1, 2, 3, 4, 5]\nM = [x + 1 for x in L]",simpleListComp,645,Yes,Yes 21190,Python for Kids,"if self.y > 0 and co.y2 >= self.game.canvas_height: self.y = 0",simpleif,280,Yes,Yes 22137,"Learning Python, 5th Edition",self.customer = Customer() # Scene is a composite,simpleattr,1497,Yes,Yes 19809,Making Use of Python,return value in sum. The,return,109,No,No 26640,2019 Book A Beginner's Guide To Python 3 Program,the __init__(),__init__,203,No,No 6625,2019 Book A Beginner's Guide To Python 3 Program,return self.name + ' is ' + str(self.age),return,210,Yes,Yes 19560,"Learning Python, 5th Edition",S = B.decode('utf-8') # Decode to Unicode text per UTF-8,simpleAssign,1184,Yes,Yes 1668,2019 Book A Beginner's Guide To Python 3 Program,print('================='),printfunc,139,Yes,Yes 17852,2019 Book A Beginner's Guide To Python 3 Program,print(px),printfunc,184,Yes,Yes 30013,"Core Python Programming, Second Edition (2006)",c.__dict__,__dict__,538,Yes,Yes 17904,"Core Python Programming, Second Edition (2006)",return value.,return,456,Yes,Yes 20381,"Think Python, 2nd Edition",more@ = 1000000,simpleAssign,12,Yes,Yes 210,Head First Python,print(deeper_item),printfunc,25,Yes,Yes 4413,Head First Python,model = hfwwgDB.Sighting,simpleAssign,371,Yes,Yes 15133,"Learning Python, 5th Edition",import string,importfunc,757,Yes,Yes 1723,2019 Book A Beginner's Guide To Python 3 Program,print('function_bang in'),printfunc,261,Yes,Yes 7136,Python for Kids,"if age == 12: print(""A pig fell in the mud!"") else:",ifelse,59,Yes,Yes 2867,Python for Kids,"print(""What did 0 say to 8?"")",printfunc,60,Yes,Yes 19634,Head First Python,print(each_item),printfunc,28,Yes,Yes 21579,Python 3 for Absolute Beginners,return view,return,211,Yes,Yes 22333,Head First Python,"print(yate.para(""The top times for this athlete are:""))",printfunc,246,Yes,Yes 3100,Python for Kids,if statement might look like this:,simpleif,111,No,No 5198,"Learning Python, 5th Edition",return lambda X: X ** N # lambda functions retain state too,return,502,Yes,No 16325,"Learning Python, 5th Edition","print(a, b, c)",printfunc,664,Yes,Yes 2561,2019 Book A Beginner's Guide To Python 3 Program,2 != 3,simpleAssign,63,Yes,No 30105,"Learning Python, 5th Edition","z1, z2, z3 = Other(), Other(), Other()",simpleAssign,1034,Yes,Yes 26528,"Think Python, 2nd Edition",return square,return,72,Yes,Yes 14959,Python Crash Course,w self.level_rect.top = self.score_rect.bottom + 10,assignwithSum,311,Yes,Yes 26743,"Learning Python, 5th Edition","rec2 = {'name': {'first': 'Sue', 'last': 'Jones'}",simpleDict,1504,Yes,No 29430,Python Crash Course,v new_topic.owner = request.user,simpleAssign,453,Yes,Yes 29663,"Learning Python, 5th Edition",class onInstance(BuiltinsMixin):,simpleclass,1347,Yes,Yes 13694,"Learning Python, 5th Edition","X, Y = TopTest(), SubTest() # Make two instances",simpleAssign,843,Yes,Yes 2683,"Learning Python, 5th Edition",X = Super(),simpleAssign,871,Yes,Yes 18992,Programming in Python 3- a complete introduction to the Python language,"equal to x as an int; e.g., math.ceil(5.4) == 6",simpleAssign,58,No,No 17115,"Learning Python, 5th Edition",res = [],simpleList,575,Yes,Yes 5160,Making Use of Python,i=1,simpleAssign,94,Yes,Yes 26099,Making Use of Python,"L1 = Label(top, text=”User Name”)",simpleAssign,351,Yes,Yes 14059,"Learning Python, 5th Edition","return values. In this specific case, we would probably be better off coding an accessor",return,498,No,No 13649,"Core Python Programming, Second Edition (2006)",import this,importfunc,412,No,No 23153,Python for Kids,print(what_i_want),printfunc,297,Yes,Yes 27314,Making Use of Python,"expression x = 7 + 3 * 6, the part 3 * 6 is evaluated first and the result 18 is added",assignwithSum,24,Yes,Yes 26808,2019 Book A Beginner's Guide To Python 3 Program,"print('project:', project)",printfunc,370,Yes,Yes 7672,Programming in Python 3- a complete introduction to the Python language,if discriminant == 0:,simpleif,94,Yes,Yes 28191,Python Crash Course,"plt.ylabel(""Square of Value"", fontsize=14)",simpleAssign,325,Yes,No 7553,"Learning Python, 5th Edition","n', 'x = 2\n'}",simpleAssign,432,No,No 21240,"Learning Python, 5th Edition",def mysum(L):,simplefunc,555,Yes,Yes 13325,"Learning Python, 5th Edition","def tracer(func, *args):",funcwithstar,1284,Yes,Yes 996,Making Use of Python,"SwFile.write(libM[1] + ‘,’)",write,186,Yes,Yes 24239,Python Crash Course,"if age: person['age'] = age",simpleif,144,Yes,Yes 27196,"Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1233,Yes,Yes 18696,Python Projects for Kids,import a,importfunc,61,Yes,Yes 928,"Learning Python, 5th Edition","zip(S1, S2))",zip,617,Yes,Yes 19948,"A python book Beginning python, advanced python, and python exercises","infile = file(infilename, 'r')",simpleAssign,142,Yes,Yes 23951,Head First Python,"try: data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) print(role, end='') print(' said: ', end='') print(line_spoken, end='') except ValueError: pass Specify the type of runtime error you are handling. data.close() except IOError: print('The data file is missing!') Of course, if an different type of runtime error occurs, it is no longer handled by your code, but at least now you’ll get to hear about it. When you are specific about the runtime errors your code handles, your programs no longer silently ignore some runtime errors. ...and it lets you avoid adding unnecessary code and logic to your programs. That works for me! Using “try/except” lets you concentrate on what your code needs to do... 102 Chapter 3",trytry,102,No,No 10887,Python Crash Course,date_added = models.DateTimeField(auto_now_add=True),simpleAssign,408,Yes,Yes 27747,"Learning Python, 5th Edition",self.addr = addr # addr is not managed,simpleattr,1265,Yes,Yes 21332,Python 3 for Absolute Beginners,import functions,importfunc,170,Yes,Yes 8904,"Learning Python, 5th Edition",self.alltime += elapsed,simpleattr,1299,Yes,Yes 10001,Programming in Python 3- a complete introduction to the Python language,return self.__width,return,362,Yes,Yes 12339,Programming in Python 3- a complete introduction to the Python language,map() with a list comprehension and filter(),map,394,No,No 28475,"Core Python Programming, Second Edition (2006)",class P(object):,simpleclass,552,Yes,Yes 16398,Head First Python,athletes = athletemodel.put_to_store(data_files),simpleAssign,339,Yes,Yes 21966,"Learning Python, 5th Edition",res = set(),simpleAssign,624,Yes,Yes 21982,Programming in Python 3- a complete introduction to the Python language,"if __name__ == ""__main__"":",__name__,203,Yes,Yes 13710,Python Crash Course,available_space_y = ai_settings.screen_height – 3 * alien_height – ship_height,simpleAssign,273,No,No 16502,"Learning Python, 5th Edition",X = yield i,simpleAssign,596,Yes,Yes 3349,"Learning Python, 5th Edition","return self.data[key] # self[i], self[i:j]",return,980,Yes,Yes 5183,"A python book Beginning python, advanced python, and python exercises","letter = Plex.Range(""AZaz"")",simpleAssign,123,Yes,Yes 3905,"Learning Python, 5th Edition","print(label, state)",printfunc,511,Yes,Yes 11621,"Learning Python, 5th Edition",self.other = value # Recurs (and might LOOP!),simpleattr,1240,Yes,Yes 1660,Python Crash Course,from django.db import models,importfromsimple,403,Yes,Yes 14625,"Learning Python, 5th Edition",return generators designed to support the,return,618,No,No 13784,Head First Python,for each_t in mikey:,forsimple,155,Yes,Yes 20835,"Learning Python, 5th Edition",import random,importfunc,1502,Yes,Yes 1122,"A python book Beginning python, advanced python, and python exercises","first_name=None, last_name=None, interest=None, category=None):",simpleAssign,263,Yes,Yes 7998,"Think Python, 2nd Edition",return set(word) <= set(available),return,228,Yes,Yes 24225,Python Crash Course,"button_clicked = play_button.rect.collidepoint(mouse_x, mouse_y)",simpleAssign,311,Yes,Yes 4282,Python Crash Course,print(message),printfunc,20,Yes,Yes 15446,"Core Python Programming, Second Edition (2006)","not a concern, then programmers could call file.readline()",readline,335,No,No 23785,"Learning Python, 5th Edition","0: 'import sys\n', 1: 'print(sys.path)\n', 2: 'x = 2\n', 3: 'print(x ** 32)\n'}",simpleAssign,432,No,No 7794,Programming in Python 3- a complete introduction to the Python language,"def factorial(x): if x <= 1: return 1 return x * factorial(x - 1) This is not an efficient solution, but it does show the two fundamental features of recursive functions. If the given number, x, is 1 or less, 1 is returned and no recursion occurs—this is the base case. But if x is greater than 1 the value returned is x * factorial",recursivefunc,349,Yes,Yes 345,Making Use of Python,import isblank_mod,importfunc,139,Yes,Yes 10612,"Learning Python, 5th Edition","print(item, end=' ')",printfunc,403,Yes,Yes 27718,"A python book Beginning python, advanced python, and python exercises",content = [],simpleList,67,Yes,Yes 14040,Python Crash Course,"import just",importfunc,156,No,No 13761,2019 Book A Beginner's Guide To Python 3 Program,return the value 1 if the number passed in is 1—this is the base case.,return,96,No,No 9722,"Learning Python, 5th Edition",print(ham(2)),printfunc,1313,Yes,Yes 4449,"A python book Beginning python, advanced python, and python exercises",In [22]: a += b,assignIncrement,190,Yes,Yes 10779,"Core Python Programming, Second Edition (2006)",The aforementioned __dict__,__dict__,528,No,No 10861,Programming in Python 3- a complete introduction to the Python language,return immediately—the context manager will ensure that the,return,460,No,No 2789,"A python book Beginning python, advanced python, and python exercises",for child in node.getchildren():,forsimple,237,Yes,Yes 3441,Head First Python,import json,importfunc,338,Yes,Yes 26238,2019 Book A Beginner's Guide To Python 3 Program,"list6 = ['Once', 'Upon', 'a', 'Time']",simpleList,359,Yes,Yes 16094,"Learning Python, 5th Edition",1. Deletion. The slice you specify to the left of the = is deleted.,simpleAssign,245,No,No 4254,"Learning Python, 5th Edition",a = 3 # It's an integer,simpleAssign,178,Yes,Yes 29182,Head First Python,head_text = headf.read(),read,228,Yes,Yes 8336,Programming in Python 3- a complete introduction to the Python language,return self.__extension,return,373,Yes,Yes 20465,"Learning Python, 5th Edition","def minmax(test, *args):",funcwithstar,750,Yes,Yes 21221,"Learning Python, 5th Edition",range(10),rangefunc,624,Yes,Yes 26207,Python Crash Course,if it does not match the quit value:,simpleif,124,No,No 11717,2019 Book A Beginner's Guide To Python 3 Program,x = 1 + 2,assignwithSum,280,Yes,Yes 2903,"Learning Python, 5th Edition","omitargs(1, 2, 3, d=11) # Bad d",simpleAssign,1335,No,No 5771,Python Crash Course,return value. The return statement takes a value,return,141,No,No 1616,"Core Python Programming, Second Edition (2006)","def __norm_cval(self, cmpres):# normalize cmp()",privatemethod,582,Yes,Yes 25451,"Learning Python, 5th Edition",itance rules. The inherited descriptor for name __class__,__class__,1227,No,No 18349,Python 3 for Absolute Beginners,"print(""You have"", profile['gold'], ""gold."")",printfunc,155,Yes,Yes 14058,Programming in Python 3- a complete introduction to the Python language,lambda *ignore: yearsScale.focus_set()),lambda,572,Yes,Yes 23553,"A python book Beginning python, advanced python, and python exercises",a.category = 25,simpleAssign,191,Yes,Yes 4469,Head First Python,for each_t in james:,forsimple,162,Yes,Yes 17891,"A python book Beginning python, advanced python, and python exercises",def upcase_names(self):,simplefunc,258,Yes,Yes 8663,"Core Python Programming, Second Edition (2006)",Section 9.2. File Built-in Functions [open() and file(),openfunc,332,No,No 15132,"Learning Python, 5th Edition",import syntax,importfunc,728,Yes,Yes 12304,"Core Python Programming, Second Edition (2006)","9 RANGE = range(3, 8)",simpleAssign,963,Yes,Yes 10671,"Learning Python, 5th Edition",def __enter__(self):,simplefunc,1116,Yes,Yes 24752,2019 Book A Beginner's Guide To Python 3 Program,"dice1 = random.randint(MIN, MAX)",simpleAssign,79,Yes,Yes 24638,"Learning Python, 5th Edition","@staticmethod def",decaratorfunc,1274,Yes,Yes 20336,"Learning Python, 5th Edition","Y = X.replace('and', 'but under no circumstances')",simpleAssign,223,Yes,Yes 9147,Python Crash Course,print(sorted(cars)),printfunc,48,Yes,Yes 10094,"Learning Python, 5th Edition",return tmp[0],return,543,Yes,Yes 31116,"Core Python Programming, Second Edition (2006)",return a loader object. The finder can also take a path for finding subpackages. The loader is,return,496,No,No 23268,Python Crash Course,with current_number += 1. (The += operator is shorthand for current_number =,assignIncrement,122,No,No 4181,"Learning Python, 5th Edition",F.read(),read,518,Yes,Yes 4641,"Learning Python, 5th Edition",self.value = value,simpleattr,922,Yes,Yes 28835,Head First Python,"try: with open('its.txt', ""w"") as data: print(""It's..."", file=data) except IOError as err:",tryexcept,120,Yes,Yes 26871,Programming in Python 3- a complete introduction to the Python language,"So when we write f = FuzzyBool(0.7), under the hood Python calls Fuzzy-",simpleAssign,254,No,No 11816,Head First Python,athlete_names = sorted(json.loads(send_to_server(web_server + get_names_cgi))),assignwithSum,343,Yes,No 8459,"Learning Python, 5th Edition",def __init__(self): print('D.__init__'); super().__init__(),privatemethod,1054,Yes,No 28637,"Learning Python, 5th Edition",showall = lambda x: [sys.stdout.write(line),write,572,Yes,Yes 821,"Learning Python, 5th Edition",print(x ** y),printfunc,1287,Yes,Yes 11393,"A python book Beginning python, advanced python, and python exercises",s1 = string.strip(s1),simpleAssign,106,Yes,Yes 28998,"Core Python Programming, Second Edition (2006)",y = (x = x + 1) # assignments not expressions!,assignwithSum,68,Yes,Yes 9994,"Learning Python, 5th Edition",w = MultiSet('spam') # String sets,simpleAssign,1495,Yes,Yes 23985,"Core Python Programming, Second Edition (2006)",c2 = C() # create another instance,simpleAssign,542,Yes,Yes 5678,Making Use of Python,"map((lambda a:a+3),[12,13,14,15,16])",map,115,Yes,Yes 1377,Programming in Python 3- a complete introduction to the Python language,"def __bisect_left(self, value)",privatemethod,269,Yes,Yes 7893,"Think Python, 2nd Edition",if two strings are equal:,simpleif,92,No,No 23541,"Learning Python, 5th Edition",self.color = color,simpleattr,923,Yes,Yes 24554,"Learning Python, 5th Edition",print('spam'),printfunc,1281,Yes,Yes 18451,"Think Python, 2nd Edition",result = n * recurse,simpleAssign,67,Yes,No 10930,"Core Python Programming, Second Edition (2006)","class RoundFloat(float): def __new__(cls, val):",metaclass3,556,Yes,Yes