HomeinterviewInterview program in Python part 1

Interview program in Python part 1

Nowadays in any interview a programming test is a must, So here we are creating a series of basic interview program in Python, We learn step by step. You can also visit Java program if you are looking for that

Write a program in Python to find a Maximum of two numbers

If you have two numbers, write a Python code to find the limit of these two numbers.


def max(i, j): 
	
	if i >= j: 
		return i 
	else: 
		return j 
	

a = 2
b = 4
print(max(a, b)) 
print('Thank you for reading basic interview programs in python')
basic interview programs in Python 
Maximum of two numbers in Python

Write a program in Python for calculation of simple interest

we can use simple interest formula :
Simple Interest = (P x T x R)/100
Where,
P is the principle amount
T is the time and
R is the rate

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 
	
# Driver code 
simple_interest(20000, 3, 8) 
print('Thank you for reading basic interview programs in python')
Write a Python Program for calculation of simple interest

Write a program in Python for check whether the number is Armstrong  number or not

The Armstrong number of three digits is the integer such that the sum of the cubes of its digits is equal to the number itself.

Write a program in Python to find some of the square of first n natural numbers

def squaresum(n) :

    sm = 0

    for i in range(1, n+1) :

        sm = sm + (i * i)

    return sm

n = 4
print(squaresum(n))
print("Thanks for visiting onurdesk program in Python")

Write a program in Python to sum of all digits of a number

n=int(input("Enter a number:"))
sum=0
while n>0:
   rem=n%10
   sum=sum+rem
   n=int(n/10)
print("The sum of digits of number is:", sum)

print("Thanks for visiting onurdesk program in Python")

Write a program in Python to check a year is a leap year or not using Python

year=int(input("Enter a Year:"))

if ((year % 100 == 0 and year % 400 == 0) or (year % 100 != 0 and year % 4 == 0)):
     print("It is a Leap Year")
else:
     print("It is not a Leap Year")

Write a program in Python to convert Days into years, weeks and months


days=int(input("Enter Day:"))

years =(int) (days / 365)
weeks =(int) (days / 7)
months =(int) (days / 30)

print("Days to Years:",years)
print("Days to Weeks:",weeks)
print("Days to Months:",months)

Write a program in Python to print all prime number in an interval

start = 11
end = 25

  

for val in range(start, end + 1):

   # If num is divisible by any number  
   # between 2 and val, it is not prime 

   if val > 1:

       for n in range(2, val):

           if (val % n) == 0:

               break

       else:

           print(val)

print("Thanks for visiting program in Python")

Write a program in Python to find Area of a circle

def findArea(r):

    PI = 3.142

    return PI * (r*r);
#Like us on facebook
# Driver method

print(findArea(5))
print("Thanks for visiting program in Python")

Write a program in Python find sum of elements in given array

def _sum(arr,n):
    # return sum using sum 
    # inbuilt sum() function
    return(sum(arr))   
# driver function
arr=[]

# input values to list

arr = [12, 3, 4, 15]

# calculating length of array

n = len(arr)

ans = _sum(arr,n)  

#Like us on facebook
# display sum

print("Thanks for visiting onurdesk program in Python")
print (ans)

Write a program in Python to check if small string is there in big string

def check(string, sub_str):

    if (string.find(sub_str) == -1):

        print("NO")

    else:

        print("YES")   
        print("Like us on facebook")
        print("Thanks for visiting onurdesk program in Python")

# driver code

string = "zeus is a programmer"

sub_str ="zeus"

check(string, sub_str)
Admin
Onurdesk is a technical platform based primarily on Spring, Java, and Nodejs ecosystem app creation. We write tutorials and manuals concentrating extensively on realistic and real-life usage cases.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular

Recent Comments