Advertisement
gabrielep

interview challenges - systems design engineer (backend)

Jun 3rd, 2024 (edited)
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # QUESTION 1 ------------------------------------------------
  2. #   What is the value of `b`?
  3.  
  4. a = [1, 2, 3, 4, 5]
  5. b = [x ** 2 for x in a]
  6.  
  7.  
  8. # QUESTION 2 ------------------------------------------------
  9. #   What is the value of `c`?
  10.  
  11. a = "Hello, World!"
  12. b = a.split()
  13. c = len(b)
  14.  
  15.  
  16. # QUESTION 3 ------------------------------------------------
  17. #   What are the values of `a` and `b`?
  18. #   What is the purpose of this method?
  19.  
  20. def f(x):
  21.     if x % 2 == 0:
  22.         return True
  23.     else:
  24.         return False
  25.  
  26. a = f(3)
  27. b = f(6)
  28.  
  29.  
  30. # QUESTION 4 ------------------------------------------------
  31. #   What is the value of `a`?
  32.  
  33. def f(x):
  34.     if x == 0:
  35.         return 0
  36.     return f(x-1)
  37.  
  38. a = f(3)
  39.  
  40. # QUESTION 5 ------------------------------------------------
  41. #    What is the value of `d`?
  42.  
  43. a = """
  44.  Hello
  45.  from
  46.  Red
  47.  Hat
  48. """.split()
  49.  
  50. b = [x for x in a if len(x) != 5]
  51.  
  52. c = ["Thank you"] + b
  53.  
  54. d = " ".join(c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement