From the course: Hands-On Introduction: Python
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Making calculations - Python Tutorial
From the course: Hands-On Introduction: Python
Making calculations
- [Instructor] Basic arithmetic is very straightforward in Python, whatever you would expect to work sort of does. Adding, subtracting, modulus, you name it. Now a good thing about Python is that additional data structures also behave sort of how you would expect, when it comes to arithmetic. So when we traverse our laureates, and we get to Albert Einstein, we may want to know how old he was, or just about how old he was when he won the Noble Prize. Now this may not be 100% accurate. It depends on when the laureate was born during the year. But for example, Python has this datetime data structure. We could import datetime here on the top, and datetime lets us create these data structures that are very straightforward to work with. And here on line 24, you'll notice, he receive the prize, so I tell the parser how to parse this. So just the year, and kind of complete the rest. And then the year he was born. So the…