### Python interview questions with answers part 2

This is a growing list hence, the article has been broken down into multiple parts

#### Fibonacci series in python?

Generate a Fibonacci series for a given number

 ``````1 2 3 4 `````` ``````a,b,n = 0,1,10 for i in range(0, n): print(a, end=', ') a, b = b, a+b``````

#### Check if a string is a palindrome or not

There are many ways of implementing this.

String Reverse

 ``````1 2 3 4 5 6 7 8 `````` ``````mystring = 'malayalam' reverse_mystring = mystring[::-1] reverse_mystring = ''.join(reversed(mystring)) if mystring == reverse_mystring: print("String is a palindrome") else: print("String is NOT a palindrome")``````

String Reverse

 ``````1 2 3 4 5 `````` ``````def isPalindrome(str): for i in range(0, len(str)//2): if str[i] != str[len(str)-i-1]: return False return True``````

#### If you have multiple decorators for a function, which would be called first

 `````` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 `````` ``````def a(f): def wrapperxx(*args, **kwargs): print("a") f(*args, **kwargs) return wrapperxx def b(f): def wrapperxx(*args, **kwargs): print("b") f(*args, **kwargs) return wrapperxx def c(f): def wrapperxx(*args, **kwargs): print("c") f(*args, **kwargs) return wrapperxx @a @b @c def myfunction(a): print(a) myfunction("Prabhakar")``````

The result would be

 ``````1 2 3 4 `````` ``````a b c Prabhakar``````

This is a growing list hence, the article has been broken down into multiple parts ## Related Content ### Javascript interview questions with answers

What are the advantages of using JSON rather than using xml JSON is a lightweight format for storing and transferring data. ### Python interview questions with answers

This is a growing list hence, the article has been broken down into multiple parts ### How to maintain multiple versions of django without using using virtual envs.

Most linux come installed with python 2.7. Some even come installed with both 2.7 and 3 as well.

## Featured Posts 