Learn Python Coding
38.7K subscribers
1.06K photos
37 videos
24 files
853 links
Learn Python through simple, practical examples and real coding ideas. Clear explanations, useful snippets, and hands-on learning for anyone starting or improving their programming skills.

Admin: @HusseinSheikho || @Hussein_Sheikho
Download Telegram
There's a floating-point number in Python and you need to output it as a percentage - use the % format in the f-string

x = .023
print(f'{x:.2%}')  # 2.30%

x = .02375
print(f'{x:.2%}')  # 2.38% -- rounded off!

x = 1.02375
print(f'{x:.2%}')  # 102.38%


👉 @PythonRe
Please open Telegram to view this post
VIEW IN TELEGRAM
6