Test your basic knowledge |

Basic Python Programming

Subject : it-skills
Instructions:
  • Answer 50 questions in 15 minutes.
  • If you are not ready to take this test, you can study here.
  • Match each statement with the correct term.
  • Don't refresh. All questions and answers are randomly picked and ordered every time you load a test.

This is a study tool. The 3 wrong answers for each question are randomly chosen from answers to other questions. So, you might find at times the answers obvious, but you will see it re-enforces your understanding as you take the test each time.
1. Prints a string to the screen which is converted using repr()






2. Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. a << 2 will give 240 which is 1111 0000






3. Function to empty the contents of a file - no recovery is possible






4. rounds a number to the number of decimal points you choose






5. A logical operator which compares two operands and produces True if they are equal and False otherwise






6. Empties the file - watch out if you care about the file.






7. returns the length of a string (number of characters)






8. turns an object into a string






9. Command to print to the screen






10. Binary XOR Operator copies the bit if it is set in one operand but not both. (a ^ b) will give 49 which is 0011 0001






11. Prints a string to the screen which is converted using repr()






12. inserts an item inside a list at a certain index






13. Holds the value of something - e.g. oh_hi = 4 where oh_hi is the variable.






14. Less than symbol






15. Evaluates to true if it finds a variable in the specified sequence and false otherwise. x in y - here in results in a 1 if x is a member of sequence y.






16. A statement that breaks out of a loop.






17. Binary Ones Complement Operator is unary and has the efect of 'flipping' bits. (~a ) will give -60 which is 1100 0011






18. Evaluates to false if the variables on either side of the operator point to the same object and true otherwise. x is not y - here is not results in 1 if id(x) is not equal to id(y).






19. Command to print to the screen






20. Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. a >> 2 will give 15 which is 0000 1111






21. Adds something to a variable






22. Greater than symbol






23. modulus AND assignment operator






24. Binary OR Operator copies a bit if it exists in eather operand. (a | b) will give 61 which is 0011 1101






25. This variable holds the arguments you pass to your Python script when you run it. Then you unpack it in your script so you have variables you can work with.






26. This keyword creates a new class object which is a user-defined type - like a factory for creating objects.






27. Function to read the contents of a file






28. Symbol to add things together






29. add AND assignment operator






30. Argument variable






31. returns the length of a string (number of characters)






32. absolute value






33. Greater than or equal symbol.






34. inserts an item inside a list at a certain index






35. modulus AND assignment operator






36. This keyword begins the simplest form of a conditional statement.






37. Prints a string to the screen which is a signed decimal.






38. A logical operator which negates an expression so that it returns a value of True if the expression is false.






39. single line comment






40. Symbol to subtract things from each other






41. Function to empty the contents of a file - no recovery is possible






42. Turns a line into a comment instead of executable code.






43. floor division






44. The keyword beginning a header that will create a new function.






45. The keyword beginning a header that will create a loop.






46. The extension for Python scripts






47. Symbol to subtract things from each other






48. multiply AND assignment operator






49. add AND assignment operator






50. Argument variable