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. This keyword in the body of a conditional - gives an alternative execution.






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






3. adds an item to a list






4. 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.






5. Prints a string to the screen which will be Unicode.






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






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






8. An operator that removes a value from a list.






9. Symbol to multiply things






10. Greater than or equal symbol.






11. writes stuff to the file






12. absolute value






13. turns an object into a string






14. The extension for Python scripts






15. End header line.






16. floor division






17. ,multi-line comment hard-code,Fix (data or parameters) in a program in such a way that they cannot easily be altered by the user.






18. Reads the contents of the file you can assign the result to a variable.






19. Prevents a runtime error from stopping the program.






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






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






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






23. A data type for representing numbers with fractional values.






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






25. This keyword attempts to do something that would cause the program to crash if it were not for this statement.






26. A statement that displays a value on the screen.






27. Function to write something to a file






28. Symbol to subtract things from each other






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






30. asks the user for a response and returns that response






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






32. 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






33. Function to open or read a file






34. End header line.






35. Adds something to a variable






36. asks the user for a response and returns that response






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






38. 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






39. 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






40. Symbol used to create comments






41. assignment operator






42. exponentiation






43. Symbol to subtract things from each other






44. This keyword in the body of a conditional allows chained conditionals.






45. Less than symbol






46. single line comment






47. A statement that assigns a value to a variable.






48. A logical operator which requires two expressions to both be true.






49. modulo






50. reads just one line of a text file & keeps track of where in the file you're at