代写 data structure algorithm game math python shell operating system graph ISYS90088

ISYS90088
Introduction to Application Development
School of Computing and Information Systems University of Melbourne Semester 2 , 2018
Dr Antonette Mendoza
* Some slides are adapted from Fundamentals of Python by Kenneth A. Lambert and dept. resources

Lecture Agenda
l Introduction
l Objectives
l Staff;Learning&Assessment
l What is a computer, and how do we talk to it?
l Python
l Grok
l Python Basics – print, input, strings
ISYS90088 sem 2 2018
1-2

About me (Antonette)
l PhD in Computer Science – UoM
l 17 years @ UoM teaching
l Three Dept. and MSE Teaching Awards
l UniversityofMelbourneEdwardBrownTeachingAward(2017)
l AustralianAwardforUniversityTeachingaward(2017)
l Computing Research and Education (CORE) teaching award (2018)
l Coordinator – Tutor development Program in the MSE; New academic teaching development program in MSE; Graduate research coordinator in CIS
ISYS90088 sem 2 2018 3

About me (Antonette)
l Research focus:
Ø Expertise lies in the area of process modelling, design and development of emerging
technologies that support positive computing, adoption and longer-term use.
Ø Interests extend to exploring the impact of wider range of technologies that include mobile applications and social media platforms on society including health care, e- learning and telework.
l Grants:
Ø Ø
Ø Ø
Australian Research Council grant 2016 – 2018 Ø “Catering for individuals’ emotions in technology development”
CRC Low Carbon Living grant 2014 – 2017
Ø Increasing knowledge and motivating collaborative action on low carbon living through team-based and game-based
mobile learning’.
Other grants include: Learning and teaching grant 2015-2016; predictive tool for depression care NHMRC grant 2014 – 2015; aged care touch frame project; VVP project for industry client;
iPad app for assessment and feedback “Rapid Feedback” on iTunes in 2016. ISYS90088 sem 2 2018 4

About me (Antonette)
Contact details:
l Office:Room6.03DougMcDonnellBuilding
l Email: mendozaa@unimelb.edu.au
l Consultation: By appointment ( email me and I will give you a time to meet)
ISYS90088 sem 2 2018 1-5

Setting Expectations
What is Programming?
What is a Software development life cycle?
Is it important?
What do you expect to learn from this subject?
ISYS90088 sem 2 2018 6

What we will be studying
l Fundamentalconceptsandmodelsofapplicationdevelopment
l Students who have no background in application development or
programming.
l Learnaboutthesoftwaredevelopmentlifecycle,programdesign, data structures, problem solving, programming logic, implementation considerations, testing and enterprise level applications.
ISYS90088 sem 2 2018 1-7

Objectives
l Learn to use primitive data types and data structures
l Understand basic programming concepts
l Writesimpleapplicationsthatrelatetoaspecificdomain
l Design,implement,test,anddebugaprogramthatuseseachofthe following fundamental programming constructs: basic computation, simple I/O, standard conditional and iterative structures, and the definition of functions.
l Test applications
ISYS90088 sem 2 2018 1-8

Learning and Assessment
l Lectures, Labs
l Assessment
l Textbook & references
ISYS90088 sem 2 2018 1-9

Learning and Assessment
Lectures: Tuesday 2.15pm – 4.15pm in Redmond Barry (Lyle Theatre) Labs: 8 scheduled labs across the week – attend any one!
Workshop 1 Workshop 2 Workshop 3 Workshop 4 Workshop 5 Workshop 6 Workshop 7 Workshop 8
Tuesday18:15 Wednesday Wednesday Wednesday Thursday
Thursday
Thursday
Friday 17:15
Alan Gilbert-111
20:15 17:15 19:15 16:15 19:15 17:15 16:15
19:15 21:15 18:15 21:15 19:15 18:15 19:15
Alan Gilbert-111
Alan Gilbert-111 Engineering B-102
Alan Gilbert-111
Elec. Engineering-121 PAR-Engineering B-102 PAR-Alan Gilbert-111
ISYS90088 sem 2 2018 1-10

Learning and Assessment
Tentative Schedule:
l Week 01: Introduction
l No workshops in week 01
l Week02: Software development, data types and expressions
l Worksheet 1 – simple print and input stmt + how to work with grok + idle download
l Week03: math function + Conditions – for /while/if statement
l Worksheet 2 – data types, expressions
l Week04: Strings/sequences + math functions + Release ass 1 (10%)
l Worksheet 3 – related to if/for/while statement
ISYS90088 sem 2 2018 1-11

Learning and Assessment
Tentative Schedule:
l Week05: complete sequences+ Functions
l Worksheet 4 – sequences and conditions + assignment 1
l Week06: Complete Functions – submit assignment 1
l Worksheet 5 – functions & ass 1
l Week07: Mid-semester test (10%)
l Worksheet 6 – Review so far!
l Week08: Iteration – for loops + while
l Worksheet 7 – iteration
ISYS90088 sem 2 2018 1-12

Learning and Assessment
Tentative Schedule:
l Week09: complete + lists _ release assignment 2 (20%)
l Worksheet 8 – feedback mid semester test + work on assignment 2
l Week10: lists/dictionary
l Worksheet 9 – list/dictionary + assignment 2
l Week11: advanced functions & File I/O – submit assignment 2
l Worksheet 10 – advanced functions
l Week12: Any outstanding + exam revision (60%)
l Worksheet 11 – practice questions and/or catch-up
ISYS90088 sem 2 2018 1-13

Learning and Assessment
Assessment:
l Individual Assignment 1 (10%) due in Week 6
l One mid-semester test (10%) in Week 7
l Individual Assignment 2 (20%) due in Week 11
• Exam (60%) – end of semester (3hr and will be a hurdle)
ISYS90088 sem 2 2018 1-14

Learning and Assessment
Text books/references:
l Youmayuseanytextbookandreferences. l Somebooks/references:
Ø FundamentalsofPython–KennethA.Lambert Ø Therearegoodonlineresources(free)
Ø Check out: www.python.org
ISYS90088 sem 2 2018 1-15

LMS
l University’s “Learning Management System” l http://www.lms.unimelb.edu.au/
l Use your university email id and password
ISYS90088 sem 2 2018 1-16

A word about the LMS & other environments
l We will post all code from lectures (other than snippets from the \console”) on the LMS after each lecture;
Ø Itisagoodideatolookbackoverthecodetoensureyoufully understand it and play around with it yourself
Ø Make sure to attend Tutorials and labs
l You will work on GROK environment for your labs and assignments
ISYS90088 sem 2 2018 1-17

Academic Honesty
Ø In accordance with the University’s Academic Honest and Plagiarism Policy (which you should familiarize yourself with!):
https://academichonesty.unimelb.edu.au/
Ø All examinable work (GROK worksheet answers and all project work) that you submit for this subject must be your own!!
ISYS90088 sem 2 2018 1-18

Academic Honesty
Ø Commoncausesofbreachesinthepasthavebeen:
ü friendsaskingtolookoveryourcodeto“gethints” fortheir
own project
ü flatmatesaccessingyourcodeviaashareddesktopcomputerwith saved login details
ü studygroupswherethefacilitatorhasoversteppedthelineand provided sample code to help people along
ISYS90088 sem 2 2018 1-19

Academic Honesty
Ø Common attempts to escape undetected are:
ü changing the comments but not the code
ü changing variable names
ü rearrangingblocksofcode(sometimesbreakingthelogicinthe process!)
Ø Itisalltooeasytoautomaticallypickuponallofthese,andmany, many more, approaches using software plagiarism detection software … and we do check
ISYS90088 sem 2 2018 1-20

So what is appropriate?
Ø Youareencouragedtoshare/collaboratedirectlyoncodeforany non-examinable items (notably the worksheets questions) … and you will learn a lot from reading the code of others (including the sample solutions in the worksheets)
Ø Youareverywelcometodiscusswithfellowclassmatesyourapproach to worksheet questions and the projects, in conceptual terms, or in
terms of key data types or programming constructs used (just not with the aid of raw code)
ISYS90088 sem 2 2018 1-21

Break!!!!

Lecture Objectives
After completing this lecture, you will be able to:
l Describethebasicfeaturesofanalgorithm
l Explainhowhardwareandsoftwarecollaborateinacomputer’s architecture
l Compose and run a simple Python program
ISYS90088 sem 2 2018 23

Algorithms & Information Processing
Ø Computer science focuses on l Algorithms
l Information processing
ISYS90088 sem 2 2018 24

Algorithm – what is it?
Ø Sequenceofstepsthatdescribeseachofthesecomputational processes is called an algorithm
Ø Featuresofanalgorithm:
l Consistsofafinitenumberofinstructions
l Eachindividualinstructioniswelldefined
l Describesaprocessthateventuallyhaltsafterarrivingatasolution to a problem
l Solvesageneralclassofproblems
ISYS90088 sem 2 2018 25

Algorithm – example!
l Stepsformakingacupofcoffee!!!
Ø Imaginethatyouwantarobot(orafriend)tomakeit.
Ø Howwillyouexplainthisproceduretotherobot(oryourfriend)so they can make it?
ISYS90088 sem 2 2018 26

Algorithm – another example!
Ø Stepsforsubtractingtwonumbers:
l Step 1: Write down the numbers, with larger number above smaller
one, digits column-aligned from right
l Step2:Startwithrightmostcolumnofdigitsandworkyourway left through the various columns
l Step3:Writedowndifferencebetweenthedigitsinthecurrent column of digits, borrowing a 1 from the top number’s next column to the left if necessary
l Step4:Ifthereisnonextcolumntotheleft,stop
l Otherwise, move to column to the left; go to Step 3
Ø The computing agent is a human being
ISYS90088 sem 2 2018 27

Information Processing
Ø Informationisalsocommonlyreferredtoasdata
Ø Dataneedstobeorganizedandstoredinsomeformtoberelevant
and easily accessed!
Ø In carrying out the instructions of an algorithm, computing agent manipulates information
l Start with inputàdo something/taskàproduce output
ISYS90088 sem 2 2018
28

Structure of a Modern Computer System
Ø Amoderncomputersystemconsistsofhardwareandsoftware
l Hardware: physical devices required to execute algorithms
l Software:setofthesealgorithms,representedasprogramsin particular programming languages
ISYS90088 sem 2 2018 29

Computer Hardware
ISYS90088 sem 2 2018 30

Computer Hardware (continued)
Ø Random access memory (RAM) is also called internal or primary
Ø Externalorsecondarymemoryexample:cd;floppies magnetic disks; optical disks!!!
ISYS90088 sem 2 2018 31

Computer Software
Ø A program stored in computer memory must be represented in binary digits, or machine code
Ø Aloadertakesasetofmachinelanguageinstructionsasinputandloads them into the appropriate memory location
Ø Themostimportantexampleofsystemsoftwareisacomputer’s operating system
o Some important parts: file system, user interfaces (terminal-based or GUIs)
Ø Applications include Web browsers, games, etc.
ISYS90088 sem 2 2018 32

Computer Software (continued)
ISYS90088 sem 2 2018 33

Getting Started with Python Programming
Ø Early 1990s: Guido van Rossum
l invented the Python programming language
Ø Pythonisahigh-level,general-purposeprogramminglanguagefor solving problems on modern computer systems
Ø Usefulresourcesatwww.python.org
ISYS90088 sem 2 2018 34

Running Code in the Interactive Shell
Ø Python is an interpreted language
Ø Simple Python expressions and statements can be run in the shell
l Easiest way to open a Python shell is to launch the IDLE (Integrated DeveLopment Environment)
l To quit, select the window’s close box l Shellorcommandlineisusefulfor:
l Experimenting with short expressions or statements l Consulting the documentation
ISYS90088 sem 2 2018 35

Running Code in the Interactive Shell (continued)
ISYS90088 sem 2 2018 36

Input, Print, String Processing & Output
Ø Programsusuallyacceptinputsfromasource,processthem,and output results to a destination
l In terminal-based interactive programs, these are the keyboard and terminal display
ISYS90088 sem 2 2018 37

The print statement
A print statement evaluates the expression and displays them, separated
by one space, in the console window
l Syntax:
print (, …, ) Example:
>>>print (3)
3
l Ifyouwanttodisplayatext(inpythoncalledastring),thenthe string must be enclosed within quotations – single or double
ISYS90088 sem 2 2018 38

Strings in python
l Thewordstringisusedtodescribeapieceoftextinsidequotes.
l You’ve seen how Python can be used to manipulate numbers, but it is also useful to be able to manipulate text.
l The things you type into a Python program are expected to be Python commands.
Example:
>>>print (“hi there”) >>>print (‘hi there’)
>>>print (“what’s she doing”)
Lets run this and see what happens!!!!!
ISYS90088 sem 2 2018 1-39

Strings in python
l Suppose you want to represent the words Hello There as text inside a Python program. If you type them as is into the program directly, Python will try to treat those words as names in the Python language:
>>> print (hello there)
What happens? Lets check it out! We get an error message!!!!!
ISYS90088 sem 2 2018 1-40

Errors and python translator
l Sometimes, you will write something which the Python interpreter does not understand. The most basic kind of mistake you can make is a syntax error.
l A syntax error occurs when you type something which is not properly formed, according to the rules of the programming language.
l It is the same as a grammatical error in English (or any natural language for that matter).
l So, in this example it did not know what hello there is (not an identifier) until you tell it to be a string within quotes.
>>> print (‘hello there’) hello there
ISYS90088 sem 2 2018 1-41

print – examples
• Youcantypeinexpressionsanditwillcalculatetheanswerfor you (noting that the asterisk, or *, signifies multiplication):
>>>print (3 * 2) 6
ISYS90088 sem 2 2018 1-42

The input statement
• Python has a built-in function called input that can be used to get
keyboard input from the user as a string.
• The input function can be given a message to display, usually promptingtheuserwithwhatkindof informationtheprogramwants.
• A variable is a name for a value. When a variable receives a value, that value can be accessed using the variable name when required.
ISYS90088 sem 2 2018 43

The input statement – example
ISYS90088 sem 2 2018 44

Variables and the Assignment Statement
l A variable associates a name with a value
Ø Makes it easy to remember and use later in program
l Variable naming rules:
Ø Reserved words cannot be used as variable names
l Examples:if,for,whileandimport
Ø Name must begin with a letter or underscore _
l The rest of the name can contain zero or more occurrences of the following things:
Ø Digits (0 to 9) .
Ø Alphabetic letters.
Ø Underscores.
§ Names are case sensitive
Ø Example:WEIGHTisdifferentfromweight
Tip: use “camel casing” (Example: interestRate) 45

Variables and the Assignment Statement (continued)
l Nothing else is allowed in a variable name. Here is (incomplete) list of the things you can’t use anywhere in a variable name:
Ø Whitespace characters (the space, tab, new line).
Ø Hyphens (-)
Ø Quotation marks (single or double)
Ø Symbol characters such as: the question mark, the exclamation mark, brackets, and so forth.
l The following words having special meaning in Python (reserve words), and so they cannot be used for variable
Examples:
def, if, for, while, else, except, return, True, range, list, continue
46

Variables and the Assignment Statement (continued)
l Programmers use all uppercase letters for symbolic constants Ø Examples: TAX_RATE and STANDARD_DEDUCTION
l Variables receive initial values and can be reset to new values with an assignment statement
=
Ø Subsequent uses of the variable name in expressions are known as variable references
47

Variables : Example 1
#Which of the following are valid variable names?
a. length
b. _width
c. firstWord
d. 2MoreToGo
e. halt!
Solution: ????
48

Editing, Saving, and Running a Script
Ø We can then run Python program files or scripts within IDLE or from the OS’s command prompt
Ø Python program files use .py extension
Ø Running a script from IDLE allows you to construct some complex programs, test them, and save them in program libraries to reuse or share with others
ISYS90088 sem 2 2018 49

Editing, Saving, and Running a Script
Ø SelectNewFilefromtheFilemenu
Ø enter the python code/statements
Ø File/Save as (give a sensible name to your file. The extension will be.py)
Ø Torunthefileorcodeasapythonscript,selectRunmodulefrom the Run Menu
Examples using IDLE – shown in lecture
ISYS90088 sem 2 2018 50

Editing, Saving, and Running a Script (continued)
ISYS90088 sem 2 2018 51

Editing, Saving, and Running a Script (continued)
ISYS90088 sem 2 2018 52

Behind the Scenes: How Python Works
ISYS90088 sem 2 2018 53

Detecting and Correcting Syntax Errors
Ø Programmers inevitably make typographical errors when editing programs, called syntax errors
l The Python interpreter will usually detect these
Ø Syntax: rules for forming sentences in a language
Ø When Python encounters a syntax error in a program, it halts execution with an error message
ISYS90088 sem 2 2018 54

Detecting and Correcting Syntax Errors (continued)
ISYS90088 sem 2 2018 55

Install Python
l We will use Python v3.4 via GROK (on my machine 3.5.1)
l You just write it like a text and the python interpreter turns it into
machine code for you
l Get a copy of python for your own machine at home – there are free versions for Windows, MacOS and Linux
http://www .python.org/download/
l Portable version (USB) http://portablepython.com/
l AdvancedPythonDistribution(forscientificexperimentation)
http://www .enthought.com/products/edudownload.php
ISYS90088 sem 2 2018 1-56

Grok Learning environment
l GROK Learning is the web-based programming environment we will be using for the duration of this subject in your labs: https://groklearning.com/course/unimelb-isys90088-2018-s2/
l All you need to access the system is a browser, an internet connection and your GROK account
l Different modes of working in GROK: code, run, mark, terminal
ISYS90088 sem 2 2018 1-57

Summary
Ø Fundamental ideas of computer science l The algorithm
l Information processing
Ø Real computing agents can be constructed out of hardware devices
l CPU, memory, and input and output devices
ISYS90088 sem 2 2018 58

Summary (continued)
Ø Software provides the means whereby different algorithms can be run on a general-purpose hardware device
l Written in programming languages
Ø Languages such as Python are high-level
Ø Interpreter translates a Python program to a lower-level form that can be executed on a real computer
Ø Python shell provides a command prompt for evaluating and viewing the results of Python expressions and statements
ISYS90088 sem 2 2018 59

Summary (continued)
Ø IDLE is an integrated development environment that allows the programmer to save programs in files and load them into a shell for testing
Ø Python scripts are programs that are saved in files and run from a terminal command prompt
Ø When a Python program is executed, it is translated into byte code
l Sent to PVM for further interpretation and execution
Ø Syntax: set of rules for forming correct expressions and
statements in a programming language
ISYS90088 sem 2 2018 60