Hướng dẫn how do you convert decimal to octal in python? - làm thế nào để bạn chuyển đổi thập phân sang bát phân trong python?

Trong chương trình này, bạn sẽ học cách chuyển đổi thập phân thành nhị phân, bát phân và thập lục phân và hiển thị nó.

Để hiểu ví dụ này, bạn nên có kiến ​​thức về các chủ đề lập trình Python sau:

  • Lập trình Python Chức năng tích hợp

Hệ thống thập phân là hệ thống số được sử dụng rộng rãi nhất. Tuy nhiên, máy tính chỉ hiểu nhị phân. Các hệ thống số nhị phân, bát phân và thập lục phân có liên quan chặt chẽ với nhau và chúng ta có thể yêu cầu chuyển đổi thập phân thành các hệ thống này.

Hệ thống thập phân là cơ sở 10 (mười ký hiệu, 0-9, được sử dụng để đại diện cho một số) và tương tự, nhị phân là cơ sở 2, octal là cơ sở 8 và thập lục phân là cơ sở 16.

Một số có tiền tố ________ 8 & nbsp; được coi là nhị phân, ________ 9 & nbsp; được coi là bát phân và ____ 10 & nbsp; như hình lục giác. Ví dụ:

60 = 0b11100 = 0o74 = 0x3c

Mã nguồn

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")

Đầu ra

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.

Lưu ý: Để kiểm tra chương trình cho các số thập phân khác, thay đổi giá trị của DEC trong chương trình. To test the program for other decimal numbers, change the value of dec in the program.

Trong chương trình này, chúng tôi đã sử dụng các hàm tích hợp

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
1,
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
2 và
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
3 để chuyển đổi số thập phân đã cho thành các hệ thống số tương ứng.

Các hàm này có một số nguyên (theo số thập phân) và trả về một chuỗi.

Bài viết này được đóng góp bởi Saurabh Sharma. Nếu bạn thích GeekSforGeeks và muốn đóng góp, bạn cũng có thể viết một bài viết bằng Write.GeekSforGeek.org hoặc gửi bài viết của bạn. Xem bài viết của bạn xuất hiện trên trang chính của GeekSforGeek và giúp các chuyên viên máy tính khác. Write a Program in Python to convert a decimal number into its corresponding octal representation.

Example:

Input:  8
Output: 10

Input:  15
Output: 17

Chuyển đổi thập phân sang bát phân trong Python bằng cách sử dụng vòng lặp

Hướng dẫn how do you convert decimal to octal in python? - làm thế nào để bạn chuyển đổi thập phân sang bát phân trong python?

Cách tiêu chuẩn để chuyển đổi số thập phân thành một bát phân là chia số thập phân cho 8 cho đến khi giảm xuống còn 0.

Sau khi phân chia kết thúc, nếu chúng ta xếp các phần còn lại theo cách từ dưới lên, giá trị kết quả sẽ là số octal tương đương.

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))

Output::

Nhập số thập phân: 15 nhị phân 15 là: 17
Binary of 15 is: 17

Chuyển đổi thập phân sang bát phân trong Python bằng cách sử dụng đệ quy

Để chuyển đổi thập phân thành bát phân bằng cách sử dụng đệ quy, chúng tôi chuyển chỉ số (cổ tức/8) sang cuộc gọi đệ quy tiếp theo và đầu ra giá trị còn lại (cổ tức%8).

Chúng tôi lặp lại quá trình cho đến khi số giảm xuống 0 (nghĩa là cho đến số thập phân> 0).

Kể từ khi đệ quy thực hiện ngăn xếp, phần còn lại được in theo cách từ dưới lên và chúng tôi nhận được số octal tương đương.

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)

Output::

Nhập số thập phân: 8 Octal: 10
Octal: 10

Chuyển đổi thập phân sang bát phân bằng OCT ()

Phương pháp Python tích hợp

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
2 trả về biểu diễn bát phân của số thập phân được truyền dưới dạng tham số.

Nó trả về một số bát phân dưới dạng

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
5, trong đó
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
6 là giá trị số octal thực tế.

>>> print(oct(15))
0o17

Nhận xét bên dưới nghi ngờ hoặc đề xuất của bạn nếu bạn có bất kỳ.

Đưa ra một số thập phân làm đầu vào, chúng ta cần viết một chương trình để chuyển đổi số thập phân đã cho thành một số bát phân tương đương. tức là chuyển đổi số với giá trị cơ sở 10 thành giá trị cơ sở 8. Giá trị cơ sở của hệ thống số xác định số chữ số được sử dụng để biểu diễn giá trị số. Ví dụ: hệ thống số nhị phân sử dụng hai chữ số 0 và 1, hệ thống số octal sử dụng 8 chữ số từ 0-7 và hệ thống số thập phân sử dụng 10 chữ số 0-9 để biểu thị bất kỳ giá trị số nào.

Ví dụ: & nbsp; 

Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41

Algorithm:  :  

  1. Lưu trữ phần còn lại khi số được chia cho 8 trong một mảng.
  2. Chia số cho 8 bây giờ
  3. Lặp lại hai bước trên cho đến khi số không bằng 0.
  4. In mảng theo thứ tự ngược lại ngay bây giờ.

Ví dụ: & nbsp;

Nếu số thập phân đã cho là 16. & nbsp;

Bước 1: Phần còn lại khi 16 được chia cho 8 là 0. Do đó, ARR [0] = 0. & NBSP; được chia cho 8, là 2. Do đó, ARR [1] = 2. & nbsp; Bước 4: chia 2 cho 8. Số mới là 2/8 = 0. & nbsp; Bước 5: Vì số trở thành = 0. & nbsp;: Remainder when 16 is divided by 8 is 0. Therefore, arr[0] = 0. 
Step 2: Divide 16 by 8. New number is 16/8 = 2. 
Step 3: Remainder, when 2 is divided by 8, is 2. Therefore, arr[1] = 2. 
Step 4: Divide 2 by 8. New number is 2/8 = 0. 
Step 5: Since number becomes = 0. 

Dừng các bước lặp lại và in mảng theo thứ tự ngược lại. Do đó, số octal tương đương là 20.

Sơ đồ dưới đây cho thấy một ví dụ về việc chuyển đổi số thập phân 33 thành số octal tương đương. & NBSP; & nbsp;

Hướng dẫn how do you convert decimal to octal in python? - làm thế nào để bạn chuyển đổi thập phân sang bát phân trong python?

Dưới đây là việc thực hiện ý tưởng trên. & Nbsp; & nbsp;

C

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
7

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
9
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
1

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
5

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
8

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
Input:  8
Output: 10

Input:  15
Output: 17
1

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
3

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
5

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
7

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
6
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
8
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
9

Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
>>> print(oct(15))
0o17
0
>>> print(oct(15))
0o17
1

Input:  8
Output: 10

Input:  15
Output: 17
9

C++

>>> print(oct(15))
0o17
3

>>> print(oct(15))
0o17
4
>>> print(oct(15))
0o17
5
>>> print(oct(15))
0o17
6

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
9
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
1

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
5

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
8

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
Input:  8
Output: 10

Input:  15
Output: 17
1

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
5

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
7

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4

Input:  8
Output: 10

Input:  15
Output: 17
20o5

Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
>>> print(oct(15))
0o17
0
>>> print(oct(15))
0o17
1

Input:  8
Output: 10

Input:  15
Output: 17
9

>>> print(oct(15)) 0o174 >>> print(oct(15)) 0o175 >>> print(oct(15)) 0o176

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
3

Java

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
09
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
10

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
11
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
12

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
9
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
1

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
23
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
24
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
26
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
27
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
28

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
40
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
41
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
44
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
41
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
Input:  8
Output: 10

Input:  15
Output: 17
7

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
31
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
61

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
36
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
38

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
55
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
56
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
57
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
59

Input:  8
Output: 10

Input:  15
Output: 17
2
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
9

Python3

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
68

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
73
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
74
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
81
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
82

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
84
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
26
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
88
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
89
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
27

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
92
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
97
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
00

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
02
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
04
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
05
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
41

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
04
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
11
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
12
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
41
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
14

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
36
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
37
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
39

Input:  8
Output: 10

Input:  15
Output: 17
2
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
92
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
17
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
56

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
43

C#

>>> print(oct(15))
0o17
4
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
45

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
11
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
12

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
9
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
1

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
23
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
24
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
61

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
8

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
0
Input:  8
Output: 10

Input:  15
Output: 17
1

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
Input:  8
Output: 10

Input:  15
Output: 17
3

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
Input:  8
Output: 10

Input:  15
Output: 17
5

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
Input:  8
Output: 10

Input:  15
Output: 17
7

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
82

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
89

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

Input:  8
Output: 10

Input:  15
Output: 17
2
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
9

PHP

Input:  8
Output: 10

Input:  15
Output: 17
00

Input:  8
Output: 10

Input:  15
Output: 17
01
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
9
Input:  8
Output: 10

Input:  15
Output: 17
03
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
14

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
07
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
10
Input:  8
Output: 10

Input:  15
Output: 17
11

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2
Input:  8
Output: 10

Input:  15
Output: 17
03
Input:  8
Output: 10

Input:  15
Output: 17
16

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
07
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
26
Input:  8
Output: 10

Input:  15
Output: 17
10
Input:  8
Output: 10

Input:  15
Output: 17
23
Input:  8
Output: 10

Input:  15
Output: 17
03
Input:  8
Output: 10

Input:  15
Output: 17
25

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
03
Input:  8
Output: 10

Input:  15
Output: 17
28
Input:  8
Output: 10

Input:  15
Output: 17
03
Input:  8
Output: 10

Input:  15
Output: 17
30

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
10
Input:  8
Output: 10

Input:  15
Output: 17
33

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input:  8
Output: 10

Input:  15
Output: 17
38
Input:  8
Output: 10

Input:  15
Output: 17
39
Input:  8
Output: 10

Input:  15
Output: 17
40______310

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
48
Input:  8
Output: 10

Input:  15
Output: 17
07
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
26
Input:  8
Output: 10

Input:  15
Output: 17
39
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
28

Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
03
Input:  8
Output: 10

Input:  15
Output: 17
55

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
9
Input:  8
Output: 10

Input:  15
Output: 17
03
Input:  8
Output: 10

Input:  15
Output: 17
58

Input:  8
Output: 10

Input:  15
Output: 17
59

JavaScript

Input:  8
Output: 10

Input:  15
Output: 17
60

Input:  8
Output: 10

Input:  15
Output: 17
01
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
43

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
24
Input:  8
Output: 10

Input:  15
Output: 17
67

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
69

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
Input:  8
Output: 10

Input:  15
Output: 17
1

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
3

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
76

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
7

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input:  8
Output: 10

Input:  15
Output: 17
83

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
85

Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
88

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

Input:  8
Output: 10

Input:  15
Output: 17
91

Độ phức tạp về thời gian: O (log n) & nbsp; O(log N) 

Độ phức tạp không gian: O (n) Kể từ khi tạo mảng để lưu trữ các số bát phân since creating array to store octal numbers

Một cách tiếp cận khác: (O (1) Độ phức tạp không gian)

Vấn đề này cũng có thể được giải quyết mà không cần sử dụng mảng & nbsp; sử dụng thuật toán sau:

  • Khởi tạo num octal thành 0 và CountVal đến 1 và số thập phân là n
  • Tìm phần còn lại khi số thập phân chia cho 8
  • Cập nhật số Octal của Octalnum + (phần còn lại * CountVal)
  • Tăng CountVal của CountVal*10
  • Chia số thập phân cho 8
  • Lặp lại từ bước thứ hai cho đến khi số thập phân bằng không

Dưới đây là việc thực hiện ý tưởng trên:

C++

>>> print(oct(15))
0o17
3

>>> print(oct(15))
0o17
4
>>> print(oct(15))
0o17
5
>>> print(oct(15))
0o17
6

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
Input:  8
Output: 10

Input:  15
Output: 17
97
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
Input:  8
Output: 10

Input:  15
Output: 17
99

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
03

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
06

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
09

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
12

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
14

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
16

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
18

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
22

Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
31

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
>>> print(oct(15))
0o17
0
>>> print(oct(15))
0o17
1

Input:  8
Output: 10

Input:  15
Output: 17
9

C

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
7

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
Input:  8
Output: 10

Input:  15
Output: 17
97
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
Input:  8
Output: 10

Input:  15
Output: 17
99

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
03

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
06

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
09

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
12

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
14

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
16

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
18

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
6
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
8
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
66

Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
31

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
>>> print(oct(15))
0o17
0
>>> print(oct(15))
0o17
1

Input:  8
Output: 10

Input:  15
Output: 17
9

C

Java

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
11
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
12

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
09
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
10

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
87
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
Input:  8
Output: 10

Input:  15
Output: 17
99

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
94
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
96
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
56
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
06

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
04
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
38

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
14

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
15
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
16
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
19
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
41
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
2
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
25

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
09
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
41
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
68

Input:  8
Output: 10

Input:  15
Output: 17
2
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
41

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
9

Python3

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
73
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
74
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
81
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
46

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
84
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
525
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
56

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
56
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
58

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
61
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
32
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
00

Input:  8
Output: 10

Input:  15
Output: 17
2
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
66
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
68
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
05
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
41

Input:  8
Output: 10

Input:  15
Output: 17
2
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
84
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
17
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
66
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
89
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
77

Input:  8
Output: 10

Input:  15
Output: 17
2
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
525
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
52
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
89
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
16

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
36
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
92

Input:  8
Output: 10

Input:  15
Output: 17
2
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
68
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
1212121212 ____185
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
41

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
93
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
94
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
97
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
98

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
>>> print(oct(15))
0o17
04

C#

>>> print(oct(15))
0o17
4
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
45

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
11
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
12

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
87
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
Input:  8
Output: 10

Input:  15
Output: 17
99

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
03

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
09

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
12

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
14

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
16

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
39
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
18

Input:  8
Output: 10

Input:  15
Output: 17
2
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
2
>>> print(oct(15))
0o17
35

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
>>> print(oct(15))
0o17
42
>>> print(oct(15))
0o17
43
>>> print(oct(15))
0o17
4444

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

Input:  8
Output: 10

Input:  15
Output: 17
2
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
41

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
9

JavaScript

Input:  8
Output: 10

Input:  15
Output: 17
60

Input:  8
Output: 10

Input:  15
Output: 17
01
>>> print(oct(15))
0o17
57

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
>>> print(oct(15))
0o17
60

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
>>> print(oct(15))
0o17
62

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
09

Input:  8
Output: 10

Input:  15
Output: 17
2
>>> print(oct(15))
0o17
67

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
14

Input:  8
Output: 10

Input:  15
Output: 17
2
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
16

Input:  8
Output: 10

Input:  15
Output: 17
2
>>> print(oct(15))
0o17
73

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
>>> print(oct(15))
0o17
777
>>> print(oct(15))
0o17
78
Input:  8
Output: 10

Input:  15
Output: 17
58

Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
88

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
31

Input:  8
Output: 10

Input:  15
Output: 17
91

Độ phức tạp về thời gian: O (log n)O(log N)

Không gian phụ trợ: O (1) O(1)

Sử dụng hàm được xác định trước

Java

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
09
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
10

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
11
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
12

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
>>> print(oct(15))
0o17
94
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
1

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
00

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
68

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
73
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
74
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

Input:  8
Output: 10

Input:  15
Output: 17
2
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
16

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
9

Python3

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
81
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
21

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
36
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
25
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
26

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
93
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
94
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
97
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
98

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
04
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
85
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
74
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
33

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
16

C#

>>> print(oct(15))
0o17
4
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
45

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
11
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
44

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
>>> print(oct(15))
0o17
94
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
1

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
56

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
68

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Input:  8
Output: 10

Input:  15
Output: 17
2
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

Input:  8
Output: 10

Input:  15
Output: 17
2
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
70

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
9

Input:  8
Output: 10

Input:  15
Output: 17
9

JavaScript

Input:  8
Output: 10

Input:  15
Output: 17
60

Input:  8
Output: 10

Input:  15
Output: 17
01
>>> print(oct(15))
0o17
57

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
79

Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input:  8
Output: 10

Input:  15
Output: 17
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
09

Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
16

Input:  8
Output: 10

Input:  15
Output: 17
91

C++

Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
85

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
>>> print(oct(15))
0o17
777
>>> print(oct(15))
0o17
78
Input:  8
Output: 10

Input:  15
Output: 17
58

Độ phức tạp về thời gian: O (log n)

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
94

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
96

Không gian phụ trợ: O (1)

Input:  8
Output: 10

Input:  15
Output: 17
9

Sử dụng hàm được xác định trước

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
2

Java

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
30b08

# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
09
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
10

Input:  8
Output: 10

Input:  15
Output: 17
9

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
>>> print(oct(15))
0o17
94
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
0
The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
1

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.
3
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
65
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
14
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
8
# Python program to convert decimal into other number systems
dec = 344

print("The decimal value of", dec, "is:")
print(bin(dec), "in binary.")
print(oct(dec), "in octal.")
print(hex(dec), "in hexadecimal.")
68


Làm thế nào để bạn chuyển đổi thập phân sang bát phân?

Trong thập phân thành nhị phân, chúng tôi chia số cho 2, theo số thập phân thành thập lục phân, chúng tôi chia số cho 16. Trong trường hợp thập phân thành Octal, chúng tôi chia số cho 8 và viết phần còn lại theo thứ tự ngược lại để có được số octal tương đương.divide the number by 8 and write the remainders in the reverse order to get the equivalent octal number.

Điều gì sẽ là cú pháp chính xác để chuyển đổi thập phân sang bát phân trong Python?

Hàm OCT () chuyển đổi một số nguyên thành một chuỗi octal.Chuỗi bát phân trong Python được tiền tố với 0O.oct() function converts an integer into an octal string. Octal strings in Python are prefixed with 0o .

Làm thế nào để bạn chuyển đổi 0,75 thành bát phân?

Phân số trong ký hiệu Octal (cơ sở 8) có thể được biểu thị chính xác trong ký hiệu thập phân.Ví dụ, 0,75 trong bát phân là 0,953125 (7/8 + 5/64) trong thập phân.Tất cả các số octal của N chữ số ở bên phải của điểm bát phân có thể được biểu thị bằng không quá 3n chữ số thập phân ở bên phải của điểm thập phân.0.953125 (7/8 + 5/64) in decimal. All octal numbers of n digits to the right of the octal point can be expressed in no more than 3n decimal digits to the right of the decimal point.

Làm cách nào để in một dạng bát phân trong Python?

Một ví dụ Python đơn giản để có được giá trị bát phân của số thập phân ...
# Python OCT () Ví dụ chức năng ..
# Chức năng gọi ..
val = tháng 10 (10).
# Hiển thị kết quả ..
In ("Giá trị bát phân 10:", Val).