VOOZH about

URL: https://www.geeksforgeeks.org/python/string-formatting-in-python-using/

⇱ Python Modulo String Formatting - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python Modulo String Formatting

Last Updated : 23 Jul, 2025

In Python, a string of required formatting can be achieved by different methods. Some of them are; 1) Using % 2) Using {} 3) Using Template Strings In this article the formatting using % is discussed. The formatting using % is similar to that of 'printf' in C programming language. %d - integer %f - float %s - string %x - hexadecimal %o - octal The below example describes the use of formatting using % in Python. 


Output
Variable as string = 15
Variable as raw data = '15'
Variable as integer = 15
Variable as float = 15.000000
Variable as printing with special char = m
Variable as hexadecimal = f
Variable as octal = 17...
Comment
Article Tags:
Article Tags: