-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP14_Casting.py
More file actions
25 lines (23 loc) · 871 Bytes
/
P14_Casting.py
File metadata and controls
25 lines (23 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File: main.py
# Author: Armstrong Subero
# Platform: Raspberry Pi Pico (RP2040) with MicroPython
# Program: P14_Casting
# Interpreter: MicroPython (latest version)
# Program Version: 1.0
#
# Program Description: This program demonstrates type casting in Python by
# converting a user-provided decimal number into its
# binary, octal, and hexadecimal representations.
# It showcases how Python can easily cast between
# different number systems.
#
# Hardware Description: No special hardware is required.
#
# Created: August 23rd, 2024, 6:30 PM
# Last Updated: August 27th, 2024, 10:13 PM
# Modified from example code by Dogan Ibrahim
dec = int(input("Enter a number: "))
print("Decimal: ", dec)
print("Binary: ", bin(dec))
print("Octal: ", oct(dec))
print("Hex: ", hex(dec))