Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created August 26, 2021 16:30
Show Gist options
  • Save pamelafox/f721b4c0e4eede9fefd5938042938628 to your computer and use it in GitHub Desktop.
Save pamelafox/f721b4c0e4eede9fefd5938042938628 to your computer and use it in GitHub Desktop.
Operator Expressions Exercise
from operator import add, sub, mul, truediv, floordiv, mod
"""
In the console, type expressions that use function calls
and correspond to each arithmetic expression.
Use the console to check your work.
Useful documentation:
https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
"""
# Q1: 30 + 2
# Q2: 30 - 2
# Q3: 30 * 2
# Q4: 30 / 2
# Q5: 30 % 2
# Nested!
# Q6: 30 + (2 * 4)
# Q7: 3 * (10 - 2)
# Challenge!
# Q8: (3 ** (365/52)) - 1
# Q9: (25 // 4) - (25 / 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment