Learning Objective: to understand data types and data structures used in programming.
Theory:
We’ll be covering some basic programming theory to link up with what we looked at last year in transition.
Programming:
- Programming Task 1: Write the following functions in Python, saved to a file called calculator.py
– fnAddNumbers(numFirst, numSecond)
– fnSubtractNumbers(numFirst, numSecond)
– fnMultiplyNumbers(numFirst, numSecond)
– fnDivideNumbers(numFirst, numSecond)
To test your code, copy the calculatorTest.py file from the Resources folder in Compass (under ‘Programming Samples’) into the SAME folder as your program. Open it in IDLE and execute the code. Do not use raw_input() or ask a user to input numbers. - Programming Task 2: Write a program that works like a calculator – a user is asked for two numbers, and then chooses: add, subtract, multiply, divide. The program should return the correct values, using your functions from the last task. Its interface, while text, should be consistent and easy to use.
- Programming Task 3 (Optional): Expand your program to include other mathematical calculations, such as square root, exponential functions, trigonometric functions, etc.
Homework:
Theory: Finish the Context Questions given out in class (Chapter 1, Q1-4) Due: Monday, 12th Feb.
Theory: Complete questions 1-9 from Chapter 6 of your textbook (Page 77). Due: Monday, 12th Feb.
Programming: Complete the programming tasks 1 & 2 listed above. You are encouraged to also complete Task 3. Due: Wednesday, 14th Feb.