StackTipsStackTips
Pythonbeginner

Python Basics List, Dictionary and Regx Practice

The test contains 40 questions and has a time imit of 20 minutes

40 questions30 min

The test contains 40 questions and has a time imit of 20 minutes

The test is not official, it's just a nice way to see how much you know, or don't know, about Python.

0/40 checked
  1. 01

    Which one of these is NOT true about recursion?

  2. 02

    Is Python case sensitive when dealing with identifiers?

  3. 03

    Which of the following commands will create a list?

  4. 04

    What is the output when we execute list("hello")?

  5. 05

    What is the output of len(list("hello"))?

  6. 06

    Suppose list1 is [2445,133,12454,123], what is max(list1)?

  7. 07

    Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?

  8. 08

    Suppose list1 is [1, 5, 9], what is sum(list1)?

  9. 09

    What function do we use to shuffle the list?

  10. 10

    Suppose list is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?

  11. 11

    Suppose list is [2, 33, 222, 14, 25], What is list[-1]?

  12. 12

    Suppose list1 is [2, 33, 222, 14, 25], What is list[:-1]?

  13. 13

    Suppose list is [3, 4, 5, 20, 5, 25, 1, 3], what is list after list.reverse()?

  14. 14

    Suppose list is [3, 4, 5, 20, 5, 25, 1, 3], what is list after list.extend([34, 5])?

  15. 15

    Suppose list is [3, 4, 5, 20, 5, 25, 1, 3], what is list after list.pop(1)?

  16. 16

    What will be the output of the following Python code?

    "Welcome to Python".split()
  17. 17

    What will be the output of the following Python code?

     list("a#b#c#d".split('#')) 
  18. 18

    What will be the output of the following Python code?

    weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
    if 'monday' in weekdays:
       print(1)
    else:
       print(2)
  19. 19

    What will be the output of the following Python code?

    def f(i, values=[]):
       values.append(i)
       return values
       
    f(1)
    f(2)
    v = f(3)
    print(v)
  20. 20

    What will be the output of the following Python code?

    names1 = ['Amir', 'Bala', 'Charlie']
    names2 = [name.lower() for name in names1]
    print(names2[2][0])
  21. 21

    To which of the following the "in" operator can be used to check if an item is in it?

  22. 22

    What will be the output of the following Python code?

    veggies = ['carrot', 'broccoli', 'potato', 'asparagus']
    veggies.insert(veggies.index('broccoli'), 'celery')
    print(veggies)
  23. 23

    Which module in Python supports regular expressions?

  24. 24

    Which of the following creates a pattern object?

  25. 25

    What does the function re.match do?

  26. 26

    What does the function re.search do?

  27. 27

    What will be the output of the following Python code?

    import re
    sentence = 'we are humans'
    matched = re.match(r'(.*) (.*?) (.*)', sentence)
    print(matched.groups())
  28. 28

    The difference between the functions re.sub and re.subn is that re.sub returns a _____ whereas re.subn returns a _______

  29. 29

    The function of re.search is ______

  30. 30

    Which of the following functions creates a Python object?

  31. 31

    The function of re.match is _______

  32. 32

    The special character \B matches the empty string, but only when it is _______

  33. 33

    What will be the output of the following Python code?

    def test():
            x, y = 4, 5
            y, x = x, y
            print(x)
            print(y)
    
    test()
  34. 34

    What is an abstract class?

  35. 35

    What happens when you use the build-in function any() on a list?

  36. 36

    What data structure does a binary tree degenerate to if it isn't balanced properly?

  37. 37

    What statement about static methods is true?

  38. 38

    What are attributes?

  39. 39

    Which statement about strings in Python is true?

  40. 40

    If you do not explicitly return a value from a function, what happens?