BASIC PYTHON PROGRAMS

HOW TO CONVERT DECIMAL TO HEXADECIMAL USING WHILE LOOP, TO REMOVE IMAGE BACKGROUND & TO FIND FACTORIAL OF A NUMBER USING FUNCTIONS USING PYTHON

Jivitesh P
Mar 4, 2023

#1

✅PYTHON PROGRAM TO CONVERT DECIMAL TO HEXADECIMAL USING WHILE LOOP

Basic python programs
conversion_table = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']
decimal = int(input("Enter a number:"))
hexadecimal = ''
while(decimal>0):
remainder=decimal%16
hexadecimal=conversion_table[remainder]+hexadecimal
decimal=decimal//16
print("Hexadecimal:",hexadecimal)

#2

HOW TO REMOVE IMAGE BACKGROUND USING PYTHON LIBRARY -REMBG?

How to remove the background of any image?
from rembg import remove
from PIL import Image
import easygui as eg
input_path = eg.fileopenbox(title=’Select image file’)
output_path = eg.filesavebox(title=’Save file to..’)
input = Image.open(input_path)
output = remove(input)
output.save(output_path)
Step-1
Step-1
Step-2
Step-2
Step-3
Step-4
Step-5

#3

✅WRITE A PYTHON PROGRAM TO FIND FACTORIAL OF A GIVEN NUMBER USING FUNCTIONS

Code:

def fact(n):
return 1 if (n==1 or n==0)else n*fact(n-1)
num=5
print("Factorial of ",num,"is")
fact(num)

An article✍️ by Jivitesh P

--

--

Jivitesh P
Jivitesh P

Written by Jivitesh P

Greetings! Here you'll find a host of great resources, interesting, up-to-date articles and more. I'm Jivitesh, a self-taught developer and technical writer

No responses yet