Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Let's say we want a math equation.
- Note that math equations can be used in conjuction with what we've learnt. (Variables, strings, conversions, and more to come!)
- Let's say we'd like to print out the sum of 5 * 5, it's fairly easy!
- We'd use this syntax: print(5*5), this shows python that we're giving it an equation to print out 5*5.
- Math symbols in python:
- / - division
- * - multiplication
- - - subtraction
- + - addition
- % - modulo operator - this gives the remainder of a division calculation, ex: 5%5 will return 0.
- ** - exponent operator, ex: 4 ** 0.5, this'd return 4 to the half power.
- Here's some extra examples:
- my_new_var = 5 % 5
- my_new_string = "cool!"
- print("My new string is" + str(my_new_string) + 'and my modulo operator has resulted in:' + str(my_new_var")
- # Note that the datatype(obj_name) method does not change the existing object, however it does create a new instance of this object.
- I recommend saving it to a variable for safekeeping/replacement, or changing the existing variable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement