Programming For Scientist Lecture 1
Programming For Scientist Lecture 1
Dan Andrews
Brian Parker
Course structure
• Week 1 – Programming Basics, Variables and Expressions
• Week 2 – Functions and abstraction
• Week 3 – Code branching and Iteration, Strings
• Week 4 – Lists (Canberra Day holiday on the Monday) Dan
• Week 5 – References, Dictionaries, Code best practices
• Week 6 – Modules, Classes, File IO
Teaching break
• Week 7 – Introduction to scientific libraries with NumPy, Debugging
• Week 8 – Data analysis with Pandas, Visualisation, Dictionaries, Sets
• Week 9 – Advanced functions, Errors and exceptions
• Week 10 – Computational complexity, Dynamic programming
Brian
• Week 11 – Computational methods in science and engineering
• Week 12 – Computational methods (cont), Exam revision
See: https://comp.anu.edu.au/courses/comp1730/lectures/
Lecture slides and code examples:
• Course website:
https://comp.anu.edu.au/courses/comp1730/lectures/
About you – results of demographic survey
About you – results of demographic survey
About you – results of demographic survey
Source: Wikipedia
• Code_L1_1.py
YES Does it NO
move?
Stop
In Python:
Code_L1_2.py
More complicated: Python as a toolbox
Code_L1_3.py
What is programming?
COMP1730 & COMP6730
Reading:
Chapter 1: Downey, Think Python,
Chapter 1: Sundnes, ItSPwP
OR
Sections 1& 2: https://docs.python.org/3/tutorial/index.html
Why Python?
• When reading other python books, make sure they are python 3!
• Be careful with web resources – some are great (eg. docs.python.org). Many
aren’t.
Safari Books (ANU library subscription)
https://www.oreilly.com/library-access/
Reading:
Chapter 2 : Downey, Think Python
Chapter 2, Sundnes, ItSPwP
OR
https://docs.python.org/3/tutorial/index.html
Variables – what are they?
• Contain a program’s data whilst it is executing
• Assignment statements:
Code_L1_4.py
Types of variables (in python)
• All variables have a type – and you
will get an error is you store an
incompatible value in the wrong type
(eg. a string value in an integer
variable type)
• Or try to do something inappropriate
with a data type (eg, print an integer
as a string)
• Basic data types:
• int – integer
• float – decimal values
• str – strings of one or more characters Sweigart (2019) Automate the Boring Stuff with Python, 2nd Ed.
Code_L1_5.py
Numeric types: int
• int types represent the mathematical integers (positive and negative
whole numbers) (0, 1, 2, -1, -17, 4096,…)
• Values of type int have no inherent size limit in python
• A string (in python) can contain other types of quote mark, but not
the one used to delimit it
• More about strings (so much more) in a coming lecture
Suggested Exercises
• https://comp.anu.edu.au/courses/comp1730/
• Wattle for announcements, forums, quizzes, surveys and assignment
submission
• Recordings of lectures are available on Wattle
• Read the Wattle news and announcements!
• To ask a question:
• Use the discussion forum on Wattle
• Ask your tutor in labs
• For private matters, use the course email: [email protected]
• Always use your ANU email address, to avoid the spam filters
• Please don’t email the course convenors directly – these emails will be ignored
Schedule overview
• Two lectures per week
• All lectures will be presented live and will be recorded
• Follow content and schedule:
https://comp.anu.edu.au/courses/comp1730/lectures/
• One 2-hour lab per week, starting from Week 2
• Before Fri 23rd Feb - Sign-up for a lab class with MyTimetable (linked via Wattle):
https://mytimetable.anu.edu.au/odd/student
• Assessments will be due at 11:55pm on Sunday of weeks when due (unless
otherwise specified):
https://comp.anu.edu.au/courses/comp1730/assessments/
• You are expected to spend another 6 hours per week studying the course:
• doing the recommended reading
• solving all lab exercises, and
• time spent to practice coding
Drop-In Sessions
• If evidence of plagiarism is found in individual homework problems, the mark for that individual homework will not be
posted, until all homeworks have been assessed. In the context of all homeworks if it is decided there is evidence of
repeated plagiarism, students will be interviewed for possible action of academic misconduct.
• The take-home assignment and exam will also be checked for evidence of academic misconduct.
• What is okay: for the homework, discussing the programming problems and approaches to solve them with other
students is allowed, provided that no code is exchanged and that the final solution and code is written individually. In
this case, the other students involved in the discussion must be listed in a comment at the top of the homework.
• For the final exam and take-home assignment must be individual work. You may not discuss the questions or your
answers with anyone (this includes any on-line forum).
• Note that in all cases every line of code submitted must be fully written by you from scratch (and not just a modified
copy of a version from the internet), and must be fully understood and explainable by you. Sufficient inline comments
should be provided to make clear that you understand the code.
• Note on large language models and other code generators: generative AI models such as github copilot, chatGPT, Bing
chatbot etc can be used by students for the homeworks and take-home assignment to explore solutions and
understand their own code. They will not be allowed for the final exam. But in all cases the final code submitted by the
student must be fully written and understood by the student, as described above.
• If you are unsure, please ask your tutor or the convenors.
Assessment
3 simple rules:
1. Read before you post.
• Before posting a question, check if your question has already been answered
These rules are good etiquette and apply to any online forum.
Important tasks:
1. Complete the demographic information 4. Prepare for the labs! Attend lectures, read
questionnaire on course Wattle page lab instructions – and attempt some of the
2. Sign up to a lab class! exercises before attending your lab
• Do this via myTimetable: 5. Make sure you have a working python
https://mytimetable.anu.edu.au/odd/student programming environment:
• Link also accessible from Wattle page • Install Anaconda on your own computer:
• Do this by end of Week 1 (Fri 23rd Feb) • Go to: https://www.anaconda.com/download
• Labs start in Week 2 • Current installation will give you python 3.9 or later
• Homework 1 is also due in Week 2 • Includes that Spyder IDE as part of installation
• In-lab assessment starts in Week 2 • For more tips and detailed instructions:
https://comp.anu.edu.au/courses/comp1730/labs/install/
3. Login to STREAMS: https://cs.anu.edu.au/streams/ • Or, install another python3 implementation
• This will create an account for you on the lab • Or, verify that you can reliably use the lab
computers computers