Answers for "float in printf"

3

float print format python

print("x = {:.2f}".format(x))
Posted by: Guest on April-06-2021
0

python3 print format float

numbers = [23.23, 0.123334987, 1, 4.223, 9887.2]

for number in numbers:
    print(f'{number:.4f}')
Posted by: Guest on November-27-2020
3

printf format specifiers c

/* printf example in C */
#include <stdio.h>

int main()
{
   printf ("Characters: %c %c n", 'a', 65);
   printf ("Decimals: %d %ldn", 1977, 650000L);
   printf ("Preceding with blanks: %10d n", 1977);
   printf ("Preceding with zeros: %010d n", 1977);
   printf ("Some different radices: %d %x %o %#x %#o n", 100, 100, 100, 100, 100);
   printf ("floats: %4.2f %+.0e %E n", 3.1416, 3.1416, 3.1416);
   printf ("Width trick: %*d n", 5, 10);
   printf ("%s n", "A string");
  
   return 0;
}


//*******

Characters: a A
Decimals: 1977 650000
Preceding with blanks:       1977
Preceding with zeros: 0000001977
Some different radices: 100 64 144 0x64 0144
floats: 3.14 +3e+000 3.141600E+000
Width trick:    10
A string
Posted by: Guest on April-04-2020

Python Answers by Framework

Browse Popular Code Answers by Language