This is Your Presentation Title
Introduction to Programming Langauge / Python
Who is Mohit ?
SELF TAUGHT (Limited knowledge)
Python
AMXModX/Sourcemod
HTML/PHP
Visual Basics
C/C++
ONTARIO TECH UNIVERSITY
Bachelor of Commerce
Accounting major
Finance minor
Graduate Diploma (Accounting)
Teaching Assistant
CANADA REVENUE AGENCY
GST/HST Appeals
2
What is a programming language?
Machine code – Binary/Hexadecimal
Assembly Language – Middle layer
Programming Language – Human readable code.
Your compiler converts human readable language into machine code.
3
Trigger or Call
Input
Function
Output
4
“
1.
What is Python?
How is it related to finance or business in general?
6
Data Types
Type
Bool
Integer
Float
String
List
Explanation
: 0/1 or True/False
: Real numbers. (1, 2, 3, …, ∞)
: Decimals.
: Sequence of alphabets and/or numbers. Between ‘’
: Group of any of the above mentioned types.
7
8
Basic Arithmetic Operators
Type
+, –
*, /
**
//
%
Explanation
: Addition, Subtraction
: Multiply, Divide
: Exponentiate
: Divide with integer output. (No fractions)
: Modulus. For example – 10 % 3.
3 x 3 = 9
10 – 9 = 1
9
Logical Operators
Type
=
>=
<=
==
!=
Explanation
: Assign a value to a variable
: Greater than or equal to
: Less than or equal to
: Equal to
: Not equal to
Other Common operators
Operators
#
If/else
del
for
print
return
Meaning
: This is a comment only for human readability.
: if true run code between below, else skip it.
: Delete a variable.
: Initiates a loop.
: Prints output.
: Returns output and stops the code below from executing
10
Python Code – Future Value
# declare varibales
N = 5
I = 0.08
Pv = 500
# Lets compute
Fv = Pv * (1 + I) ** N
# Print the output
print(Fv)
# Limit our output to only 2 decimal places.
print(‘%.2f’ % Fv)
11
734.6640384000003
Print command Examples
# Print command with one variable.
print(‘The future value is: %i’ % Fv)
# Print command with multiple variables.
print(‘The future value of $%i after %i years at a rate of %.2f percentage is: %i’ % (Pv, N, I*100, Fv))
# Print command combining two strings.
print(‘This is first string’ + ‘and this is second string’)
12
Python Code (Future Value)
# declare variables
N = 5
I = 0.08
Pv = 500
# Lets compute
Fv = Pv * (1 + I) ** N
# Print the output
print(Fv)
# Limit our output to only 2 decimal places.
print(‘%.2f’ % Fv)
13
734.6640384000003
Python Code (Present Value)
# declare variables
N = 5
I = 0.08
Pv = 500
# Lets compute
Fv = Pv / (1 + I) ** N
# Print the output
print(Fv)
# Limit our output to only 2 decimal places.
print(‘%.2f’ % Fv)
14
734.6640384000003
Net Present Value (Loop)
# Declare variables
Cf = [-1200, 150, 200, 250, 300, 350]
I = 0.08
Npv = 0
# Length of the list
Length = len(Cf)
# Lets create a loop
For i in range(length):
Pv = Cf[i] / (1 + I)**i
Npv += Pv
Print('the NPV of year %i is: %i' % (i, Npv))
# NPV of the cash flows
print('The NPV of the project is: %i’ % Npv)
15
End of Session
Questions?
16