Monday, August 15, 2022

### 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): ...

### Python program to find the GCD of two numbers using recursive

def gcd(x,y):     if(y==0):       return x     else:       return gcd(y,x%y) x=int(input("Please enter first number: ")) y=int(input("Please enter second...

### Python program to check find the given year is a leap year or not

year=int(input("Please enter a year to be check leap year or not: ")) if(year%4==0 and year%100!=0 or year%400==0): print("This year is a leap...

### Python program to find the LCM of two numbers using recursive

def lcm(a,b): lcm.multiple=lcm.multiple+b if((lcm.multiple % a == 0) and (lcm.multiple % b == 0)): ...