python developer interview questions and answers code example
Example 1: python interview prep
# 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
Example 2: interviewbit with Python questions solutions
class Student:
def __init__(self, name, branch):
self.name = name
self.branch = branch
obj = Student("Robin", "CSE")
print(obj.name)
print(obj.branch)