Ethics in Information Technology
Ethics in Information Technology
Start Program
Enter two numbers, A, B
Add the numbers together
Print Sum
End Program
Designing a Program
• Designing a Program -- Tools
o another example of pseudocode to compute the
perimeter of a rectangle:
Start Program
Enter length, l
Enter width, w
Compute Perimeter = 2*l + 2*w
Display Perimeter of a rectangle
End Program
Designing a Program
• Designing a Program – Use flowchart
Designing a Program
• Designing a Program – Use flowchart
• Performing Calculations
• Python math Operators:
Symbol Name
+ Addition
- Subtraction
* Multiplication
/ Division
// Integer Division
% Reminder
** Power
print function, Comments, Variables
• Performing Calculations
# Python Source code
a = 10.89234
b = 11
c = 12
add = a + b + c
sub = c - a
mult = a * b
div = c / 3
power = a ** 2
# Left justified
print(format(x, '<10.1f'))
# Centered
print(format(x, '^10.1f'))
print(format(x, '0,.1f'))
print function, Comments, Variables
• Functions we learn today
print -- output function
Input -- data input function
int -- data conversion function
float -- data conversion functions
str -- data conversion functions
format – data formatting function
Programming Exercise
12.Stock Transaction program page 79
Last month Joe purchased some stock in Acme Software, Inc. here are
the details of the purchase:
• The number of shares that Joe purchased was 2,000
• When joe purchased the stock, he paid $40.00 per share
• Joe paid his stockbroker a commission that amounted to 3% of the
amount he paid for the stock.
Two weeks later joe sold the stock. Here are the details of the sale:
• The number if shares that Joe sold was 2,000
• He sold the stock for $42.75 per share
• He paid his stockbroker another commission that amount to 3% of
the amount he received for the stock.
Programming Exercise
12.Stock Transaction program page 79
Write a program that display the following information:
• The amount of money joe paid for the stock
• The amount of Commission Joe paid for his broker
when he bought the stock
• The amount of money Joe sold for the stock
• The amount of Commission Joe paid for his broker
when he sold the stock
• Display the amount of money that Joe had left when
he sold the stock and paid his broker(both times). If
this amount is positive, then Joe made a profit. If the
amount is negative, then Joe lost money.
Programming Exercise
12.Stock Transaction program page 79
buy_share=2000 # this variable is integer
buy_per_share=40 # this variable is integer
buy_Commission_rate=0.03 # this variable is float
print ('The amount of money Joe paid for the stock is $',format(buy_amount,',d'),sep='')
print("The amount of Commission Joe paid for his broker when he bought the stock is $",format(buy_Commission ,',.0f'),sep='')
if final_amount>0 :
print("Joe made a profit")
else:
print("Joe lost money")
Lab exercise and Assignment
• Exercises
Review Questions p73-p74
Programming Exercises 3 , 7
• Assignments:
• Programming Exercises
– 1,4,5,9
– Send source code and output to ling.zhang@hccs.edu or
hong.sun@hccs.edu
– Due: June 14, 2016.