| Name | |
| email | |
Question 1: What is a decorator? |
| | A function wrapper |
| | Nothing to with Python - a painter |
| | An optional parameter on a method call |
Question 2: When would you use a generator function |
| | When creating a list or tuple to a formula |
| | When stepping item by item through a large data flow |
| | Generaor functions are deprecated and should no longer be used |
Question 3: Which is a difference between old and new style classes |
| | You call the parent constructuctor via a super call in new style |
| | In old style classes, assigning an object to a new variable clones it but in the new style it copies the reference |
| | Old style classes only support inheritance to one level, but that limit is removed in new style |
| | You can only use the property() builtin on new style classes |
Question 4: Which of the following is not a valid Python variable name? |
| | abc |
| | def |
| | ghi |
| | unless |
| | until |
Question 5: Which database support is shipped with a standard Python distributon? |
| | Oracle |
| | MySQL |
| | SqLite |
| | PostGRESql |
| | CSV files at database tables |
| | None |
Question 6: Which of these will NOT add multiple objects onto an existing list? |
| | demo.append([12,14,16]) |
| | demo = demo + [12,14,16] |
| | demo += [12,14,16] |
| | demo.extend([12,14,16]) |
Question 7: How do you insert a floating point number variable into the middle of a string |
| | Write the string in double quotes, with a $ in front of the variable name where you want it |
| | The only way to do it is to use the + operator to concatenate strings |
| | Using either the % operator or the format method on a string object |
| | Using the #{varname} structure in a non-raw string |
Question 8: Unittests allow you to |
| | Check that modules and packages you've loaded are the current ones |
| | Test whether code performs to specification |
| | Check that you have all your dependencies matched |
| | Distribute your own code and charge for it, even though Python is GPL license compatible |
Question 9: Python is called "Python" because |
| | The Author thought that an O'Reilly book with an animal on the cover would come, and liked snakes |
| | Named after Monty Python - "And now for something completely different" |
| | It's just a nice name a word chosen more or less at random |
| | It stands for "Programming - with Yield High Through Object Nodes" (words other way round in Dutch - native tongue of author) |
Question A: What is 'if __name__ == "__main__":' commonly used for? |
| | Adding a test harness to a class |
| | Checking whether there are command line arguments available to you |
| | Providing user documentation |
| | All of the above |
Question B: Under what circumatances can a dictionary have two identical keys? |
| | It can't |
| | Only if the keys are objects of a type you have defined yourself |
| | If the keys are muttable objects |
| | If the keys are immutable objects |
| | If the keys are object which extend the base class cloneable |
Question C: What does "vals = range(20); print vals[2:17:3]" print? |
| | SyntaxError: invalid syntax |
| | [2, 5, 8, 11, 14] |
| | [2, 5, 8, 11, 14, 17] |
| | 2, 5, 8, 11, 14 |
| | 2, 5, 8, 11, 14, 17 |
When done, please |