Python program to convert decimal to binary octal and hexadecimal using function
def dec_to_binary(dec): # Function which is convert decimal to binary
decimal = int(dec)
print(decimal, " in Binary...
Python program to convert decimal to binary using function
def dec_to_binary(num): #This function converts decimal number to binary and print
if num > 1:
...
Python program to convert decimal to hexadecimal using function
def dec_to_hexa(dec):
d = int(dec) #d represents decimal
print(d, " in Hexadecimal : ", hex(d)) ...
Python program to convert a decimal number to octal number using function
""" Python program to convert a decimal number to octal number without using
direct functions for standard base conversions like oct()"""
def dec_to_octal(n): ...
Python program to find length of a String using function
def find_length(str):
counter = 0
for i in str:
...
Python program for swapping of two numbers using function
def swapping_numbers(num1, num2):
temp=num1
num1=num2
num2=temp
print("After swapping: ")
...
Python Program to find the LCM using function
def lcm(a, b):
if a > b: # choose the greater number
greater = a
...
Python program to find GCD or HCF using function
def hcf(a, b):
if a > b: # choose the smaller number
...
Python program to perform all arithmetic operations on two integers using function
def airthcalc(x,y):
return x+y, x-y, x*y, x/y, x%y
#_____main_____
num1=int(input("Please enter the first number: "))
num2=int(input("Please enter the second number: "))
add,sub,mult,div,mod=airthcalc(num1,num2)
print("Sum of given numbers:...
Python program to check number is prime or not using function
def prime(num):
if num > 1:
for i in range(2, num//2):
...