Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 100 Introduction to Computing Seminar

Similar presentations


Presentation on theme: "CS 100 Introduction to Computing Seminar"— Presentation transcript:

1 CS 100 Introduction to Computing Seminar
September 23, 2015 1

2 Let's Work on Some Programs (1)
A company has determined that its annual profit is typically 23% of total sales. Write a Python program that asks the user to enter the projected amount of total sales, and then displays the projected profit that should be made from that amount of sales. What are the inputs and outputs?

3 Let's Work on Some Programs (2)
What are the inputs and outputs? Inputs: projected amount of total sales Outputs: projected profit Develop an algorithm

4 Let's Work on Some Programs (3)
Develop an algorithm Step 1: Introduce the program Step 2: Ask for the amount of projected sales Step 3: Record the user’s response for projected sales Step 4: Calculate the projected profit Step 5: Provide the user with the projected profit.   Step 6: Stop

5 Let's Work on Some Programs (4)
Develop a flow chart

6 Let's Work on Some Programs (5)
Develop a flow chart

7 Let's Work on Some Programs (6)
Develop source code

8 Let's Work on Some Programs (7)
# Step 1: Introduce the program print ("This program projects future profit based on projected sales. ") # Step 2: Ask for the amount of projected sales # Step 3: Record the user’s response for projected sales. sales_total = float(input("Enter the projected sales: ")) # Continued on next slide

9 Let's Work on Some Programs (8)
# Step 4: Calculate the projected profit (formula: sales * .23) profit = sales_total * 0.23 # Step 5: Provide the user with the projected profit. print ("The projected profit is " , format(profit, '.2f')) # Step 6: Stop

10 Let's Work on Some Programs (9)
One acre of land is equivalent to 43,460 square feet. Write a program that asks the user to enter the total square feet in a tract of land an calculates the number of acres in that tract. What are the inputs and outputs

11 Let's Work on Some Programs (10)
What are the inputs and outputs? Inputs: tract size in square feet Outputs: number of acres Develop an algorithm

12 Let's Work on Some Programs (11)
Develop an algorithm # Step 1: Introduce the program # Step 2: Ask for the amount of square feet of the tract of land. # Step 3: Record the user’s input for the tract of land. # Step 4: Calculate the acreage ( tract_size / ).   # Step 5: Provide the user with the number of acres.   # Step 6: Stop

13 Let's Work on Some Programs (12)
Develop a flow chart

14 Let's Work on Some Programs (13)
Develop a flow chart

15 Let's Work on Some Programs (14)
Develop source code

16 Let's Work on Some Programs (15)
# Step 1: Introduce the program print ("This program determines the acreage in a tract of land.") # Step 2: Ask for the square feet in the tract of land. # Step 3: Record the user’s input for the tract of land. tract_size = input("Enter the number of square feet in the tract: ")

17 Let's Work on Some Programs (16)
# Step 4: Calculate the acreage (tract_size / 43560). acres = float(tract_size) / # Step 5: Provide the use with the number of acres. print ("The size of that tract is" , format(acres , '.2f' ) , "acres.") # Step 6: Stop

18 Let's Work on Some Programs (17)
A customer in a store is purchasing five items. Write a program that asks for the price of each item, and then displays the subtotal of the sale, the amount of sales tax, and the total cost. Assume the sales tax is 7 percent What are the inputs and outputs?

19 Let's Work on Some Programs (18)
What are the inputs and outputs? Inputs: the price of item #1 2. the price of item #2 3. the price of item #3 4. the price of item #4 5. the price of item #5 Outputs: 1. the subtotal of the 5 items 2. the amount of sales tax (based on 7% of sales) 3. the total cost

20 Let's Work on Some Programs (19)
Develop an algorithm Remember: there are only sequential instructions… you cannot use a "loop"

21 Let's Work on Some Programs (20a)
Develop an algorithm # Step 1: Introduce the program # Step 2: Ask for the price of the first item # Step 3: Record the price of the first item # Step 4: Ask for the price of the second item # Step 5: Record the price of the second item # Step 6: Ask for the price of the third item # Step 7: Record the price of the third item # Continued on next slide

22 Let's Work on Some Programs (20b)
Develop an algorithm (continued) # Step 8: Ask for the price of the fourth item # Step 9: Record the price of the fourth item # Step 10: Ask for the price of the fifth item # Step 11: Record the price of the fifth item # Step 12: Calculate the subtotal cost of all 5 items # Step 13: Calculate the sales tax amount (subtotal * tax rate) # Step 14: Calculate the total (subtotal + sales tax amount) # Step 15: Communicate the subtotal, sales tax, and total values # Step 16: Stop

23 Let's Work on Some Programs (21)
Develop a flow chart

24 Let's Work on Some Programs (22)
Develop a flow chart

25 Let's Work on Some Programs (23)
Develop source code

26 Let's Work on Some Programs (24)
Develop source code

27 Let's Work on Some Programs (25)
A cookie recipe calls for the following ingredients: 1.5 cups of sugar 1 cup of butter 2.75 cups of flour The recipe produces 48 cookies with this amount of ingredients. Write a program that asks the user how many cookies he/she wants to make, and then display the number of cups of each ingredient needed for the user’s specified number of cookies. What are the inputs and outputs?

28 Let's Work on Some Programs (26)
What are the inputs and outputs? Inputs: desired number of cookies Outputs: 1. the amount of sugar necessary 2. the amount of butter necessary 3. the amount of flour necessary Develop and algorithm

29 Let's Work on Some Programs (27a)
Develop an algorithm # Step 1: Introduce the program # Step 2: Ask the user for the desired number of cookies # Step 3: Record the user’s input for the number of cookies # Step 4: Calculate the cups of sugar needed ( ( cookies_desired / cookies_recipe) * 1.5 cups_of_sugar ) # Step 5: Calculate the cups of butter needed ( 1 / 48 * number of cookies) ( ( cookies_desired / cookies_recipe) * 1 cups_of_butter ) # Step 6: Calculate the cups of flour (2.75 / 48 * number of cookies) ( ( cookies_desired / cookies_recipe) * cups_of_flour )

30 Let's Work on Some Programs (27b)
Develop an algorithm (continued) # Step 7: Communicate the amount of butter, sugar, # and flour needed to make the specified number of cookies. # Step 8: Stop

31 Let's Work on Some Programs (28)
Develop a flow chart

32 Let's Work on Some Programs (29)
Develop a flow chart

33 Let's Work on Some Programs (30)
Develop source code

34 Let's Work on Some Programs (31)
Develop source code

35 Monday: Exam


Download ppt "CS 100 Introduction to Computing Seminar"

Similar presentations


Ads by Google