CompSci 101 Introduction to Computer Science April 14, 2016 Prof. Rodger compsci101 spring161.

Slides:



Advertisements
Similar presentations
CompSci 101 Introduction to Computer Science February 3, 2015 Prof. Rodger Lecture given by Elizabeth Dowd.
Advertisements

CompSci 101 Introduction to Computer Science Feb 26, 2015 Prof. Rodger.
CompSci 101 Introduction to Computer Science January 13, 2015 Prof. Rodger compsci 101 spring
COMP 1001: Introduction to Computers for Arts and Social Sciences Programming in Scratch Monday, May 16, 2011.
CompSci 101 Introduction to Computer Science January 20, 2015 Prof. Rodger compsci 101, spring
Computers Are Your Future Twelfth Edition Spotlight 2: File Management Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 1.
Component 4: Introduction to Information and Computer Science Unit 4: Application and System Software Lecture 3 This material was developed by Oregon Health.
Ch 1. A Python Q&A Session Spring Why do people use Python? Software quality Developer productivity Program portability Support libraries Component.
CompSci 6 Introduction to Computer Science October 20, 2011 Prof. Rodger.
CompSci 100e Program Design and Analysis II March 29, 2011 Prof. Rodger CompSci 100e, Spring20111.
CompSci 101 Introduction to Computer Science September 23, 2014 Prof. Rodger.
Operating System What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. An operating.
CompSci 101 Introduction to Computer Science Sept. 9, 2014 Prof. Rodger President Brodhead speech graduation 2010 CompSci 101 Fall
CompSci 6 Introduction to Computer Science November 1, 2011 Prof. Rodger.
CompSci 6 Introduction to Computer Science Sept 29, 2011 Prof. Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not.
CompSci 6 Introduction to Computer Science November 8, 2011 Prof. Rodger.
CompSci 101 Introduction to Computer Science November 18, 2014 Prof. Rodger.
CompSci 101 Introduction to Computer Science March 3, 2015 Prof. Rodger compsci101 spring151.
CompSci 101 Introduction to Computer Science March 31, 2015 Prof. Rodger Thanks to Elizabeth Dowd for giving this lecture Review for exam.
CompSci 101 Introduction to Computer Science February 10, 2015 Prof. Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were.
CompSci 101 Introduction to Computer Science January 28, 2016 Prof. Rodger compsci101 spring161.
Xi Wang Yang Zhang. 1. Easy to learn 2. Clean and readable codes 3. A lot of useful packages, especially for web scraping and text mining 4. Growing popularity.
CompSci 101 Introduction to Computer Science February 4, 2016 Prof. Rodger compsci101 spring161.
CompSci 101 Introduction to Computer Science Feb 24, 2015 Prof. Rodger.
Genome Revolution: COMPSCI 006G 15.1 Recursion and Recursive Structures l Definition in the dictionary: in mathematics an expression in which a value is.
CompSci 101 Introduction to Computer Science February 11, 2016 Prof. Rodger.
Compsci 06/101, Spring Compsci 6/101: Re[gex|cursion] l Regular expressions and grammars  Recognizing and validating text based on rules  Generating.
CompSci 101 Introduction to Computer Science January 26, 2016 Prof. Rodger compsci 101, spring
CompSci 101 Introduction to Computer Science November 11, 2014 Prof. Rodger CompSci 101 Fall Review for exam.
CompSci 101 Introduction to Computer Science March 17, 2015 Prof. Rodger compsci 101, spring
CompSci 101 Introduction to Computer Science February 25, 2016 Prof. Rodger compsci101 spring20161.
CompSci 101 Introduction to Computer Science January 15, 2015 Prof. Rodger 1.
CompSci 6 Introduction to Computer Science September 27, 2011 Prof. Rodger CompSci 6 Fall
CompSci 101 Introduction to Computer Science February 16, 2016 Prof. Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were.
CompSci 101 Introduction to Computer Science April 7, 2015 Prof. Rodger.
CompSci 101 Introduction to Computer Science March 24, 2016 Prof. Rodger compsci 101, spring
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
CompSci 101 Introduction to Computer Science March 8, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science April 14, 2016 Prof. Rodger Lecture today by Sriram Vepuri.
Compsci 101.2, Fall Plan for ThBThB l Programming and understanding …  Hierarchical structures and concepts What is a file system on a computer?
CompSci 101 Introduction to Computer Science March 29, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science February 5, 2015 Prof. Rodger Lecture given by Elizabeth Dowd compsci101 spring151.
CMSC201 Computer Science I for Majors Lecture 19 – Recursion
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 6 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CMSC201 Computer Science I for Majors Lecture 18 – Recursion
Fundamentals of Programming I Design with Functions
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CMSC201 Computer Science I for Majors Lecture 16 – Recursion
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CMSC201 Computer Science I for Majors Lecture 19 – Recursion
Grammars, Regex, Problems and More
CompSci 101 Introduction to Computer Science
3.1 Basic Concept of Directory and Sub-directory
Department of Computing Science
Presentation transcript:

CompSci 101 Introduction to Computer Science April 14, 2016 Prof. Rodger compsci101 spring161

Announcements Reading and RQ 17 due next time Assignment 7 due today –Assign 8 due April 21, Assign 9 due April 28 –APT 10 due Tuesday Today: –How do you access directories –Recursion – Solving problems by solving smaller and smaller similar problems –Exam back compsci101 spring162

Plan for Today Programming and understanding … –Hierarchical structures and concepts What is a file system on a computer? What is the Internet? How does the Domain Name System Work? How do you access directories? And all the files in a directory, and the … compsci101 spring163

What's in a file-system Folder? compsci101 spring164

What's in a folder on your computer? Where are the large files? How do you find them? They take up space! Erase? Backup? –Can a folder be inside a folder? Why? compsci101 spring165

Finding large files: FileVisit.py def bigfiles(dirname,min_size): large = [] for sub in os.listdir(dirname): path = os.path.join(dirname,sub) if os.path.isdir(path): subs = bigfiles(path,min_size) large.extend(subs) else: size = os.path.getsize(path) if size > min_size: large.append((path,size)) return large # on Mac like this: #bigs = bigfiles("/Users/Susan/Documents",10000) # on Windows like this: bigs = bigfiles("C:\\Users\\Susan\\Documents",10000)

Example Run ('C:\\Users\\Susan\\files\\courses\\cps101\\w orkspace\\spring2015\\assign4_transform\\d ata\\romeo.txt', L) ('C:\\Users\\Susan\\files\\courses\\cps101\\w orkspace\\spring2015\\assign4_transform\\d ata\\twain.txt', 13421L) ('C:\\Users\\Susan\\files\\courses\\cps101\\w orkspace\\spring2015\\assign5_hangman\\sr c\\lowerwords.txt', L) … compsci101 spring167

Does the function call itself? No! def visit(dirname): for inner in dirname: if isdir(inner): visit(inner) else: print name(inner), size(inner) Is a file inside itself? No! Does pseudo code make sense? –Details make this a little harder in Python, but close! compsci101 spring168

Structure matches Code If you see a folder –Find large files, if you find a folder, … –To compress folder, must compress … Files and repeat process for folders Structure of list of lists –Can also lead to processing a list which requires processing a list which … [ [ [a,b], [c,d], [a, [b,c],d] ] (a *(b + c (d + e*f)) + (a* (b+d))) compsci101 spring169

Recursion Structure matches code, or concept matches code –Must have a base case when no recursive call made Simpler/smaller calls The case of Quicksort –Inventor didn't get it compsci101 spring1610

Sir Anthony (Tony) Hoare There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. Turing Award, didn’t get recursion….. Inventor of quicksort compsci101 spring1611

The os and os.path libraries Use an API to isolate system dependencies –C:\\x\\y # windows –/Users/Susan/Desktop # mac FAT-32, ReFS, WinFS, HFS, HSF+, fs –Underneath, these systems are different –Python API insulates and protects programmer Why do we have os.path.join(x,y) ? compsci101 spring1612

os. And os.path questions bit.ly/101sp compsci101 spring1613

Dissecting FileVisit.py How do we find the contents of a folder? –Another name for folder: directory How do we identify folder? (by name) –os.listdir(dirname) returns a list of files and folder Path is c:\user\ola\foo or /Users/ola/bar –os.path.join(dir,sub) returns full path –Platform independent paths What's the difference between file and folder? –os.path.isdir() and os.path.getsize() compsci101 spring1614

Recursion in Pictures and compsci101 spring1615

Mystery Recursion bit.ly/101sp compsci101 spring1616

Something Recursion bitly/101sp compsci101 spring1617

Hand back Exam 2 compsci101 spring1618