Python Operators are: 1. Addition: + 2. Subtraction: - 3. Multiplication: * 4. Division: / Parentheses can be used for grouping. Try the following scripts (“>>>” is the Python command prompt): >>> 9+9 [Enter] 18 >>> 3*7 21 >>> (5*4)+3 23 >>> (40-3*8)/4 4 To assign a value to a variable use “=”: >>> a=4 >>> b=6 >>> a*b 24 Dividing integers will give the answer rounded down to the nearest integer, also known as the floor: >>> 9/4 2 >>> 9/-4 -3 In order to divide and return a decimal answer, “floating point” form must be used: >>> 9.0/4 2.25 Downloaded from http://www.wikihow.com
Design a Mobile Website
View Site in Mobile | Classic
Share by: