CompSci 101 Introduction to Computer Science Feb 26, 2015 Prof. Rodger.

Slides:



Advertisements
Similar presentations
CompSci 101 Introduction to Computer Science January 22, 2015 Prof. Rodger compsci101 spring151.
Advertisements

CompSci 101 Introduction to Computer Science February 3, 2015 Prof. Rodger Lecture given by Elizabeth Dowd.
COMP 14 Introduction to Programming Miguel A. Otaduy May 18, 2004.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 30, 2005.
CompSci 101 Introduction to Computer Science January 20, 2015 Prof. Rodger compsci 101, spring
CompSci 6 Introduction to Computer Science October 20, 2011 Prof. Rodger.
CSC 107 – Programming For Science. Today’s Goal  Discuss how to hand data to functions  Review loopholes in variables & scoping rules  Ways to get.
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.
Number Representation, Data Types and Elementary Programming Shirley Moore CS 1401 February 5-7, 2013.
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.
1 CS161 Introduction to Computer Science Topic #17.
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 6 Introduction to Computer Science September 13, 2011 Prof. Rodger.
Compsci 101.2, Fall Plan for TDAFB (after fall break) l Hear via about plans to catch-up and stay-ahead  Profs. Rodger and Astrachan to.
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.
CompSci 101 Introduction to Computer Science February 4, 2016 Prof. Rodger compsci101 spring161.
CompSci 100 Prog Design and Analysis II Sept 14, 2010 Prof. Rodger CompSci 100, Fall
Jordan Jozwiak CS50. Announcements Pset3 will be returned by 7pm on Tuesday REMINDER: Access section materials from this year and last year at
CompSci 101 Introduction to Computer Science Feb 24, 2015 Prof. Rodger.
Declaring variables The type could be: int double char String name is anything you want like lowerCaseWord.
CompSci 6 Introduction to Computer Science Sept. 20, 2011 Prof. Rodger CompSci 6 Fall
CompSci 101 Introduction to Computer Science February 11, 2016 Prof. Rodger.
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 101 Introduction to Computer Science April 14, 2016 Prof. Rodger Lecture today by Sriram Vepuri.
CompSci 101 Introduction to Computer Science March 1, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science April 14, 2016 Prof. Rodger compsci101 spring161.
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.
CompSci 4 Java 1 Apr 2, 2009 Prof. Susan Rodger. Announcements Assignment 7 questions? –Beware having two events that kick in at the same time! –Beware.
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 6 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
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
© A+ Computer Science - What is a LOOP? © A+ Computer Science -
CompSci 101 Introduction to Computer Science
Assignment Operators Topics Increment and Decrement Operators
CompSci 101 Introduction to Computer Science
Assignment Operators Topics Increment and Decrement Operators
Assignment Operators Topics Increment and Decrement Operators
Assignment Operators Topics Increment and Decrement Operators
Presentation transcript:

CompSci 101 Introduction to Computer Science Feb 26, 2015 Prof. Rodger

Announcements Reading and RQ11 now due APT 5 due Tuesday, Assign 5 due Thursday Nothing new out today Exam 1 was handed back on Tuesday

Snow day! Classwork instead No class today, instead you should work the following problems and enter your answers in the google form bit.ly/101S Feel free to get together with others and work on the problems. Suggest you work on them today! But will give you until Sunday midnight to complete. The google form will turn off Sunday midnight!

Problem 0: Set Examples s = set(lista) t = set(listb) problem1 = (s-t) | (t-s) print problem1 problem2 = (s|t) - (s&t) print problem2 problem3 = (s|t|(s&t)) print problem3 lista = ['apple', 'pear', 'fig', 'orange', 'strawberry'] listb = ['pear', 'lemon', 'grapefruit', 'orange']

Debugging Problems Today the focus is on debugging. There are several problems. Trace by hand to see if you can figure out if they are correct or not, or what to do to correct them. Enter your answers on the google form

Problem 1 – Does it work? The function sizes has a parameter named words that is a list of strings. This function returns a list of the sizes of each string. For example, sizes(['This', 'is', 'a', 'test']) should return the list [4, 2, 1, 4] def sizes(words): nums = [ ] for w in words: nums = len(w) return nums

Problem 2 – Does it work? The function buildword has a parameter words that is a list of strings. This function returns a string that is made up of the first character from each word in the list. For example, buildword(['This', 'is', 'a', 'test']) returns 'Tiat' def buildword(words): answer = '' for w in words: answer += w[:1] return answer

Problem 3 – Does it work? The function middle has a parameter names that is a list of strings, which each string is in the format "firstname:middlename:lastname". This function returns a list of strings of the middlenames. def middle(names): middlelist = [] for name in names: name.split(":") middlelist.append(name[1]) return middlelist

Problem 4 – Does it work? The function removeOs has one string parameter named names. This function returns a string equal to names but with all the lowercase o's removed. def removeOs(word): position = word.find("o") while position != -1: word = word[:position] + word[position+1:] return word

Problem 5 – Does it work? The function uniqueDigits has one int parameter number. This function returns the number of unique digits in number. If the number is , then it returns 3. def uniqueDigits(number) digits = [ ] while number > 0: digits.append(number % 10) number = number / 10 return len(digits)