F-Strings decilamal places 1

F-Strings decilamal places

#!/usr/bin/env python3

a = 300

# hexadecimal
print(f"{a:x}")

# octal
print(f"{a:o}")

# scientific
print(f"{a:e}")

Here is what the above code is Doing:
1. The first line is a shebang. It tells the operating system that this file is a Python script and that it should be run by the Python interpreter.
2. The second line is a comment. It’s ignored by the Python interpreter.
3. The third line is a variable assignment. It creates a variable named a and assigns it the value 300.
4. The fourth line is a print statement. It prints the value of a in hexadecimal format.
5. The fifth line is a print statement. It prints the value of a in octal format.
6. The sixth line is a print statement. It prints the value of a in scientific format.

Similar Posts