python basic interview questions code example

Example 1: python interview questions

Python OneStop Solution..
link: https://github.com/itzanuragsinghania/Python-One-Stop

Example 2: 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 3: interviewbit with Python questions solutions

1234567891011121314151617class Student:    def __init__(self, name, branch):        self.name = name        self.branch = branch    def printfunction(self):        print(self.name + " " + self.branch)def main():    #Your code goes here    stud1=function('Robin','CSE')    stud2=student('Rahul','ECE')    stud1.printfunction()    stud2.printfunction()    return 0if __name__ == '__main__':    main()XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Example 4: python interview questions

a=input("enter sequence")
b=a[::-1]
if a==b:
    print("palindrome")
else:
    print("Not a Palindrome")

Example 5: python interview questions

# what is python apart from language

Example 6: 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)