Python Guide V1.2.11

Xxa6 xrais likexxa6 similarly for output

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: or!pseudorandom!numbers! • random.random() uniform in [0,1)! • random.seed(n)!#!resets!random!number!stream! • random.randrange(a,b) uniform int in [a,b)!! • x!=!y!makes identifier!x!refer to!the same object that!y! refers to! • x,y!=!a,b!is like x!=!a;!y6=!b! • x,y!=!y,x!swaps values of x and6y! • x!+=!a!is like!x!=!x!+!a6! • x!R=!a!is like!x!=!x!–!a6! • similarly for!*=,!/=,!//=,!%=,!**=! Output with old style formatting • Command:!print!3,5,(1,2)!displays blanks between 3!5!(1,!2) • "%d6and6%f:6%s"!%!(3,5.6,"pi")! !"36and65.600000:6pi"! • Conversion specifiers: %s string version, same as str(x) %r best representation, same as repr(x) %c shows number as a character, same as chr(x) %d an integer %0nd an integer left padded with zeros, width n %f decimal notation with 6 decimals %e,6%E scientific notation with e or E %g,6%G compact number notation with e or E %nz format z right-adjusted, width n %Rnz format z left-adjusted, width n %n.mz! format z: m decimals, width n %% a literal % sign while contr...
View Full Document

Ask a homework question - tutors are online