Test your basic knowledge |

Basic Python Programming

Subject : it-skills
  • 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 creates a new class object which is a user-defined type - like a factory for creating objects.

2. adds an item to a list

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

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

5. Function to open or read a file

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

7. A built-in function that converts integers and strings to floating-point numbers.

8. absolute value

9. Binary AND Operator copies a bit to the result if it exists in both operands. (a & b) will give 12 which is 0000 1100

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

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

12. Function to read the contents of a file

13. A logical operator which returns a value of True if either of the conditions is true.

14. subtract AND assignment operator

15. add AND assignment operator

16. turns an object into a string

17. End header line.

18. Greater than or equal symbol.

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

20. floor division

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

22. A boolean operator that takes two strings and returns True if the first appears as a substring in the second.

23. Greater than symbol

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

25. This statement exits a function. The remaining lines of the function are not executed.

26. Called Logical AND operator. If both the operands are true then then condition becomes true. (a and b) is true.

27. A string that begins with the % symbol and contains a sequence of printable characters and format specifiers that determine how values output should look.

28. Greater than symbol

29. Symbol used to create comments

30. turns an object into an integer

31. A statement that ends the current iteration of a loop but continues looping.

32. Function to read the contents of a file

33. Adds a new line character

34. This keyword in the body of a conditional - gives an alternative execution.

35. multiply AND assignment operator

36. Symbol to subtract things from each other

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

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

39. assignment operator

40. turns an object into a string

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

42. Function to write something to a file

43. A built-in function that takes any value and converts it to an integer if possible - or complains otherwise.

44. prints its parameter to the console

45. empties the file

46. floor division

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

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

49. divide AND assignment operator

50. adds an item to a list