MTH4000 - Programming in Python I - 2023/24
Topic outline
-
ASSESSMENT & MARKING CRITERIA
There will be five in-term tests in weeks 3, 5, 8, 10, and 12, each of them counting 20% towards your final mark. More information under the "Assessments" tab below.
FEEDBACK
Your feedback comes in many forms:
- Weekly Quizzes with specific feedback
- Weekly lab sheets
- Additional list of exercises (with solutions in due time) for you to practice
- Availability to ask questions during or after lectures
- Participation in IT Labs throughout the week - these provide you with a unique opportunity to work with other students and explore ideas from the module in further depth. Labs are also a more relaxed environment for you to get advice and guidance for your course from academic members of staff, who will provide helpful comments.
- Personalised feedback during office hours - Office hours are also an opportunity for you to get 1 on 1 help for any additional support you may need. You can also contact the lecturer by email with any queries you might have.
Feedback is not just written comments on a piece of work. Please make sure that you actively engage with all these feedback opportunities, as they are there to help you learn and gain confidence in tackling unfamiliar problems!
MEET YOUR LECTURERS
Your lecturers for the module are Prof. Thomas Prellberg and Dr Matthew Lewis.
Thomas is a Professor of Mathematics at QMUL, and a member of the Dynamical Systems & Statistical Physics research group. His research interests span several areas of mathematics and theoretical physics, including combinatorics, statistical physics, and the mathematical and computational modelling of polymers, where he has published over 120 papers. Throughout his academic career he has used extensively computer programming for computer simulations, designing and implementing algorithms for large-scale simulations. At QMUL he has taught Python modules for several years, modules he also designed and created.
Matthew is a Lecturer in Mathematical Sciences at QMUL. He obtained his PhD in 2019 at Cardiff University with thesis Stability of Solutions of a One-Dimensional p-Laplace Equation with Periodic Potential. Throughout his research, he has used Python to design numerical algorithms to evaluate solutions to nonlinear differential equations. He has taught programming modules at QMUL over the last couple of years, helping design and structure material for these courses.The on-campus IT labs for the module are supported by academic staff Dr Mark Walters, Dr Fatemeh Parsa, Dr Subhajit Jana, Dr Omer Bobrowski, Dr Masanori Hanada, Dr Vincenzo Nicosia, and research students Evelyn Lira Torres, Danilo Riccio, and Elisa Scanu.READING LIST
The lecture notes and lab materials will define the content of the module, but if you would like some additional reading material, then we recommend two books:
- Python: an introduction to programming by James Parker
- A Beginner's Guide to Python 3 Programming by John Hunt
This is available as an e-book from the library. (You are not required to purchase a copy.)
-
View all general news and announcements from the your module leaders.
-
The early feedback questionnaire is now complete, and we thank the 88 students who provided us with their answers and comments.
The response statistics and the free text comments are now available if you like to look.
We take these responses seriously, and while we are overall very satisfied with the comments, we will use the responses to fine-tune our delivery.
Focussing on the lectures, we will endeavour to give you more opportunities to answer questions and to maintain more noise control (as it is hard to hear if there are noise issues when standing up front, it might be necessary for one of us to sit in the upper third of the lecture theatre).
We fully agree that for most students a course like this should have more labs (and perhaps no lectures?). As it is, we are offering 12h IT labs and we have repeatedly stated that you can come to more than just your scheduled lab if your timetable allows (and if there are computers available). Unfortunately doubling the amount of scheduled hours in the IT labs is not feasible.
Some students asked for small projects. We suggest that students can focus on the additional exercises (some with solutions) as some of these fit that bill. We are happy to have a look at any attempts in the labs or in the learning cafe on Thursdays.
Some students remarked that the labs introduce concepts that have not been covered in the lectures. This is intentional, as there is an element of self-paced learning of new material to the labs. The 2h lectures cannot possibly cover everything in detail.
-
There will be five in-term tests (counting 20% each), in weeks 3, 5, 8, 10, and 12.
The in-term tests will have a quiz format. You will be able to practice quizzes in every week.
Weekly quizzes are an excellent way of checking if you master the minimum (and a way to practice for the tests), but the bulk of the learning will take place while you practice your coding skills (lab and additional exercises).- In weeks 3, 5, 8, 10, and 12 we will upload the respective tests. You will have a 24h window from Wednesday 11am to Thursday 11am to work on a 2h assessment. For details, please refer to the respective test sections.
-
Your week 3 mid-term test will take place over a 24h period, starting on Wednesday, October 11, 11am and ending on Thursday, October 12, 11am.
Once you start the test, you will have two hours to complete it or until the 24h period ends, whatever happens earlier.
While the test might be substantially shorter to complete, please assume that you will need about 2 hours from the moment you start to the moment you submit it.
The test covers all material in lectures and tutorials from week 1 and week 2.
The test is open book. This means:
- You may access any printed and online resources, however,
- You may not communicate, nor attempt to communicate, with anyone else, nor solicit assistance in any way (e.g. via email, Discord, WhatsApp, Chegg, Stackexchange, etc.).
The test itself will be in the format of a QMPlus quiz (just like the weekly quizzes). You are encouraged to do rough work on paper or within Jupyter Notebook.
-
Your week 5 mid-term test will take place over a 24h period, starting on Wednesday, October 25, 11am and ending on Thursday, October 26, 11am.
Once you start the test, you will have two hours to complete it or until the 24h period ends, whatever happens earlier.
While the test might be substantially shorter to complete, please assume that you will need about 2 hours from the moment you start to the moment you submit it.
The test covers all material in lectures and tutorials from week 1 to week 4.
The test is open book. This means:
- You may access any printed and online resources, however,
- You may not communicate, nor attempt to communicate, with anyone else, nor solicit assistance in any way (e.g. via email, Discord, WhatsApp, Chegg, Stackexchange, etc.).
The test itself will be in the format of a QMPlus quiz (just like the weekly quizzes). You are encouraged to do rough work on paper or within Jupyter Notebook.
-
Your week 8 mid-term test will take place over a 24h period, starting on Wednesday, November 15, 11am and ending on Thursday, November 16, 11am.
Once you start the test, you will have two hours to complete it or until the 24h period ends, whatever happens earlier.
While the test might be substantially shorter to complete, please assume that you will need about 2 hours from the moment you start to the moment you submit it.
The test covers all material in lectures and tutorials from week 1 to week 6.
The test is open book. This means:
- You may access any printed and online resources, however,
- You may not communicate, nor attempt to communicate, with anyone else, nor solicit assistance in any way (e.g. via email, Discord, WhatsApp, Chegg, Stackexchange, etc.).
The test itself will be in the format of a QMPlus quiz (just like the weekly quizzes). You are encouraged to do rough work on paper or within Jupyter Notebook.
-
Your week 10 mid-term test will take place over a 24h period, starting on Wednesday, November 29, 11am and ending on Thursday, November 30, 11am.
Once you start the test, you will have two hours to complete it or until the 24h period ends, whatever happens earlier.
While the test might be substantially shorter to complete, please assume that you will need about 2 hours from the moment you start to the moment you submit it.
The test covers all material in lectures and tutorials from week 1 to week 9.
The test is open book. This means:
- You may access any printed and online resources, however,
- You may not communicate, nor attempt to communicate, with anyone else, nor solicit assistance in any way (e.g. via email, Discord, WhatsApp, Chegg, Stackexchange, etc.).
The test itself will be in the format of a QMPlus quiz (just like the weekly quizzes). You are encouraged to do rough work on paper or within Jupyter Notebook.
-
Your week 12 mid-term test will take place over a 24h period, starting on Wednesday, December 13, 11am and ending on Thursday, December 13, 11am.
Once you start the test, you will have two hours to complete it or until the 24h period ends, whatever happens earlier.
While the test might be substantially shorter to complete, please assume that you will need about 2 hours from the moment you start to the moment you submit it.
The test covers all material in lectures and tutorials from week 1 to week 11.
The test is open book. This means:
- You may access any printed and online resources, however,
- You may not communicate, nor attempt to communicate, with anyone else, nor solicit assistance in any way (e.g. via email, Discord, WhatsApp, Chegg, Stackexchange, etc.).
The test itself will be in the format of a QMPlus quiz (just like the weekly quizzes). You are encouraged to do rough work on paper or within Jupyter Notebook.
-
This is a first module in computer programming in Python, a widely used programming language, an essential professional skill for Mathematicians and Statisticians. Students will learn to understand the basic logic of computer programming, read and implement basic code and write programs to solve problems coming from real world situations using theoretical results from their mathematics and statistics modules. These computational skills are applicable to any role that requires quantitative analysis and evidence-based decision making.
-
The programming language used for this module is Python, via the web-based Jupyter Notebook application. Please see the week 1 exercise sheet for information on how to access Jupyter Notebook on college computers and/or install it on your personal computer.
The content of the module is (roughly) as follows; more details are given in the week 1 lecture notes:
- Week 1: Introduction to Jupyter Notebook, Numbers and Variables
- Week 2: Sequences, Lists, and Arrays
- Week 3: Plotting data - first test
- Week 4: Functions
- Week 5: Logic and Loops - second test
- Week 6: Strings, text processing, file I/O
- Week 7: Revision
- Week 8: Designing an Algorithm - Euclid's Algorithm - third test
- Week 9: Searching and Sorting Algorithms and ...
- Week 10: ... Algorithmic Complexity - fourth test
- Week 11: Root finding algorithms
- Week 12: Working with Spreadsheets - fifth test
-
This is a first introduction to computer programming. Learning outcomes include:
- To apply basic elements of computer programming to analyse data
- To solve problems using computational methods
- To simulate complex systems on a computer
- Introductory concepts of computer programming in a widely used programming language
- Computational methods for analysing data, modelling complex systems and solving problems coming from real life situations
- Simple data types, composite data types, variables, functions, file input/output
- Branching (if-else), loops (while), List comphrehension
- Applications, e.g., Euclid's algorithm, sorting, root finding (bisection, Netwon,) algorithmic complexity
- Apply analytical skills to investigate unfamiliar problems
- Use technologies to access and interpret information effectively
- Use information for evidence-based decision-making
- Produce analyses, which are grounded in evidence
- Develop key transferable skills to identify and pursue career goals
-
What's covered in this week?
- Introduction to the module
- Jupyter Notebooks
- Using Python as a calculator
- Using Python to plot graphs
Activities for this week:
- Familiarise yourself with how to start Jupyter Notebook:
- Attend the Lectures on Tuesday
- Do the Coursework and attend one of the IT labs
Content for this week:
- Lectures can be accessed here
- Notes for this week are available here
- Coursework download and submission for this week are available here
- Set of additional exercises for practice: here
- This week's quiz (available at the end of the week): here
- This week's lab session walkthrough (available after the labs): here
Optional:
- See below for some help with AppsAnywhere
-
What's covered in this week?
- defining and manipulating data variables. Sequences and Lists.
- data libraries: numpy, math, matplotlib
Activities for this week:
- Attend the Lectures on Tuesday
- Do the Coursework and attend one of the IT labs
- Do the Quiz
Content for this week:
- Lectures can be accessed here
- Notes for this week are available here
- Coursework download and submission for this week are available here
- Set of additional exercises for practice: here
- This week's quiz (available at the end of the week): here
- This week's lab session walkthrough (available after the labs): here
-
What's covered in this week?
- More on sequences: slices, generators
- Plotting
- Built-in functions
- Attend the Lectures on Tuesday
- Do the first in-term test on Wednesday
- Do the Coursework and attend one of the IT labs
- Do the Quiz
- Please fill in this anonymous Early Feedback Questionnaire
Content for this week:
- Lectures can be accessed here
- Notes for this week are available here
- Coursework download and submission for this week are available here
- Set of additional exercises for practice: here
- This week's quiz (available at the end of the week): here
- This week's lab session walkthrough (available after the labs): here
-
What's covered in this week?
- User-defined functions
- Functions as variables
- Lambda functions
Activities for this week:
- Attend the Lectures on Tuesday
- Do the Coursework and attend one of the IT labs
- Do the Quiz
- Please fill in this anonymous Early Feedback Questionnaire
Content for this week:
- Lectures can be accessed here
- Notes for this week are available here
- Coursework download and submission for this week are available here
- Set of additional exercises for practice: here
- This week's quiz (available at the end of the week): here
- This week's lab session walkthrough (available after the labs): here
-
What's covered in this week?
- Boolean Types
- Boolean Operators
- Conditional Statements (if)
- recursive functions
Activities for this week:
- Attend the Lectures on Tuesday
- Do the second in-term test on Wednesday
- Do the Coursework and attend one of the IT labs
- Do the Quiz
Content for this week:
- Lectures can be accessed here
- Notes for this week are available here
- Coursework download and submission for this week are available here
- Set of additional exercises for practice: here
- This week's quiz (available at the end of the week): here
- This week's lab session walkthrough (available after the labs): here
-
What's covered in this week?
- For loops
- While loops
- Application: evaluation of (infinite) sums
- Infinite loops
Activities for this week:
- Attend the Lectures on Tuesday
- Do the Coursework and attend one of the IT labs
- Do the Quiz
Content for this week:
- Lectures can be accessed here
- Notes for this week are available here
- Coursework download and submission for this week are available here
- Set of additional exercises for practice: here
- This week's quiz (available at the end of the week): here
- This week's lab session walkthrough (available after the labs): here
-
-
What's covered in this week?
- Algorithms
- Euclidean gcd algorithm
- Arrangements of parentheses
- Root finding via bisection
Activities for this week:
- Attend the Lectures on Tuesday
- Do the third in-term test on Wednesday
- Do the Coursework and attend one of the IT labs
- Do the Quiz
Content for this week:
- Algorithms
-
What's covered in this week?
- Using GitHub
- Copying Composite Data
- Strings
- File Input/Output
Activities for this week:
- Attend the Lectures on Tuesday
- Do the Coursework and attend one of the IT labs
- Do the Quiz
Content for this week:
-
What's covered in this week?
- Array Operations with Numpy
- Application: Solving Systems of Linear Equations
- Data Analysis with Pandas: Example Atmospheric CO2
Activities for this week:
- Attend the Lectures on Tuesday
- Do the fourth in-term test on Wednesday
- Do the Coursework and attend one of the IT labs
- Do the Quiz
Content for this week:
-
What's covered in this week?
- More on Pandas
- Application: Live Currency Exchange Data
- Seaborn
Activities for this week:
- Attend the Lectures on Tuesday (with a presentation on CV writing, given by Sonia Lassami)
- Do the Coursework and attend one of the IT labs
- Do the Quiz
Content for this week:
-
What's covered in this week?
- Python vs C - indentation and one statement per line vs using brackets and delimiters
- inline if (or ternary conditional operator), and filtering using if in list comprehensions
- unpacking and the * operator
- Python function arguments: *args and all that
- complexity analysis of algorithms
Activities for this week:
- Attend the Lectures on Tuesday
- Do the fifth in-term test on Wednesday
- Do the Coursework and attend one of the IT labs
Content for this week:
-
-
Download and hand in your week 1 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download and hand in your week 2 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download and hand in your week 3 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download and hand in your week 4 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download and hand in your week 5 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download and hand in your week 6 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download and hand in your week 8 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download and hand in your week 9 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download and hand in your week 10 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download and hand in your week 11 Jupyter Notebook file. These do not contribute to your grade, but will be used to monitor your engagement with the module in accordance with the School's Student Engagement Policy.
-
Download your week 12 Jupyter Notebook file. There is no need to upload your work (but of course you can).
-
-
-
-
Contains...
Exercise 1: Mailing Address
Exercise 2: Hello
Exercise 3: Area of a Room
Exercise 4: Area of a Field
Exercise 5: Bottle Deposits
Exercise 6: Tax and Tip
Exercise 7: Sum of the First n Positive Integers
Exercise 8: Widgets and Gizmos
Exercise 9: Compound Interest
Exercise 10: Arithmetic
Exercise 11: Fuel Efficiency
Exercise 12: Distance Between Two Points on Earth
Exercise 13: Making Change
Exercise 14: Height Units
Exercise 15: Distance Units
Exercise 16: Area and Volume
Exercise 17: Heat Capacity
Exercise 18: Volume of a Cylinder
Exercise 19: Free Fall
Exercise 20: Ideal Gas Law
Exercise 21: Area of a Triangle
Exercise 22: Area of a Triangle (Again)
Exercise 23: Area of a Regular Polygon
Exercise 24: Units of Time
Exercise 25: Units of Time (Again)
Exercise 26: Current Time
Exercise 27: Body Mass Index
Exercise 28: Wind Chill
Exercise 29: Celsius to Fahrenheit and Kelvin
Exercise 30: Units of Pressure
Exercise 31: Sum of the Digits in an Integer
Exercise 32: Sort 3 Integers
Exercise 33: Day Old Bread -
-
Contains...
Exercise 34: Even or Odd?
Exercise 35: Dog Years
Exercise 36: Vowel or Consonant
Exercise 37: Name that Shape
Exercise 38: Month Name to Number of Days
Exercise 39: Sound Levels
Exercise 40: Name that Triangle
Exercise 41: Note To Frequency
Exercise 42: Frequency To Note
Exercise 43: Faces on Money
Exercise 44: Date to Holiday Name
Exercise 45: What Color is that Square?
Exercise 46: Season from Month and Day
Exercise 47: Birth Date to Astrological Sign
Exercise 48: Chinese Zodiac
Exercise 49: Richter Scale
Exercise 50: Roots of a Quadratic Function
Exercise 51: Letter Grade to Grade Points
Exercise 52: Grade Points to Letter Grade
Exercise 53: Assessing Employees
Exercise 54: Wavelengths of Visible Light
Exercise 55: Frequency to Name
Exercise 56: Cell Phone Bill
Exercise 57: Is it a Leap Year?
Exercise 58: Next Day
Exercise 59: Is a License Plate Valid?
Exercise 60: Roulette Payouts -
Contains...
Exercise 61: Average
Exercise 62: Discount Table
Exercise 63: Temperature Conversion Table
Exercise 64: No More Pennies
Exercise 65: Compute the Perimeter of a Polygon
Exercise 66: Compute a Grade Point Average
Exercise 67: Admission Price
Exercise 68: Parity Bits
Exercise 69: Approximate
Exercise 70: Caesar Cipher
Exercise 71: Square Root
Exercise 72: Is a String a Palindrome?
Exercise 73: Multiple Word Palindromes
Exercise 74: Multiplication Table
Exercise 75: Greatest Common Divisor
Exercise 76: Prime Factors
Exercise 77: Binary to Decimal
Exercise 78: Decimal to Binary
Exercise 79: Maximum Integer
Exercise 80: Coin Flip Simulation -
-
Contains...
Exercise 81: Compute the Hypotenuse
Exercise 82: Taxi Fare
Exercise 83: Shipping Calculator
Exercise 84: Median of Three Values
Exercise 85: Convert an Integer to its Ordinal Number
Exercise 86: The Twelve Days of Christmas
Exercise 87: Center a String in the Terminal
Exercise 88: Is it a Valid Triangle?
Exercise 89: Capitalize It
Exercise 90: Does a String Represent an Integer?
Exercise 91: Operator Precedence
Exercise 92: Is a Number Prime?
Exercise 93: Next Prime
Exercise 94: Random Password
Exercise 95: Random License Plate
Exercise 96: Check a Password
Exercise 97: Random Good Password
Exercise 98: Hexadecimal and Decimal Digits
Exercise 99: Arbitrary Base Conversions
Exercise 100: Days in a Month
Exercise 101: Reduce a Fraction to Lowest Terms
Exercise 102: Reduce Measures
Exercise 103: Magic Dates -
Contains...
Exercise 104: Sorted Order
Exercise 105: Reverse Order
Exercise 106: Remove Outliers
Exercise 107: Avoiding Duplicates
Exercise 108: Negatives, Zeros and Positives
Exercise 109: List of Proper Divisors
Exercise 110: Perfect Numbers
Exercise 111: Only the Words
Exercise 112: Below and Above Average
Exercise 113: Formatting a List
Exercise 114: Random Lottery Numbers
Exercise 115: Pig Latin
Exercise 116: Pig Latin Improved
Exercise 117: Line of Best Fit
Exercise 118: Shuffl ing a Deck of Cards
Exercise 119: Dealing Hands of Cards
Exercise 120: Is a List already in Sorted Order?
Exercise 121: Count the Elements
Exercise 122: Tokenizing a String
Exercise 123: Infix to Postfix
Exercise 124: Evaluate Postfix
Exercise 125: Does a List contain a Sublist?
Exercise 126: Generate All Sublists of a List
Exercise 127: The Sieve of Eratosthenes -
-