Interview Coding Questions & Answers — Python

Priyankar Prasad
2 min readOct 1, 2021

--

In IT industry, almost every technical interview has few programming or scripting questions depending on the role(ex: DevOps engineer, SRE) you apply. Python is a popular language among software developers and system engineers because it is relatively easy to learn. Python is used to write scripts to automate repetitive or manual tasks of engineers. So that, I wrote some simple yet most commonly asked python questions in DevOps or SRE interviews.

  1. Find all permutations of a text field

Output :

Permutations of "ABC" is as below,
ABC
ACB
BAC
BCA
CAB
CBA

2. Reverse a String

Output :

Using String slicing : DASARP
Using for loop : DASARP

3. Swap two numbers without using third variable

Output :

Using in-build syntax : a is 20 & b is 10
Using arithmetic operations : a is 20 & b is 10

4. Find the Fibonacci sequence

Output :

Fibonacci sequence : 
0
1
1
2
3

5. Calculate the sum of all the digits in a number

Output :

Sum of digits : 5

6. Check if a string is a palindrome or not

Output :

RADAR is a Palindrome

7. Calculate the factorial of a number

Output :

5! = 120

8. Copy contents of files named like “FileA.txt, FileB.txt, …” in FolderA and FolderB to FolderC

I’m planning to update this post when ever I came across some new scenarios. I hope that this list of interview questions on Python will help you to crack your next job interview. Check my article on Questions of Bash scripts also.

--

--