An attribute can be a number, so no need for the |int, and state_attr() protects against non-existent attributes. See the warning box at the end of this section: Templating - Home Assistant
No need to apologise, we’re all here to learn. You can try out your templates in the template tool, which is how I confirmed the second bit of my answer using a suitable entity on my system: