29
loading...
This website collects cookies to deliver better user experience
Remember, interview process is not about the solution of a problem its all about how you approach the given problem.
[('John', 95), ('Danny', 98), ('Aaron', 90), ('Leo', 94)]
sort this by the name of the person.people = [('John', 95), ('Danny', 98), ('Aaron', 90), ('Leo', 94)]
# argument to lambda function is the whole list of tuple & it will
# set the key to sort on the basis of the 0th index of each tuple
people = sorted(people, key=lambda x: x[0])
print(people)
Output:
[('Aaron', 90), ('Danny', 98), ('John', 95), ('Leo', 94)]
import enum
class Programming(enum.Enum):
python = 1
java = 2
# A generator function that yields 1 for first time,
# 2 second time and 3 third time
def simpleGeneratorFun():
yield 1
yield 2
yield 3
# Driver code to check above generator function
for value in simpleGeneratorFun():
print(value)
from abc import ABC
class AbstractLanguage(ABC):
@abstractmethod
def created_by(self):
pass
class Python(AbstractLanguage):
def created_by(self):
print("Guido van Rossum")