Create an integer variable by assigning octal value in Python

Program

a = 0o1234567
b = 0o7654321
c = 0o1745
d = 0o100
e = 0o123

# printing types
print("type of the variables...")
print("type of a: ", type(a))
print("type of b: ", type(b))
print("type of c: ", type(c))
print("type of d: ", type(d))
print("type of e: ", type(e))

# printing values in decimal format
print("value of the variables in decimal format...")
print("value of a: ", a)
print("value of b: ", b)
print("value of c: ", c)
print("value of d: ", d)
print("value of e: ", e)

# printing values in octal format
print("value of the variables in octal format...")
print("value of a: ", oct(a))
print("value of b: ", oct(b))
print("value of c: ", oct(c))
print("value of d: ", oct(d))
print("value of e: ", oct(e))

Output

Create an integer variable by assigning octal value in Python

Leave a Comment

error: Alert: Content is protected!!