SHARE
TWEET

Untitled

a guest Sep 19th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Let's say we want a math equation.
  2.  
  3. Note that math equations can be used in conjuction with what we've learnt. (Variables, strings, conversions, and more to come!)
  4.  
  5. Let's say we'd like to print out the sum of 5 * 5, it's fairly easy!
  6.  
  7. We'd use this syntax: print(5*5), this shows python that we're giving it an equation to print out 5*5.
  8.  
  9. Math symbols in python:
  10. / - division
  11. * - multiplication
  12. - - subtraction
  13. + - addition
  14. % - modulo operator - this gives the remainder of a division calculation, ex: 5%5 will return 0.
  15. ** - exponent operator, ex: 4 ** 0.5, this'd return 4 to the half power.
  16.  
  17.  
  18. Here's some extra examples:
  19.  
  20. my_new_var = 5 % 5
  21. my_new_string = "cool!"
  22. print("My new string is" + str(my_new_string) + 'and my modulo operator has resulted in:' + str(my_new_var")
  23.  
  24. # Note that the datatype(obj_name) method does not change the existing object, however it does create a new instance of this object.
  25. I recommend saving it to a variable for safekeeping/replacement, or changing the existing variable.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top