Earl
0
Q:

python interview questions

# what is python apart from language
0
def myWrapper(n):
  return lambda a : a * n

mulFive = myWrapper(5)
print(mulFive(2))    # output => 10
0
# Negative indexes are the indexes from the end of a list, tuple, or string

arr = [1, 2, 3, 4, 5, 6]

#get the last element
print(arr[-1]) #output 6

#get the second last element
print(arr[-2]) #output 5
1
class Employee:
def __init__(self, name, age,salary):
self.name = name
self.age = age
self.salary = 20000
E1 = Employee("XYZ", 23, 20000)
# E1 is the instance of class Employee.
#__init__ allocates memory for E1. 
print(E1.name)
print(E1.age)
print(E1.salary)
0
mul = lambda a, b : a * b
print(mul(2, 5))    # output => 10
0

New to Communities?

Join the community