Logbook 1 and 2
Logbook 1 and 2
Logbook 1 and 2
Software
Development
CP30681E CP3CS81E
Logbook
STUDENT NAME
STUDENT NUMBER
Table of Contents
Reflective Portfolio 3
Seminar week 1 4
Task Describe the different “layers” of Software that exist on a typical
computer and explain why there are different layers of software. 4
Task 1.2: Describe what an algorithm is and explain why it is a useful
“tool” to translate from a human level problem to a computer program.4
Task 1.3: Enter the following expressions in the Python IDLE and note
down the response to each. Do they differ from what you would
expect? 4
Seminar week 2 5
Task 2.1: Write an algorithm that describes how to make scrambled
eggs, try to use control words, like IF, WHEN, UNTIL, WHILE, WAIT,
AND, OR. 5
Task 2.2: List at least three advantages and disadvantages of an
interpreter and a compiler 5
Task 2.3: Is IDLE (the Python language shell) an Interpreter or a
Compiler? Explain your answer. 5
Task 2.4: Write a command in the IDLE shell that says “Hello world” 5
Task 2.5: Write a program that produces the following output: 5
Seminar week 3 6
Seminar week 4 7
Seminar week 5 8
Reflective Portfolio
Write a one page reflective portfolio for the first 5 weeks of the module.
Be critical and thorough. This is an opportunity for you to write what you
learnt, the benefits, the things you liked in these 5 weeks. In addition, do
not hesitate to state the challenges you faced, which includes things that
did not go right. Finally, avoid blaming others and be professional with
your writing.
2
Introduction to Software Development
Seminar week 1
Task 1.3: Enter the following expressions in the Python IDLE and note
down the response to each. Do they differ from what you would expect
Seminar week 2
Task 2.4: Write a command in the IDLE shell that says “Hello world”
Seminar week 3
Introduction to Software Development (ISD) Seminar week 3 Tasks: 1.
3
Introduction to Software Development
Write a Python program that introduces yourself following the same
pattern as below
2. Write a program that asks for two numbers, adds them up and
displays the result.
3. What do the following lines of code output? Why do they give a
different answer? ∙ print(2 / 3) ∙ print(2 // 3)
4.Write a Python program which accepts the user's first and last name
and print them in reverse order ( i.e. last name followed by first name
with a space between them)
5. Write a Python program that will accept the base and height of a
triangle and compute the area (Formula: base*height/2)
Seminar week 4
Tasks:
4
Introduction to Software Development
>>> print(area)
12.568
2. Consider the following code:
x = 19.93
y = 20.00
z=y–x
print(z)
Improve the code so that the output is only two decimal places.
Solution:
>>> x = 19.93
>>> y = 20.00
>>> z = y – x
>>>print(round(z, 2))
0.07
5
Introduction to Software Development
4. Write a Python program to print the calendar of a given
month and year.
(Hint: Use 'calendar' module)
Solution:
import calendar
y = int(input("Input the year : "))
m = int(input("Input the month : "))
print(calendar.month(y, m))
Solution:
>>> from tkinter import *
>>> screen = Tk() # this will create a new window, which
will pop up
>>> screen.title("hello") # this will caption the window
>>> welcome_message = Label(text = "welcome to my
first window", fg = "red", bg = "blue") # this will display a
6
Introduction to Software Development
welcome message on the window with foreground and
background colours
>>> welcome_message.pack()
>>> click_here = Button(text = "submit", fg = "red", bg =
"yellow") # this will create a button
>>> click_here.pack() # pack mean place the button in the middle.
You can use your own coordinates as well.
7
Introduction to Software Development
the following: • Concatenation (p+q+r) in capital letters • Concatenation
of (r + p) in lowercase • total number of characters within (p+q+r)
2. Write python program to allow the user to input his/her age. Then the
program will show if the person is an infant, child, a teenager or an adult.
3. Write a python program to compute body mass index (BMI). The
program should take input values such as weight and height in order to
calculate BMI and display it on the screen. In addition, the program
should display to the user whether the calculated BMI result corresponds
to underweight, healthy weight or overweight. Formula: weight (kg) /
[height (m)]2
8
Introduction to Software Development
Introduction to Software Development Seminar Week 8
Tasks: 1. Consider the following function: def mystery (x, y): result = (x +
y) / (y - x) return result What is the result of the call mystery (2, 3)? 2.
What does this program print? def main(): a = 5 b = 7 print(mystery(a, b))
def mystery(x, y): z = x + y z = z / 2.0 return z main()
3. What does this program print? def main(): a = 4 print(mystery(a + 1))
def mystery(x): y = x * x return y main()
9
Introduction to Software Development
5. Write a Python function to check whether a year (integer) entered by
the user is a leap year or not. Expected Output: Input a year: 2017 False
10
Introduction to Software Development
‘exit’). The program should then tell the user the total amount for the
products they have selected
Introduction to Software Development Seminar Week 11
Create a word document and answer the following questions. Where
there is coding involved, take a screenshot of the code along with the
output and attach it to the word document below each question.
Tasks: 1. a) Copy and paste the following code into your Python editor.
Check that the code runs and produces the output you expect. class
Student: def init (self, name, age, course, ID): self.name = name self.age
= age self.course = course self.ID = ID def print_details(self):
print("Name: " + self.name) print("Age: " + str(self.age)) print("Course: "
+ self.course) print("Student ID: " + self.ID) student1 = Student("Bob",
20, "Computer Science", "1000121") student2 = Student("Alice", 21,
"Computer Science", "1000475") student3 = Student("Jane", 18,
"Information Technology", "1000823") student1.print_details()
student2.print_details() student3.print_details() b)
At the end of the file, add code to prompt the user to enter detailsfor a
new student. Using these details, create a new object of class Student,
and call the print_details function to display the details of the new
student.Page 2 of 3 Example output: 2. a)
11
Introduction to Software Development
In a new Python program, copy and paste the following code: class
BankAccount: def init (self, account_number, balance):
self.account_number = account_number self.balance = balance def
print_balance(self): print("Account balance for account " +
self.account_number + " is: " + str(self.balance)) account1 =
BankAccount("123456789", 1000.00) account1.print_balance()
Check that the code runs and produces the output you expect. Create
two more BankAccount objects and call the print_balance function to
display the balance of these accounts. Example output: b)
Add another attribute to the BankAccount class, to store the name of the
account holder. Modify the constructor function as necessary, and
modify the print_balance function so that it also prints out the account
holder’s name. Add a new function to the class, called print_name, which
prints the account number and the name of the account holder. At the
end of the program, call this function on the objects you have created, to
12
Introduction to Software Development
show the names of the account holders. Example output:Page 3 of 3 c)
Add two new functions to the BankAccount class, one called withdraw
and one called deposit. The withdraw function should take one
parameter, and should deduct the amount passed in the parameter from
the account balance. The deposit function should also take one
parameter, and should add the amount passed in the parameter to the
account balance. At the end of your program, call both functions on the
objects you have created. Then call the print_balance function to sh
13
Introduction to Software Development
store the price of the product A variable self.prime_eligible, which can
have a value of either True or False to indicate whether or not the
product is eligible for Amazon Prime A variable self.number_in_stock to
store the number of this product currently in stock A variable
self.date_added to store the date when the product was added to the
Amazon website
2. Write the following functions for your Product class: a. A constructor
function ( init ) b. Setter and getter functions for each of the data fields in
the Product class c. A print() function which prints the values of all the
data fields.
3. Next, define a new class, called Book, which inherits from the Product
class. The Book class should have the following five data fields in
addition to the ones it inherits from the Product class: A variable self.title
to store the book titlePage 2 of 2 A variable self.author to store the name
of the book’s author A variable self.num_pages, to store the number of
pages in the book A variable self.publisher to store the name of the
publisher A variable self.publication_date to store the date when the
book was published.
4. Write the following functions for the Book class: a. A constructor
function ( init ) - this should call the constructor function of the parent
class, and then set the additional five data fields of the Book class b.
Setter and getter functions for each of the five new data fields in the
Book class c. A print() function which prints the values of all the data
fields – this should call the print() function of the parent class, and then
also print the remaining data fields that belong to the Book class
5. Look on Amazon for three different books. Using the information on
the Amazon website, create three objects of class Book in your code.
Test your code by calling the print() function and getter and setter
methods on the three Book objects you have created
14
Introduction to Software Development
15
Introduction to Software Development
16
Introduction to Software Development