program to covert a base 10 number in any base system

 Problem Statement: Given a number in base 10 convert it in base 2, 3, 4,5,.......,9

Code:

n=int(input("enter a number with base 10:"))

b=int (input("enter the base in which you want to convert:"))

p=1

num=0

while(n>0):

    rem=n%b

    num=rem*p+num

    p=p*10

    n=n//b

print(num)

Screansort of code and output:





Comments

Popular posts from this blog

Program to print Z in Python

Program to print a pattern in python