Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #math operators
- #+ - * / // % ** **(1/n)
- a = 3 ; b = 2
- theSum = a + b #5
- print(theSum,end="\n") #writes the expression to the stdout stream / standard output stream
- theDif = a-b #1
- print(theDif)
- print(theSum, theDif, sep=" | ")
- print(theSum, sep=" | ")
- print(theDif)
- a=30;b=2
- floatingPointDivision = realDivision = a/b #15.0
- print(realDivision)
- integerDivision = a//b #15
- print(integerDivision)
- a=3;b=2
- remainderOfTheIntegerDivision=a%b #1
- print(remainderOfTheIntegerDivision)
- aSquared = a**2
- print(aSquared) #9
- squareRoot = aSquared**(1/2)
- type(squareRoot) #float
- print(squareRoot)
- print("squareRoot= "+str(squareRoot))
- print("squareRoot=", squareRoot)
- print("squareRoot= {}".format(squareRoot))
- print("squareRoot= {:3.1f}".format(squareRoot))
- print("squareRoot= %3.1f"%(squareRoot))
- #d decimal | s string | x hexadecimal | o octal
- d=123; s="Hello!"
- print("decimal=%d o=%o h=%x ; frase=%s" \
- %(d, d, d, s))
- for n in range(256): #col [0..255]
- strDecimalAndHexa = "n= %3d h= %2x"%(n,n)
- print(strDecimalAndHexa)
- #for
Add Comment
Please, Sign In to add comment