Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- “””
- List of possible questions for python coding interview.
- Meant to be flexible so pick and choose from the outline as we please.
- I created more questions than someone could probably answer in the
- allotted time anyway so we can choose a subset.
- “””
- # Print the keys from the given dictionary person
- person = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
- # Write a simple unit test for your method
- # ----------------------------------------------------------
- # Return a single list of unique names given two seperate lists of names
- names1 = ['Olivia', 'Amy', 'Emily', 'Jack', 'Charlie', 'Bill', 'Ray', 'Mia']
- names2 = ['John', 'Steven', 'Amy', 'Ray', 'Jason', 'Mia', 'Emilio']
- # ----------------------------------------------------------
- # Create two lists. One with all even and another with all odd numbers from the given list below.
- nums = [3, 1, 10, 4, 8, 11, 2, 6, 9, 0, 5, 7]
- # ----------------------------------------------------------
- Tell me about generators.
- Possible questions
- What is an iterable.
- What two methods do iterable objects implement
- What is the difference between a generator and a list
- What is lazy evaluation
- # Write a generator method that prints from 0 to n given n
- # Given the simple generator function, what will be printed to the console?
- def my_gen():
- n = 1
- print('This is printed first')
- yield n
- n += 1
- print('This is printed second')
- yield n
- n += 1
- print('This is printed at last')
- yield n
- next(my_gen())
- next(my_gen())
- next(my_gen())
- next(my_gen())
- # What about
- g = my_gen()
- next(g)
- next(g)
- next(g)
- next(g)
- # Or
- print(next(g))
- print(next(g))
- print(next(g))
- print(next(g))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement