Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computational Thinking

Similar presentations


Presentation on theme: "Introduction to Computational Thinking"— Presentation transcript:

1 Introduction to Computational Thinking
Abstraction & Data Structures (C) Dennis Kafura 2016

2 Abstraction & Data Structures
identifying the information properties of an entity relevant for a given stakeholder; each property has a value. computer property --> value abstraction property --> value data structure state property --> value algorithm organizing the properties and their values so that they can be processed by an algorithm executed by a computer. (C) Dennis Kafura 2016

3 Abstraction An abstraction can be depicted by a table
Example: an abstraction of a weather report properties City Temperature “Blacksburg, VA” 77 values (C) Dennis Kafura 2016

4 Dictionary: a data structure
A dictionary is a data structure used to represent a single instance A dictionary is organized as a collection of property-value pairs In Python the term key-value pair is used City Temperature “Blacksburg, VA” 77 key-value pair key-value pair temps = { “City” : “Blacksburg, VA”, “Temperature” : 77} key value (C) Dennis Kafura 2016

5 Dictionary operations
temps = { “ City” :“Blacksburg, VA” , “Temperature” : 77} retrieval cityTemp = temps[“Temperature”] cityName = temps[“City”] update temps[“Temperature”] = 82 (C) Dennis Kafura 2016

6 For today Work in your cohorts on the class work problems for 30 minutes More discussion of abstraction and dictionaries to follow (C) Dennis Kafura 2016

7 Abstracting multiple entities
Similar abstracted entities (e.g., weather reports for different locations) have the same properties but different values. They are called instances. properties City Temperature “Blacksburg, VA” 77 “New York, NY” 85 “San Jose, CA” 75 “Miami, FL” 88 instances (C) Dennis Kafura 2016

8 Representing an abstraction
City Temperature “Blacksburg, VA” 77 “New York, NY” 85 “San Jose, CA” 75 “Miami, FL” 88 list multiple instances, one property dictionary multiple properties one instance (C) Dennis Kafura 2016

9 Representing Abstractions
Abstractions are represented using data structures Dictionary a collection of key-value pairs used to represent multiple properties of a single instance of an abstraction List a collection of similar things used to represent one property of multiple instances of an abstraction (C) Dennis Kafura 2016

10 An Example City Temperature “Blacksburg, VA” 77 “New York, NY” 85
“San Jose, CA” 75 “Miami, FL” 88 report = [ { “ City” : “Blacksburg, VA” , “Temperature” : 77} , { “ City” : “New York, NY” , “Temperature” : 85} , { “ City” : “San Jose, CA” , “Temperature” : 75} , { “ City” : “Miami, FL” , “Temperature” : 88} ] (C) Dennis Kafura 2016

11 Dictionaries/Lists and iteration
reports = [ { “ City” : “Blacksburg, VA” , “Temperature” : 77} , { “ City” : “New York, NY” , “Temperature” : 85} , { “ City” : “San Jose, CA” , “Temperature” : 75} , { “ City” : “Miami, FL” , “Temperature” : 88} ] # find average temperature total = 0 number= 0 for report in reports: total= total + report[“Temperature”] number = number + 1 average = total / number (C) Dennis Kafura 2016


Download ppt "Introduction to Computational Thinking"

Similar presentations


Ads by Google