Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

Essential Software

Dr. Muhammad Yousuf Tufail

Department of Mathematics
Institute of Business Administration.
‡ Yousuf Tufail ¯ Yousuf Tufail
ytufail@iba.edu.pk

Lecture 1 & 2

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 1/8
Creating Variable

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Returning variable/ Recalling variable/Displaying variable

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Returning variable/ Recalling variable/Displaying variable

print(Profit per year)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Returning variable/ Recalling variable/Displaying variable

print(Profit per year)


50000

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Returning variable/ Recalling variable/Displaying variable

print(Profit per year)


50000
Example (1)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Returning variable/ Recalling variable/Displaying variable

print(Profit per year)


50000
Example (1)
What would be the profit after 8 year.

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Returning variable/ Recalling variable/Displaying variable

print(Profit per year)


50000
Example (1)
What would be the profit after 8 year.

Solution

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Returning variable/ Recalling variable/Displaying variable

print(Profit per year)


50000
Example (1)
What would be the profit after 8 year.

Solution
Req profit after 8 year= 8*Profit per year

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Returning variable/ Recalling variable/Displaying variable

print(Profit per year)


50000
Example (1)
What would be the profit after 8 year.

Solution
Req profit after 8 year= 8*Profit per year
print(Req profit after 8 year)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Creating Variable
Profit per year=50000

Returning variable/ Recalling variable/Displaying variable

print(Profit per year)


50000
Example (1)
What would be the profit after 8 year.

Solution
Req profit after 8 year= 8*Profit per year
print(Req profit after 8 year)
400000
Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 2/8
Example (2)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 3/8
Example (2)
What would be the profit after 12 years?

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 3/8
Example (2)
What would be the profit after 12 years?

Solution

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 3/8
Example (2)
What would be the profit after 12 years?

Solution
600000

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 3/8
Calculation of Body mass index(BMI)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (3)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (3)
Calculate the body mass index for the following observation.
height = 1.79, weight = 68.7

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (3)
Calculate the body mass index for the following observation.
height = 1.79, weight = 68.7

Solution

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (3)
Calculate the body mass index for the following observation.
height = 1.79, weight = 68.7

Solution
height=1.79

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (3)
Calculate the body mass index for the following observation.
height = 1.79, weight = 68.7

Solution
height=1.79
weight=68.7

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (3)
Calculate the body mass index for the following observation.
height = 1.79, weight = 68.7

Solution
height=1.79
weight=68.7
BMI=

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (3)
Calculate the body mass index for the following observation.
height = 1.79, weight = 68.7

Solution
height=1.79
weight=68.7
BMI= weight/height**(2)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (3)
Calculate the body mass index for the following observation.
height = 1.79, weight = 68.7

Solution
height=1.79
weight=68.7
BMI= weight/height**(2)
print(BMI)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (3)
Calculate the body mass index for the following observation.
height = 1.79, weight = 68.7

Solution
height=1.79
weight=68.7
BMI= weight/height**(2)
print(BMI)
21.4413

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 4/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (4)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 5/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (4)
Calculate the body mass index for the following observation.
height = 1.79, weight = 74.2

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 5/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (4)
Calculate the body mass index for the following observation.
height = 1.79, weight = 74.2

Solution

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 5/8
Calculation of Body mass index(BMI)

weight
BMI = height 2

Example (4)
Calculate the body mass index for the following observation.
height = 1.79, weight = 74.2

Solution
23.1578

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 5/8
Types of variable

Example (5)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 6/8
Types of variable

Example (5)
What are the types of the following variable.
a=2, b=2.34, c=‘I am string’, d=True

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 6/8
Types of variable

Example (5)
What are the types of the following variable.
a=2, b=2.34, c=‘I am string’, d=True

Solution

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 6/8
Types of variable

Example (5)
What are the types of the following variable.
a=2, b=2.34, c=‘I am string’, d=True

Solution
a=2

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 6/8
Types of variable

Example (5)
What are the types of the following variable.
a=2, b=2.34, c=‘I am string’, d=True

Solution
a=2
b=2.34

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 6/8
Types of variable

Example (5)
What are the types of the following variable.
a=2, b=2.34, c=‘I am string’, d=True

Solution
a=2
b=2.34
c=‘I am string’

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 6/8
Types of variable

Example (5)
What are the types of the following variable.
a=2, b=2.34, c=‘I am string’, d=True

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 6/8
Types of variable

Example (5)
What are the types of the following variable.
a=2, b=2.34, c=‘I am string’, d=True

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 6/8
Types of variable

Example (5)
What are the types of the following variable.
a=2, b=2.34, c=‘I am string’, d=True

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 6/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)
print(type(a))

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)
print(type(a))
int

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)
print(type(a))
int
print(type(b))

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)
print(type(a))
int
print(type(b))
float

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)
print(type(a))
int
print(type(b))
float
print(type(c))

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)
print(type(a))
int
print(type(b))
float
print(type(c))
string

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)
print(type(a))
int
print(type(b))
float
print(type(c))
string
print(type(d))

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)
print(type(a))
int
print(type(b))
float
print(type(c))
string
print(type(d))
bool

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Types of variable

Solution
a=2
b=2.34
c=‘I am string’ (It will be green in color)
d=True (It will be blue in color)
print(type(a))
int
print(type(b))
float
print(type(c))
string
print(type(d))
bool
Note: Strings are always written in ‘ ‘ or ” ”
Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 7/8
Lists

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 8/8
Lists

Height of a family members:

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 8/8
Lists

Height of a family members:


height 1 = 1.64
height 2 = 1.42
height 3 = 1.56
height 4 = 1.80

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 8/8
Lists

Height of a family members:


height 1 = 1.64
height 2 = 1.42
height 3 = 1.56
height 4 = 1.80
It looks quite inconvenient way of representation.

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 8/8
Lists

Height of a family members:


height 1 = 1.64
height 2 = 1.42
height 3 = 1.56
height 4 = 1.80
It looks quite inconvenient way of representation.
Python provides a better way to represent such data in the form of list as
explained below:

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 8/8
Lists

Height of a family members:


height 1 = 1.64
height 2 = 1.42
height 3 = 1.56
height 4 = 1.80
It looks quite inconvenient way of representation.
Python provides a better way to represent such data in the form of list as
explained below:
fam heights=[1.64,1.42,1.56,1.80]

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 8/8
Lists

Height of a family members:


height 1 = 1.64
height 2 = 1.42
height 3 = 1.56
height 4 = 1.80
It looks quite inconvenient way of representation.
Python provides a better way to represent such data in the form of list as
explained below:
fam heights=[1.64,1.42,1.56,1.80]
Above representation is better than previous.

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 8/8
Lists

Height of a family members:


height 1 = 1.64
height 2 = 1.42
height 3 = 1.56
height 4 = 1.80
It looks quite inconvenient way of representation.
Python provides a better way to represent such data in the form of list as
explained below:
fam heights=[1.64,1.42,1.56,1.80]
Above representation is better than previous.
But (still) we do not know the people corresponding to each height.

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 8/8
Lists

Height of a family members:


height 1 = 1.64
height 2 = 1.42
height 3 = 1.56
height 4 = 1.80
It looks quite inconvenient way of representation.
Python provides a better way to represent such data in the form of list as
explained below:
fam heights=[1.64,1.42,1.56,1.80]
Above representation is better than previous.
But (still) we do not know the people corresponding to each height.
fam heights=[”John”, 1.64, ”Hazel”, 1.42, ”mom”, 1.56, ”dad”, 1.80]

Dr. Muhammad Yousuf Tufail (IBA.) Essential Software Lecture 1 & 2 8/8

You might also like