Handouts Lecture 1
Handouts Lecture 1
§ Course information
§ General introduction to programming
• Python basics
• Mathematical operations
• Python variables and data types
Course objectives
§ Soft skills
• PwC: Questioning mind
• EY: Social styles
• BDO: Negotiation skills
§ Module: Python for Accountancy & Control
Python for Accountancy & Control
Required attendance:
§ At least 2 workshops and 7 out of 9 Python sessions
Importance of Data Analytics & Python for accounting
§ Risk management
• Default prediction, regulatory compliance, credit scoring, fraud prediction
§ Generating market insights
• Competitor analysis, sales forecasting, price optimization
§ Process mining
• Process efficiency, effectiveness, bottlenecks and exceptions
§ Natural language processing
• Sentiment analysis, document classification, labelling, chat bots
§ Customer analysis
• Churn prediction, segmentation, lifetime value analysis
§ Supply chain management
• Manage inventory levels, reduce carrying costs
Data Science Venn Diagram
Source: http://drewconway.com/zia/2013/3/26/the-data-science-venn-diagram
Top programming languages
Source: https://spectrum.ieee.org/the-top-programming-languages-2023
Python
§ Open source
• Free to use
§ Cross-platform
• Available for Windows, Mac and Linux
§ Easy to learn
• Focus on readability of code
• Use of indentation for code blocks
§ General programming language
• Versatile
• Software development, web development, automation, machine learning, etc.
• Interpreted programming language
§ De facto language for data science and machine learning
• Many useful data science libraries
• Numpy, Pandas, Matplotlib, Scikit Learn, etc.
• Large community of users and developers
What is a program?
§ Practice!
§ Cannot passively absorb programming as a skill
§ Don’t be afraid to try out Python commands
Expressions and statements
§ Expressions:
• Combination of objects and operators
• <object><operator><object>
• Code constructs that evaluate to a value
• 16 + 12
• n + 10
• a == b
§ Statements: commands executed
• Instructions that perform some sort of action, but do not produce a value
• Determine the flow of a program
• E.g., assignments, control flow statements (if/else), print statements, import
statements, and return statements
Jupyter Notebook
§ Interactive environment
• Code, text, data visualizations and other ouput
§ Bring your own device
• Tutorials
• Workshops
§ Using Jupyter Notebook
• Google Colaboratory
https://colab.research.google.com
• No installation required
• Alternative:
• Local installation of Jupyter using Anaconda
https://www.anaconda.com
• May require administration rights to install
• No support by faculty
Google Colaboratory
Jupyter Notebook
Our first program
print statement
Arithmetic operators
Operator symbol Operator name Description
+ Addition Add two operands
- Subtraction Subtract the right operand from the left operand
* Multiplication Multiply two operands
/ Division Divide the left operand by the right operand, return a float
// Floor division Divide the left operand by the right operand and return the
floor value (integer)
** Exponent Raise the left operand to the power of the right operand
% Modulo Returns the remainder of the division of the left operand by
the right operand
Coding examples
§ Addition:
§ Subtraction:
§ Multiplication:
§ Division:
Coding examples
§ Floor division:
§ Exponent:
§ Modulo:
Assignment statements
Keywords are reserved words that have specific meanings and purposes and can't be used
for anything but those specific purposes
§ Examples of keywords: if, elif, else, while, for, return, import
§ Note that class is printed in blue, indicating that it is a keyword
Relational operators
Operator symbol Operator name Description
== equal to Compares if the value op the left operand is equal to the
value op the right operand
!= not equal to Compares if the value op the left operand is not equal to the
value op the right operand
< less than Tests if the value op the left operand is smaller than the
value op the right operand
> greater than Tests if the value op the left operand is greater than the
value op the right operand
<= less than or equal to Tests if the value op the left operand is smaller than or equal
to the value op the right operand
>= greater than Tests if the value op the left operand is greater than or equal
to the value op the right operand
Coding examples
§ Assign:
§ Equal to:
§ Less than:
§ Greater than:
§ username = input()
§ Display username:
.lower()
.upper()
.title()
String methods
0 1 2 3 4 5
String slices
p y t h o n
0 1 2 3 4 5
Source: https://www.geeksforgeeks.org/10-famous-bugs-in-the-computer-science-world/
Source: https://www.youtube.com/
watch?v=wGeZEUjUKvc
Source: https://edition.cnn.com/2013/07/17/tech/paypal-error/index.html
Errors and Debugging
Types of errors:
• Syntax errors: code cannot be parsed due to violations of the Python programming language:
• e.g., inappropriate indentation, not closing brackets, missing parentheses
• Runtime errors: errors which do not appear until after the program started running
• e.g., misspelling a variable name (NameError), using the wrong type (TypeErrors), attempting to open a file that
doesn not exist, etc.
• Semantic errors: the program runs, but does something else than expected
• Returning a wrong value (i.e., errors in algorithms) or never ending a loop
• Hardest to find
• Important to verify if your code does what you expected it to do
Recommended reading