# Top 15 First Round Questions For Interview for Python Programmer

Share on whatsapp
WhatsApp
Share on telegram
Telegram
Share on email
Email

### Some instructions before we begin :-

1. First see the question and than solve and check if solution is correct or not.
2. There are many ways of doing a same Question, if you find another way to solve question than share with other people in comment section.
3. If you are not able to solve questions than don’t worry see the solution and than try solving it.

### Solution:

# Python3 program to add two numbers
num1 = 15
num2 = 12
sum = num1 + num2
# printing values
print(“Sum of {0} and {1} is {2}” .format(num1, num2, sum))

### Solution:

def factorial(n):
if n < 0:
return 0
elif n == 0 or n == 1:
return 1
else:
fact = 1
while(n > 1):
fact *= n
n -= 1
return fact
num = 5;
print(“Factorial of”,num,”is”,
factorial(num))

### Solution:

def simple_interest(p,t,r):
print(‘The principal is’, p)
print(‘The time period is’, t)
print(‘The rate of interest is’,r)

si = (p * t * r)/100

print(‘The Simple Interest is’, si)
return si

simple_interest(8, 6, 8)

### Solution:

# interest for given values.

def compound_interest(principle, rate, time):

# Calculates compound interest
CI = principle * (pow((1 + rate / 100), time))
print(“Compound interest is”, CI)

# Driver Code
compound_interest(10000, 10.25, 5)

### Solution:

# Python program to determine whether the
number is
# Armstrong number or not
# Function to calculate x raised to the power y
def power(x, y):
if y==0:
return 1
if y%2==0:
return power(x, y/2)*power(x, y/2)
return x*power(x, y/2)*power(x, y/2)
# Function to calculate order of the number
def order(x):
# variable to store of the number
n = 0
while (x!=0):
n = n+1
x = x/10
return n

### Solution:

# Python program to find Area of a circle
def findArea(r):

PI = 3.142
return PI * (r*r);

# Driver method
print(“Area is %.6f” % findArea(5));

### Solution:

start = 11
end = 25
for val in range(start, end + 1):
if val > 1:
for n in range(2, val//2 + 2):
if (val % n) == 0:
break
else:
if n == val//2 + 1:
print(val)

### Solution:

num = 11
# If given number is greater than 1
if num > 1:
# Iterate from 2 to n / 2
for i in range(2, num//2):
# If num is divisible by any number between
# 2 and n / 2, it is not prime
if (num % i) == 0:
print(num, “is not a prime number”)
break
else:
print(num, “is a prime number”)
else:
print(num, “is not a prime number”)

### Solution:

def isPerfectSquare(x):
s = int(math.sqrt(x))
return s*s == x
# Returns true if n is a Fibinacci Number, else false
def isFibonacci(n):
# n is Fibinacci if one of 5*n*n + 4 or 5*n*n – 4 or both
# is a perferct square
return isPerfectSquare(5*n*n + 4) or isPerfectSquare(5*n*n – 4)

# A utility function to test above functions
for i in range(1,11):
if (isFibonacci(i) == True):
print(i,”is a Fibonacci Number”)
else:
print(i,”is a not Fibonacci Number “)

### Solution:

# Python program to print
# ASCII Value of Character

# In c we can assign different
# characters of which we want ASCII value

c = ‘g’
# print the ASCII value of assigned character in c
print(“The ASCII value of ‘” + c + “‘ is”, ord(c))