From 90b4e73ea4f624e482db7af3bffca0928bb818ab Mon Sep 17 00:00:00 2001 From: Aidan Baird <102356055+AidanBaird@users.noreply.github.com> Date: Tue, 24 May 2022 22:09:50 +0100 Subject: [PATCH] Add files via upload --- Make_a_function_that_does_arithmetic_kyu8.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Make_a_function_that_does_arithmetic_kyu8.py diff --git a/Make_a_function_that_does_arithmetic_kyu8.py b/Make_a_function_that_does_arithmetic_kyu8.py new file mode 100644 index 0000000..9feb09a --- /dev/null +++ b/Make_a_function_that_does_arithmetic_kyu8.py @@ -0,0 +1,14 @@ +# # A function that foes arithmetic with two numbers and an operator in string form. +# Works out the correct operator by using ifs then returns + +def arithmetic(a, b, operator): + if operator == "add": + return a + b + elif operator == "subtract": + return a - b + elif operator == "multiply": + return a * b + elif operator == "divide": + return a / b + else: + return "Error" \ No newline at end of file