Posts

Showing posts from July, 2020

Python Notes

Image
PythonNotes Output ¶ In [2]: print ( 123 ) 123 printf syntax ¶ In [12]: print ( " %s " % ( "Hello" )) print ( " %d , %03d " % ( 1 , 1 )) print ( " %f , %.3f " % ( 0.2 , 0.2 )) print ( " %e , %E " % ( 300000000 , 300000000 )) print ( " %.1e , %.0E " % ( 300000000 , 300000000 )) Hello 1 , 001 0.200000, 0.200 3.000000e+08, 3.000000E+08 3.0e+08, 3E+08 Format string syntax ¶ In [13]: print ( " {x:.2f} " . format ( x = 64.89999 )) #{[name a variable]:[assigns a format]} 64.90 Type Conversion ¶ In [16]: a = 1 b = 1.0 c = "c" print ( type ( a )) print ( type ( b )) print ( type ( c )) <class 'int'>...