Python Guide V1.2.11

boolean two aliases for 1 and 0 respectively boolx

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: ;The6literal6starts6here6and6goes6on6'line6 after6line'6until6three6more6quotes.""" • Boolean: two aliases for 1 and 0 respectively: bool(x)! True or False! Any zero or empty value can be used as False in a boolean expression; other values mean True! • type("age")! !<type!'str'> Math operators: int type result if x and y are int y • Power (x ): x**y! • Times (x×y): x6*6y! • Divide by (x÷y): x6/6y or x6//6y! // result value is always integer, but not type; ! / result value is integer when both x and y are.! • Remainder (x mod y): x6%6y! • Add (x+y): x6+6y! • Subtract (x–y): x6–6y! Operators with boolean result • • • • • ! ! Compare: <, <=, !=, ==, >=, >! x6>6y either True or False!(1 or 0) 36<=6x6<65!means!3!<=!x!and!x!<!5! x6is6y means x, y refer to the same object (T/F)! x6in6y means x is found inside y!(T/F) ! Evaluation Order from High Priority to Low Built-in functions: dir(__builtins__) • **:!R2**2**3 is like –(2**(2**3)) • • • • • • • • •...
View Full Document

This document was uploaded on 02/14/2014 for the course COMP 1012 at Manitoba.

Ask a homework question - tutors are online