Reference no: EM133087642
ITECH1400 Foundations of Programming
Question 1. Briefly describe four key characteristics of a complex problem.
Question 2. In your own words, describe what debugging source code is and explain why may need to debug our code. Name the category of software tool used to debug source code.
Question 3. Sort the following series of values into ascending order using the Bubble Sort algorithm. Write out the complete row of numbers each time two values change places and circle the two values that have changed places.
Question 4. When testing software we may either perform black-box testing or white-box testing. Describe the key characteristics of each of these testing methods. If we were performing unit-testing, which of these to testing methods would we be using?
Question 5. In your own words explain what type of data can be stored in the following primitive data types: integer, float, string and boolean.
Question 6. In programming we use for-loops to either run sections of code a specific number of times, or to iterate over lists. In this question we're looking at the latter of these uses where we'll work with lists generated via the range statement. As such, write code that will:
a.) Print out the values 1 through 10 inclusive (i.e. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10).
b.) Print out the values 10 through 20 inclusive in steps of 2 (i.e. 10, 12, 14, 16, 18, 20),
c.) Print out the values between 10 and -11 in steps of -3 (i.e. 10, 7, 4, 1, -2, -5, -8, -11).
Question 7. In terms of programming, in your own words describe what a function is and how functions operate. In what way are functions different to methods? In your answer be sure to mention any input characteristics a function may have (i.e. arguments / parameters) and any return types.
Also, briefly explain the difference between an argument and a parameter.
Question 8. When writing programs we may want to persist data so that the data exists on file rather than just in memory while the program is running. Write a small amount of code which will write the following list of groceries to a file called shopping_list.txt (with each item on a separate line) and then save and close the file:
groceries = ['Bread', 'Milk', 'Sugar', 'Oranges']
Question 9. Write Python code to create a class called Car which represents a car. The Car class should have properties of make, model and owner (i.e. whose car is it). The class should also have a constructor that takes these parameters to initialise the object, and a method called drive that prints out the phrase 'The car drives away into the sunset...' to the screen.
After you have defined the Car class, create a Car object called test_car with a make of 'Ford', a model of 'Focus' and an owner of 'Emily'. Once the object has been created, call the drive() method on it.
Question 10. When writing programs, one of the goals of our programs is that they do not crash - and one mechanism that we may use to ensure that our programs are robust is to use exception handling.
Briefly explain what exception handling is and how we can use it to ensure our programs don't crash.
Question 11. Software libraries are pieces of code that perform functionality that may be time- consuming or difficult for us to write ourselves. As such, by using a software library we can cut down on development time.
In your own words, and with respect to software libraries which can be used with the Python
programming language, explain how you might go about performing the following tasks:
a.) Identifying suitable libraries,
b.) Obtaining any suitable library you've identified, and
c.) Using the software library (just in general, not how to use a specific software library).
In your answer name two examples of specific software libraries that you have used during this course.
Question 12. When writing software that uses a graphical user interface (GUI) our program will operate using the mechanism of event driven programming.
Explain what event driven programming is and how it operates. In your answer, briefly discuss how event driven programming operates differently from standard 'procedural / command-line' programming.
Question 13. When profiling a computer program, two of the main things that we want to identify are
bottlenecks and hotspots. In your own words explain what bottlenecks and hotspots are.
Question 14. The way in which high-level source code (such as a Python .py file) is translated into machine code suitable for execution can be broken down into three main areas:
- Interpretation,
- Compilation, and
- Hybrid Techniques.
Very briefly explain the key characteristics of each of the above high-level to low-level source translation mechanisms.
Finally, rank the typical execution of speed of each into the categories of: Fastest, Slowest and
Intermediate.
Question 15. When solving problems we may decide to use the six-step problem solving process in order to solve it. List down the commonly accepted six steps and the order in which they occur if this process is to be used.
Question 16. Below is an algorithm (i.e. a series of steps and the sequence in which they should be performed) to perform the operation "Make a cup of tea for someone".
1) Boil at least 200ml of water,
2) Find a clean cup,
3) Put a teabag in the cup,
4) Pour the boiling water into the cup until it is three quarters full,
5) Leave the tea to brew for a few minutes.
6) Ask whether the person takes sugar in their tea.
a) If so, add the required number of sugars into the cup.
b) If not then simply continue.
7) Ask whether the person takes milk in their tea.
a) If so, add a small amount of milk into the cup.
b) If not then simply continue.
8) Stir the tea and serve it to the person.
Draw an activity diagram / flowchart of this process. In your answer, be sure to use the correct symbols for:
- Starting the process (a circle),
- Ending the process (a circle with a black centre),
- A process (a rectangle), and
- A decision (a diamond).
Attachment:- Foundations of Programming.rar