上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Computational Thinking and Approach Lecture 8 Dr.Jialiang LU Jialiang.lu@situ.edu.cn
Computational Thinking and Approach Lecture 8 Dr. Jialiang LU Jialiang.lu@sjtu.edu.cn
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Massive data representation and processing DATA COLLECTION
DATA COLLECTION Massive data representation and processing
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Examples of data collection: Simple Statistics 。 Many programs deal with large collections of similar information. Words in a document Students in a course Data from an experiment Customers of a business Graphics objects drawn on the screen Cards in a deck 3
Examples of data collection: Simple Statistics • Many programs deal with large collections of similar information. – Words in a document – Students in a course – Data from an experiment – Customers of a business – Graphics objects drawn on the screen – Cards in a deck 3
上游充通大粤 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Sample Problem: Simple Statistics Let's review our code of average: average4.py 井 A program to average a set of numbers # Illustrates sentinel loop using empty string as sentinel def main(): sum 0.0 count =0 xStr raw input ("Enter a number (<Enter>to quit)>>" while xStr!="": x eval(xStr) sumsum x count count 1 xStr raw input ("Enter a number (<Enter>to quit)>>" print "\nThe average of the numbers is",sum count main ( 4
Sample Problem: Simple Statistics Let‟s review our code of average: # average4.py # A program to average a set of numbers # Illustrates sentinel loop using empty string as sentinel def main(): sum = 0.0 count = 0 xStr = raw_input("Enter a number (<Enter> to quit) >> ") while xStr != "": x = eval(xStr) sum = sum + x count = count + 1 xStr = raw_input("Enter a number (<Enter> to quit) >> ") print "\nThe average of the numbers is", sum / count main() 4
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Sample Problem: Simple Statistics This program allows the user to enter a sequence of numbers,but the program itself doesn't keep track of the numbers that were entered it only keeps a running total. Suppose we want to extend the program to compute not only the mean,but also the median and standard deviation. 5
Sample Problem: Simple Statistics • This program allows the user to enter a sequence of numbers, but the program itself doesn‟t keep track of the numbers that were entered – it only keeps a running total. • Suppose we want to extend the program to compute not only the mean, but also the median and standard deviation. 5