iqa

This project contains Interview questions with solution and answers

This project is maintained by AshishNamdev

Python Questions

<Back

Q1-Python

Tell the output of following program

def func(user_input):
  output = ""
  for char in user_input:
    output = char + output
  return output

func("INDIA")

Answer

Q2-Python

What is the output of the below code?

import array
a = [1, 2, 3]
print a[-3]
print a[-2]
print a[-1]

Answer

Q3-Python

How to count the occurrences of a perticular element in the list?

Answer

Q4-Python

How to convert a list into a tuple?

Answer

Q5-Python

How to convert a list into a set?

Answer

Q6-Python

How to convert a list into a string?

Answer

Q7-Python

What is Yield Keyword in python?

Answer

Q8-Python

What is a negative index in python?

Answer

Q9-Python

What is the output of the below program?

names = ['Chris', 'Jack', 'John', 'Daman']
print(names[-1][-1])

Answer

Q10-Python

What is Enumerate() Function in python?

Answer

Q11-Python

What is data type SET in python and how to work with it?

Answer

Q12-Python

How do you Concatenate Strings in python?

Answer

Q13-Python

How to generate random numbers in python?

Answer

Q14-Python

How to print sum of the numbers starting from 1 to 100?

Answer

Q15-Python

How do you set a global variable inside a function?

Answer

Q16-Python

What is the output of the program?

names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1[:]

names2[0] = 'Alice'
names3[1] = 'Bob'

sum = 0
for ls in (names1, names2, names3):
    if ls[0] == 'Alice':
        sum += 1
    if ls[1] == 'Bob':
        sum += 10

print(sum)

Answer

Q17-Python

What is the output?

list1 = [1, 3, 2]
print(list1 * 2)

Answer

Q18-Python

What is the output when we execute list("hello")?

Answer

Q19-Python

How to change a set in Python?

Answer

Q20-Python

How to remove elements from a set?

Answer

Q21-Python

What are all Python Set Operations?

Answer

<Back