Below is the learning for today as part of the #30daysofML challenge
- Variable assignment
- Print function
- #commenting the code in Python
- Variable reassignment
- Writing conditional statements using if
The colon (:) at the end of the if line indicates that a new code block is starting
The * operator can be used to multiply two numbers (3 * 3 evaluates to 9), but we can also multiply a string by a number, to get a version that's been repeated that many times. Python offers a number of cheeky little time-saving tricks like this where operators like * and + have a different meaning depending on what kind of thing they're applied to.
What is type function used for ?
type(spam_amount)
The // operator gives us a result that's rounded down to the next integer.
print(float(10))
print(int(3.33))
# They can even be called on strings!
print(int('807') + 1)
No comments:
Post a Comment