We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 045ec95 commit 7ec8386Copy full SHA for 7ec8386
conv.py
@@ -0,0 +1,18 @@
1
+def convert_number(decimal_number):
2
+ # Convert to binary, octal, and hexadecimal
3
+ binary_rep = bin(decimal_number)
4
+ octal_rep = oct(decimal_number)
5
+ hex_rep = hex(decimal_number)
6
+
7
+ # Display the results
8
+ print(f"Decimal: {decimal_number}")
9
+ print(f"Binary: {binary_rep}")
10
+ print(f"Octal: {octal_rep}")
11
+ print(f"Hexadecimal: {hex_rep}")
12
13
+# Input from the user
14
+try:
15
+ decimal_input = int(input("Enter a decimal number: "))
16
+ convert_number(decimal_input)
17
+except ValueError:
18
+ print("Please enter a valid decimal number.")
0 commit comments