Lecture 5 8/24/18. Writing larger programs. Comments. What are we going to cover today? Using Comments. Comments in Python. Writing larger programs
|
|
- Joanna Flynn
- 5 years ago
- Views:
Transcription
1 What are we going to cover today? Lecture 5 Writing and Testing Programs Writing larger programs Commenting Design Testing Writing larger programs As programs become larger and more complex, it becomes more and more important to plan out how they will work. One subfield of computer science, called software engineering, deals with the processes for constructing large pieces of software. We re not going to be handling large software in this course, but some of the principles for good software construction practice still apply. Today, we ll look at a couple of them. Comments Comments are descriptive text placed into the code of the program. Comments (for the most part) are NOT executed. They are purely for human benefit, not for the computer! As the computer reads through the code, comments are just skipped over. Comments are meant to help people understand what the purpose of the code is. Others who will read your code You, when you come back to your code in the future You, when you are dealing with a large program that s hard to keep track of Comments in Python To create a comment in Python, you can place a # in front of the comment you want. The # and everything after it on that line are totally ignored # Here is a comment before a line of code a = 3 # Here is a comment at the end of a line of code # b = 4 This whole line is a comment: the b = 4 part is not executed Using Comments You should use comments to: Describe the purpose of a line or a section of code Define the purpose of a particular variable Clarify a computation that is not present Give a reference to some external source that a person reading the code might need to be aware of Clearly separate sections of code from each other Do not use comments to: Restate what should be obvious from reading the code Add things that are irrelevant to the code itself Except for header information required for our class! 1
2 The comment that s not a comment Sometimes, you will see people use a triple-quoted string as a type of comment. Either with single quotes or double quotes: ''' or """ Basically, you can put anything in a triple-quoted string, but not assign the string to anything, and the string is effectively ignored, thus it s like a comment. a = 3 ''' This is a string that spans multiple lines, and that acts sort-of like a comment ''' People sometimes use this when they want a comment spanning multiple lines. But, it is better practice not to use this! Later, we ll see a real use for this sort of comment Visual Breaks in Code Whitespace refers to blank lines and spaces in code Whitespace can be used to separate different sections of the code. Helps identify sections of the code that have different purposes a = 3 b = 5 print( The sum is, a+b) Sometimes, comments are used to provide visual breaks: ################################## ##### New Section ##### Program Design When faced with a large task, the first thing to do is to think. This goes for almost anything: building a house, designing a bridge, etc. Writing software is the same way: think before writing code! Usually, the time spent thinking about a problem before trying to solve it will save more time later. There are many approaches to program design, but all of them involve stopping to think about design before trying to implement. A first approach to program design Consider the major stages the program will follow Typically, a sequence of operations e.g. Get input from user -> Perform calculation -> Output result List these in order (outside of a program) Convert your steps of the program to comments Fill in the regions between comments with code Example (initial steps/design): Task: write a program to calculate a person s BMI and output their weight category. Steps: 1. Read user s height and weight 2. Calculate BMI 3. Output weight category Example: Making steps into comments #Read user's height and weight #Calculate BMI #Output weight category 2
3 Example: Filling in code Writing Tests #Read user's height and weight height = float(input("enter height in inches: ")) weight = float(input("enter weight in pounds: ")) #Calculate BMI BMI = weight/(height*height)*709 #Output weight category if BMI < 18.5: print("underweight") elif BMI <=25: print("normal Weight") elif BMI <=30: print("overweight") else: print("obese") To find if a program is working, you need to test it! Never assume it s working without testing You will need to understand what your code should do This is sometimes more difficult than it might seem you often are writing a program since it is difficult to do the same thing by hand Tests should be basic input to a program (or part of a program) where you know what you should expect as output Tests could be values you enter as a user Tests could be values of variables set in the code Writing Tests (ideally) Ideally, write your tests before you write your program This will help you think through what the program should be doing This will give you a way to test your code as soon as you write it Sometimes it helps to have someone write tests who is not writing the code Ideally, if you do a good job writing tests, then if your code passes all tests, it should work. Realistically, people often write tests after writing (at least some) code and don t write sufficiently thorough tests How to write tests Test the Typical case You usually don t need to test too many of these just enough to ensure the program is basically working Test the edge cases or corner cases These are the special cases, that are less common/typical Example: on a chess board: The typical case would be a square near the middle (touching 8 other squares) Would also want to test edge squares (touching 5 other squares), and corner squares (touching 3 other squares) This is where the term edge case or corner case comes from! Exercise: Coming up with tests Imagine a program that had to process dates in a year What dates would you test? Exercise: Coming up with tests Imagine a program that had to process dates in a year What dates would you test? Typical: some dates in middle of year: e.g. May 25 or November 9 Some edge cases: First/last days of months: July 1, June 30, July 31, February 28 First/last day of the year: January 1, December 31 Special case: February 29 3
4 Implementing Tests If you have a complete program, you can test the whole process. But, it often helps to test just a piece of the program. To do this: Can read in values from a user Can set variable values to specific test cases Can print out values at various points using print statements When you find something doesn t work, you need to fix it! This is called debugging: find where the program is failing, determine the error, and fix it. Later, we will learn more formal debugging approaches An analogy for software construction There are two common architectural forms, both of which have produced structures that have lasted since ancient times: Pyramids Arches An analogy for software construction Though both pyramids and arches end up with good structures, the way they are built is quite different. Pyramid: Place stones at the bottom. Once stones underneath are set, place more on top of them. Arch: Place all stones in the arch, holding it up with temporary scaffolding. Place all stones in the arch before removing the scaffolding. An analogy for software construction With Pyramids, you can stop at any point You always have a stable structure. You can test the lower levels before adding upper levels With Arches, you can t stop at an intermediate point The structure is not stable until every stone is in place You can t really test the arch until all pieces are there So, how does this relate to software construction? Incremental Development Sometimes, people try to follow the arch style of development with their code Only after they ve written all of the code do they stop to test/evaluate it If any one piece is missing or broken, the whole program falls apart! The pyramid style lets you develop incrementally You can write small pieces of code, test them, and ensure that they are working before adding more code You always have a stable piece of software, even when not complete! When building software, try to use a pyramid process, not an arch process! Example Let s see development of a piece of code. Back to our learning example, let s say we want to compute the concepts learned getting a time of study from a user and computing how much they can expect to learn Rate of Learning 2. But perhaps there is a warm-up period where we remember what we had learned before 1. We might assume a constant learning rate 3. And, maybe when we get fatigued we learn worse Time since start of study session 4
5 Thinking about the problem What information will we need to perform the computation? Initial rate of learning Length of study session Time at which warmup stops Constant rate of learning Time when fatigue begins Time we stop learning anything new Rate of Learning Thinking about the problem What information will we need to perform the computation? Initial rate of learning Length of study session Time at which warmup stops Constant rate of learning Time when fatigue begins Time we stop learning anything new What variables will we use? (might find we need more later) rate_initial, rate_constant time_constant, time_fatigue, time_stop study_time Time since start of study session What will our general process be? Set up specific model for learning Setting variable values will hard-code them Read time from user Calculate the amount learned Output result to user Writing Code Writing Code Testing Typically, we should stop and test after each section But, for this simple program, the setup has very little we can test it s just variable assignment. We WILL stop and test future sections. 5
6 Testing study_time = input("how long will you study? ") We ll want to see if we re reading the data correctly. Let s add a single print statement in to output what we read in. study_time = input("how long will you study? ") print("entered: ", study_time) Testing Run the program, see if the input matches output. How long will you study? 10 Entered: 10 OK, it seems like it s working But was that enough of a test? Maybe we want to make sure we can do something with the value, so we might also want to test that we can compute with it Let s try, say, adding 1 to the value we read in. study_time = input("how long will you study? ") print("entered: ", study_time) Now test: How long will you study? 10 Entered: 10 Traceback (most recent call last): File "C:/Users/John/PycharmProjects/ENGR102/Test Development.py", line 12, in <module> TypeError: must be str, not int Process finished with exit code 1 Oh no! What happened that was an error! If you read the output from the failure, it gives us a hint as to what went wrong That won t always be the case, but it is, here How long will you study? 10 Entered: 10 Traceback (most recent call last): File "C:/Users/John/PycharmProjects/ENGR102/Test Development.py", line 12, in <module> TypeError: must be str, not int Process finished with exit code 1 Line number is shown, along with the statement on that line. And, it says we have a TypeError We tried to add a number to a string! 6
7 Fix the bug: study_time = input("how long will you study? ") We forgot to convert the input from a string to a number! print("entered: ", study_time) This is where the program failed, but it s not where the error is. print("entered: ", study_time) Now re-test Writing tests How long will you study? 10 Entered: 10.0 Adding 1: 11.0 Process finished with exit code 0 Before we write the next section, computing study, let s think of some tests. Study times to test: Typical points: during the warmup, during the constant period, during the fatigue period Edge cases: 0, at transition points, negative values, values past stop point Looks good, now We could do more tests, but for illustration, let s move on. Rate of Learning Time since start of study session Other tests Need to come up with specific values for learning model, and should test with multiple such values Will need to determine actual values. For the values we ve put into code, we could test study times, and expect values of: 0: 0 8: : : : : : : (after stop period) -1: 0 (before) Now write code Code will require if-elif-else statements Went through an example in last lecture Will add comments throughout Need a new variable to store answer: concepts_learned And maybe some others along the way! Test pieces incrementally First write and test the warmup calculation Then write and test the constant period of time Then write and test fatigue period Test all the other cases Will use the overall output as our test output, in this instance. 7
8 Now test warmup period Test for time 0, time 8, time 15 For this example, we won t have more bugs in the code, but in general, you might find them if (study_time >=0) and (study_time <= time_constant): #warmup period end_learn_rate = rate_initial + (rate_constant - rate_initial) / time_constant * study_time concepts_learned = study_time * (rate_initial + end_learn_rate) / 2 print("you learned",concepts_learned,"concepts in that time.") Adding constant period (then should test) Adding fatigue period (then should test) if (study_time >=0) and (study_time <= time_constant): if (study_time >=0) and (study_time <= time_constant): #warmup period #warmup period end_learn_rate = rate_initial + (rate_constant - rate_initial) / time_constant * study_time end_learn_rate = rate_initial + (rate_constant - rate_initial) / time_constant * study_time concepts_learned = study_time * (rate_initial + end_learn_rate) / 2 concepts_learned = study_time * (rate_initial + end_learn_rate) / 2 elif (study_time > time_constant) and (study_time <= time_fatigue): elif (study_time > time_constant) and (study_time <= time_fatigue): #constant period #constant period concepts_learned = 2.25 #concepts learned during warmup concepts_learned = 2.25 #concepts learned during warmup concepts_learned += rate_constant * (study_time - time_constant) concepts_learned += rate_constant * (study_time - time_constant) elif (study_time > time_fatigue) and (study_time <= time_stop): #fatique period print("you learned",concepts_learned,"concepts in that time.") concepts_learned = #concepts learned through constant period end_learn_rate = (study_time - time_fatigue) / (time_stop-time_fatigue) concepts_learned += (study_time - time_fatigue) * (rate_constant * end_learn_rate) / 2 print("you learned",concepts_learned,"concepts in that time.") if (study_time >=0) and (study_time <= time_constant): #warmup period end_learn_rate = rate_initial + (rate_constant - rate_initial) / time_constant * study_time concepts_learned = study_time * (rate_initial + end_learn_rate) / 2 elif (study_time > time_constant) and (study_time <= time_fatigue): #constant period concepts_learned = 2.25 #concepts learned during warmup concepts_learned += rate_constant * (study_time - time_constant) elif (study_time > time_fatigue) and (study_time <= time_stop): #fatique period concepts_learned = #concepts learned through constant period end_learn_rate = (study_time - time_fatigue) / (time_stop-time_fatigue) concepts_learned += (study_time - time_fatigue) * (rate_constant * end_learn_rate) / 2 elif (study_time > time_stop): #post-fatque: nothing more to learn concepts_learned = else: #negative time - nothing can be learned! concepts_leanred = 0 Adding before/after periods (then should test) Summary Think about the program What do you need to do Determine key variables Write some comments Think about testing (the earlier the better) Code incrementally Test each section of code after you write it print("you learned",concepts_learned,"concepts in that time.") 8
9 For more complex programs As the computation becomes more complex, design will increase in importance. There are more formalized methods for ways of designing We ll see a couple of these, top-down and bottom-up, later in the course 9
Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn
Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn Problem Write and test a Scheme program to compute how many days are spanned by two given days. The program will include a procedure
More informationIf Statements, For Loops, Functions
Fundamentals of Programming If Statements, For Loops, Functions Table of Contents Hello World Types of Variables Integers and Floats String Boolean Relational Operators Lists Conditionals If and Else Statements
More informationFunctions and Decomposition
Unit 4 Functions and Decomposition Learning Outcomes Design and implement functions to carry out a particular task. Begin to evaluate when it is necessary to split some work into functions. Locate the
More informationGetting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners
Getting Started Excerpted from Hello World! Computer Programming for Kids and Other Beginners EARLY ACCESS EDITION Warren D. Sande and Carter Sande MEAP Release: May 2008 Softbound print: November 2008
More informationHello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications
Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this
More informationControl Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur
Control Structures Code can be purely arithmetic assignments At some point we will need some kind of control or decision making process to occur C uses the if keyword as part of it s control structure
More informationLecture 4 CSE July 1992
Lecture 4 CSE 110 6 July 1992 1 More Operators C has many operators. Some of them, like +, are binary, which means that they require two operands, as in 4 + 5. Others are unary, which means they require
More informationExcel Basics: Working with Spreadsheets
Excel Basics: Working with Spreadsheets E 890 / 1 Unravel the Mysteries of Cells, Rows, Ranges, Formulas and More Spreadsheets are all about numbers: they help us keep track of figures and make calculations.
More informationText Input and Conditionals
Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()
More informationExcel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller
Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing
More informationS206E Lecture 19, 5/24/2016, Python an overview
S206E057 Spring 2016 Copyright 2016, Chiu-Shui Chan. All Rights Reserved. Global and local variables: differences between the two Global variable is usually declared at the start of the program, their
More informationReliable programming
Reliable programming How to write programs that work Think about reliability during design and implementation Test systematically When things break, fix them correctly Make sure everything stays fixed
More informationCMSC 201 Spring 2017 Lab 05 Lists
CMSC 201 Spring 2017 Lab 05 Lists Assignment: Lab 05 Lists Due Date: During discussion, February 27th through March 2nd Value: 10 points (8 points during lab, 2 points for Pre Lab quiz) This week s lab
More informationLecture 4 8/24/18. Expressing Procedural Knowledge. Procedural Knowledge. What are we going to cover today? Computational Constructs
What are we going to cover today? Lecture 4 Conditionals and Boolean Expressions What is procedural knowledge? Boolean expressions The if-else and if-elif-else statements s Procedural Knowledge We differentiate
More information1: Introduction to Object (1)
1: Introduction to Object (1) 김동원 2003.01.20 Overview (1) The progress of abstraction Smalltalk Class & Object Interface The hidden implementation Reusing the implementation Inheritance: Reusing the interface
More information1.7 Limit of a Function
1.7 Limit of a Function We will discuss the following in this section: 1. Limit Notation 2. Finding a it numerically 3. Right and Left Hand Limits 4. Infinite Limits Consider the following graph Notation:
More informationLoop structures and booleans
Loop structures and booleans Michael Mandel Lecture 7 Methods in Computational Linguistics I The City University of New York, Graduate Center https://github.com/ling78100/lectureexamples/blob/master/lecture07final.ipynb
More informationCS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise
CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise If you re not already crazy about Scheme (and I m sure you are), then here s something to get
More informationSection 1.1 Definitions and Properties
Section 1.1 Definitions and Properties Objectives In this section, you will learn to: To successfully complete this section, you need to understand: Abbreviate repeated addition using Exponents and Square
More informationCMSC 201 Fall 2016 Lab 09 Advanced Debugging
CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working
More informationPython for Non-programmers
Python for Non-programmers A Gentle Introduction 1 Yann Tambouret Scientific Computing and Visualization Information Services & Technology Boston University 111 Cummington St. yannpaul@bu.edu Winter 2013
More informationThe name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.
Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that
More informationCS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style
CS125 : Introduction to Computer Science Lecture Notes #4 Type Checking, Input/Output, and Programming Style c 2005, 2004, 2002, 2001, 2000 Jason Zych 1 Lecture 4 : Type Checking, Input/Output, and Programming
More informationSection 0.3 The Order of Operations
Section 0.3 The Contents: Evaluating an Expression Grouping Symbols OPERATIONS The Distributive Property Answers Focus Exercises Let s be reminded of those operations seen thus far in the course: Operation
More informationBoolean Expressions. Is Equal and Is Not Equal
3 MAKING CHOICES Now that we ve covered how to create constants and variables, you re ready to learn how to tell your computer to make choices. This chapter is about controlling the flow of a computer
More informationIf you don t, it will return the same thing as == But this may not be what you want... Several different kinds of equality to consider:
CS61B Summer 2006 Instructor: Erin Korber Lecture 5, 3 July Reading for tomorrow: Chs. 7 and 8 1 Comparing Objects Every class has an equals method, whether you write one or not. If you don t, it will
More informationBoolean Expressions. Is Equal and Is Not Equal
3 MAKING CHOICES ow that we ve covered how to create constants and variables, you re ready to learn how to tell your computer to make choices. This chapter is about controlling the flow of a computer program
More information(Python) Chapter 3: Repetition
(Python) Chapter 3: Repetition 3.1 while loop Motivation Using our current set of tools, repeating a simple statement many times is tedious. The only item we can currently repeat easily is printing the
More informationWeek - 01 Lecture - 03 Euclid's Algorithm for gcd. Let us continue with our running example of gcd to explore more issues involved with program.
Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 03 Euclid's Algorithm
More informationLOOPS. Repetition using the while statement
1 LOOPS Loops are an extremely useful feature in any programming language. They allow you to direct the computer to execute certain statements more than once. In Python, there are two kinds of loops: while
More informationHow To Get Your Word Document. Ready For Your Editor
How To Get Your Word Document Ready For Your Editor When your document is ready to send to your editor you ll want to have it set out to look as professional as possible. This isn t just to make it look
More informationCSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch
CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed
More informationPart II Composition of Functions
Part II Composition of Functions The big idea in this part of the book is deceptively simple. It s that we can take the value returned by one function and use it as an argument to another function. By
More informationIntroduction to Programming Style
Introduction to Programming Style Thaddeus Aid The IT Learning Programme The University of Oxford, UK 30 July, 2013 Abstract Programming style is the part of the program that the human reads and the compiler
More informationLecture 4. Conditionals and Boolean Expressions
Lecture 4 Conditionals and Boolean Expressions What are we going to cover today? What is procedural knowledge? Boolean expressions The if-else and if-elif-else statements Examples Procedural Knowledge
More information6.189 Project 1. Readings. What to hand in. Project 1: The Game of Hangman. Get caught up on all the readings from this week!
6.189 Project 1 Readings Get caught up on all the readings from this week! What to hand in Print out your hangman code and turn it in Monday, Jaunary 10 at 2:10 PM. Be sure to write your name and section
More informationprinceton univ. F 17 cos 521: Advanced Algorithm Design Lecture 24: Online Algorithms
princeton univ. F 17 cos 521: Advanced Algorithm Design Lecture 24: Online Algorithms Lecturer: Matt Weinberg Scribe:Matt Weinberg Lecture notes sourced from Avrim Blum s lecture notes here: http://www.cs.cmu.edu/
More informationRACKET BASICS, ORDER OF EVALUATION, RECURSION 1
RACKET BASICS, ORDER OF EVALUATION, RECURSION 1 COMPUTER SCIENCE 61AS 1. What is functional programming? Give an example of a function below: Functional Programming In functional programming, you do not
More informationCMSC 201 Fall 2018 Lab 04 While Loops
CMSC 201 Fall 2018 Lab 04 While Loops Assignment: Lab 04 While Loops Due Date: During discussion, September 24 th through September 27 th Value: 10 points (8 points during lab, 2 points for Pre Lab quiz)
More informationIntro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming
Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals
More informationExcel programmers develop two basic types of spreadsheets: spreadsheets
Bonus Chapter 1 Creating Excel Applications for Others In This Chapter Developing spreadsheets for yourself and for other people Knowing what makes a good spreadsheet application Using guidelines for developing
More informationCMSC 201 Spring 2019 Lab 06 Lists
CMSC 201 Spring 2019 Lab 06 Lists Assignment: Lab 06 Lists Due Date: Thursday, March 7th by 11:59:59 PM Value: 10 points This week s lab will put into practice the concepts you learned about lists: indexing,
More informationFOR Loops. Last Modified: 01 June / 1
FOR Loops http://people.sc.fsu.edu/ jburkardt/isc/week04 lecture 08.pdf... ISC3313: Introduction to Scientific Computing with C++ Summer Semester 2011... John Burkardt Department of Scientific Computing
More informationChapter 2 Programming in Python
Chapter 2 Programming in Python Depending on your previous programming background, we recommend different paths through the available readings: If you have never programmed before: you should start with
More informationHow To Think Like A Computer Scientist, chapter 3; chapter 6, sections
6.189 Day 3 Today there are no written exercises. Turn in your code tomorrow, stapled together, with your name and the file name in comments at the top as detailed in the Day 1 exercises. Readings How
More informationIntroduction to Python Code Quality
Introduction to Python Code Quality Clarity and readability are important (easter egg: type import this at the Python prompt), as well as extensibility, meaning code that can be easily enhanced and extended.
More informationRev. C 11/09/2010 Downers Grove Public Library Page 1 of 41
Table of Contents Objectives... 3 Introduction... 3 Excel Ribbon Components... 3 Office Button... 4 Quick Access Toolbar... 5 Excel Worksheet Components... 8 Navigating Through a Worksheet... 8 Making
More informationPost Experiment Interview Questions
Post Experiment Interview Questions Questions about the Maximum Problem 1. What is this problem statement asking? 2. What is meant by positive integers? 3. What does it mean by the user entering valid
More informationAPCS-AB: Java. Recursion in Java December 12, week14 1
APCS-AB: Java Recursion in Java December 12, 2005 week14 1 Check point Double Linked List - extra project grade Must turn in today MBCS - Chapter 1 Installation Exercises Analysis Questions week14 2 Scheme
More informationFoundations, Reasoning About Algorithms, and Design By Contract CMPSC 122
Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122 I. Logic 101 In logic, a statement or proposition is a sentence that can either be true or false. A predicate is a sentence in
More informationLecture 14: Exceptions 10:00 AM, Feb 26, 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 14: Exceptions 10:00 AM, Feb 26, 2018 Contents 1 Exceptions and How They Work 1 1.1 Update to the Banking Example.............................
More informationProgramming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.
Plan for the rest of the semester: Programming We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems. We saw earlier that computers
More informationLecture 05 I/O statements Printf, Scanf Simple statements, Compound statements
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple
More informationLecture 12 CSE July Today we ll cover the things that you still don t know that you need to know in order to do the assignment.
Lecture 12 CSE 110 20 July 1992 Today we ll cover the things that you still don t know that you need to know in order to do the assignment. 1 The NULL Pointer For each pointer type, there is one special
More informationWeek - 04 Lecture - 01 Merge Sort. (Refer Slide Time: 00:02)
Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 04 Lecture - 01 Merge Sort (Refer
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationNot-So-Mini-Lecture 6. Modules & Scripts
Not-So-Mini-Lecture 6 Modules & Scripts Interactive Shell vs. Modules Launch in command line Type each line separately Python executes as you type Write in a code editor We use Atom Editor But anything
More information» How do I Integrate Excel information and objects in Word documents? How Do I... Page 2 of 10 How do I Integrate Excel information and objects in Word documents? Date: July 16th, 2007 Blogger: Scott Lowe
More informationCS103 Handout 29 Winter 2018 February 9, 2018 Inductive Proofwriting Checklist
CS103 Handout 29 Winter 2018 February 9, 2018 Inductive Proofwriting Checklist In Handout 28, the Guide to Inductive Proofs, we outlined a number of specifc issues and concepts to be mindful about when
More informationRecursively Enumerable Languages, Turing Machines, and Decidability
Recursively Enumerable Languages, Turing Machines, and Decidability 1 Problem Reduction: Basic Concepts and Analogies The concept of problem reduction is simple at a high level. You simply take an algorithm
More informationFirst-Order Translation Checklist
CS103 Winter 2019 First-Order Translation Checklist Cynthia Lee Keith Schwarz In this handout, we ve distilled five specific points that you should check in your first-order logic statements before submitting
More informationUnit Testing as Hypothesis Testing
Unit Testing as Hypothesis Testing Jonathan Clark September 19, 2012 5 minutes You should test your code. Why? To find bugs. Even for seasoned programmers, bugs are an inevitable reality. Today, we ll
More informationTrombone players produce different pitches partly by varying the length of a tube.
Trombone players produce different pitches partly by varying the length of a tube. 7 Variables A variable is a connection between a name and a value.* That sounds simple enough, but some complexities arise
More informationAppendix: Common Errors
Appendix: Common Errors Appendix 439 This appendix offers a brief overview of common errors that occur in Processing, what those errors mean and why they occur. The language of error messages can often
More informationHave the students look at the editor on their computers. Refer to overhead projector as necessary.
Intro to Programming (Time 15 minutes) Open the programming tool of your choice: If you ve installed, DrRacket, double-click the application to launch it. If you are using the online-tool, click here to
More informationHow does light energy travel? transparent transmit mediums media medium
Have you ever observed a solar eclipse like the one in this photograph? During a solar eclipse, it can become very dark in the middle of a sunny day. This may seem amazing to us, but it was terrifying
More informationIt s possible to get your inbox to zero and keep it there, even if you get hundreds of s a day.
It s possible to get your email inbox to zero and keep it there, even if you get hundreds of emails a day. It s not super complicated, though it does take effort and discipline. Many people simply need
More informationComputational Geometry: Lecture 5
Computational Geometry: Lecture 5 Don Sheehy January 29, 2010 1 Degeneracy In many of the algorithms that we have discussed so far, we have run into problems when that input is somehow troublesome. For
More informationSlide Set 15 (Complete)
Slide Set 15 (Complete) for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary November 2017 ENCM 339 Fall 2017
More informationLecture 9: July 14, How to Think About Debugging
Lecture 9: July 14, 2011 How to Think About Debugging So, you wrote your program. And, guess what? It doesn t work. L Your program has a bug in it Somehow, you must track down the bug and fix it Need to
More informationHere we will look at some methods for checking data simply using JOSM. Some of the questions we are asking about our data are:
Validating for Missing Maps Using JOSM This document covers processes for checking data quality in OpenStreetMap, particularly in the context of Humanitarian OpenStreetMap Team and Red Cross Missing Maps
More informationLesson 4: Who Goes There?
Lesson 4: Who Goes There? In this lesson we will write a program that asks for your name and a password, and prints a secret message if you give the right password. While doing this we will learn: 1. What
More informationGoogle Earth: Significant Places in Your Life Got Maps? Workshop June 17, 2013
Google Earth: Significant Places in Your Life Got Maps? Workshop June 17, 2013 1. Open Google Earth. 2. Familiarize yourself with Google Earth s navigational features by zooming into Furman s campus, your
More informationThe Dynamic Typing Interlude
CHAPTER 6 The Dynamic Typing Interlude In the prior chapter, we began exploring Python s core object types in depth with a look at Python numbers. We ll resume our object type tour in the next chapter,
More information61A Lecture 2. Friday, August 28, 2015
61A Lecture 2 Friday, August 28, 2015 Names, Assignment, and User-Defined Functions (Demo) Types of Expressions Primitive expressions: 2 add 'hello' Number or Numeral Name String Call expressions: max
More informationA simple problem that has a solution that is far deeper than expected!
The Water, Gas, Electricity Problem A simple problem that has a solution that is far deeper than expected! Consider the diagram below of three houses and three utilities: water, gas, and electricity. Each
More informationIntroduction to Programming
CHAPTER 1 Introduction to Programming Begin at the beginning, and go on till you come to the end: then stop. This method of telling a story is as good today as it was when the King of Hearts prescribed
More informationCS1 Lecture 5 Jan. 25, 2019
CS1 Lecture 5 Jan. 25, 2019 HW1 due Monday, 9:00am. Notes: Do not write all the code at once before starting to test. Take tiny steps. Write a few lines test... add a line or two test... add another line
More informationAssignment #1 Simple C++
Eric Roberts Handout #5 CS 106B January 7, 2015 Assignment #1 Simple C++ Due: Friday, January 16 Part 1. Get Qt Creator working Parts of this handout were written by Julie Zelenski. Your first task is
More informationHow to Get Your Inbox to Zero Every Day
How to Get Your Inbox to Zero Every Day MATT PERMAN WHATSBESTNEXT.COM It s possible to get your email inbox to zero and keep it there, even if you get hundreds of emails a day. It s not super complicated,
More informationCache Coherence Tutorial
Cache Coherence Tutorial The cache coherence protocol described in the book is not really all that difficult and yet a lot of people seem to have troubles when it comes to using it or answering an assignment
More information14.1 Encoding for different models of computation
Lecture 14 Decidable languages In the previous lecture we discussed some examples of encoding schemes, through which various objects can be represented by strings over a given alphabet. We will begin this
More informationFor Volunteers An Elvanto Guide
For Volunteers An Elvanto Guide www.elvanto.com Volunteers are what keep churches running! This guide is for volunteers who use Elvanto. If you re in charge of volunteers, why not check out our Volunteer
More informationYou just told Matlab to create two strings of letters 'I have no idea what I m doing' and to name those strings str1 and str2.
Chapter 2: Strings and Vectors str1 = 'this is all new to me' str2='i have no clue what I am doing' str1 = this is all new to me str2 = I have no clue what I am doing You just told Matlab to create two
More informationProblem Solving for Intro to Computer Science
Problem Solving for Intro to Computer Science The purpose of this document is to review some principles for problem solving that are relevant to Intro to Computer Science course. Introduction: A Sample
More informationHeuristic Evaluation of Team Betamax
Heuristic Evaluation of Team Betamax Eric Gallimore Connor Riley Becky Scholl Chris Stone November 4, 2006 Overview Evaluation Let s just state for the record that we like this a whole lot better than
More informationCS 102 Lab 3 Fall 2012
Name: The symbol marks programming exercises. Upon completion, always capture a screenshot and include it in your lab report. Email lab report to instructor at the end of the lab. Review of built-in functions
More informationChapter 1 Introduction
Chapter 1 Introduction Why I Am Writing This: Why I am I writing a set of tutorials on compilers and how to build them? Well, the idea goes back several years ago when Rapid-Q, one of the best free BASIC
More informationIntroduction to Programming in C Department of Computer Science and Engineering. Lecture No. #17. Loops: Break Statement
Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #17 Loops: Break Statement (Refer Slide Time: 00:07) In this session we will see one more feature that is present
More informationT H E I N T E R A C T I V E S H E L L
3 T H E I N T E R A C T I V E S H E L L The Analytical Engine has no pretensions whatever to originate anything. It can do whatever we know how to order it to perform. Ada Lovelace, October 1842 Before
More informationComp 11 Lectures. Mike Shah. June 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures June 26, / 57
Comp 11 Lectures Mike Shah Tufts University June 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures June 26, 2017 1 / 57 Please do not distribute or host these slides without prior permission. Mike
More information1 Introduction to Using Excel Spreadsheets
Survey of Math: Excel Spreadsheet Guide (for Excel 2007) Page 1 of 6 1 Introduction to Using Excel Spreadsheets This section of the guide is based on the file (a faux grade sheet created for messing with)
More informationStoryStylus Scripting Help
StoryStylus Scripting Help Version 0.9.6 Monday, June 29, 2015 One More Story Games, Inc. 2015 Contents Versions... 3 Scripting User Interface... 4 Script Triggers... 5 If-Then Scripting Language... 6
More informationExcerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.
Chapter 5 Using the Integers In spite of their being a rather restricted class of numbers, the integers have a lot of interesting properties and uses. Math which involves the properties of integers is
More informationProject Collaboration
Bonus Chapter 8 Project Collaboration It s quite ironic that the last bonus chapter of this book contains information that many of you will need to get your first Autodesk Revit Architecture project off
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu/program/philippines-summer-2012/ Philippines Summer 2012 Lecture 1 Introduction to Python June 19, 2012 Agenda About the Course What is
More informationMaximum and Minimum Slopes Wilfrid Laurier University
Maximum and Minimum Slopes Wilfrid Laurier University Wilfrid Laurier University December 12, 2014 In this document, you ll learn: In this document, you ll learn: how to determine the uncertainties in
More informationExcel Intermediate
Excel 2013 - Intermediate (103-124) Multiple Worksheets Quick Links Manipulating Sheets Pages EX16 EX17 Copying Worksheets Page EX337 Grouping Worksheets Pages EX330 EX332 Multi-Sheet Cell References Page
More informationAO3. 1. Load Flash. 2. Under Create New click on Flash document a blank screen should appear:
AO3 This is where you use Flash to create your own Pizzalicious advert. Follow the instructions below to create a basic advert however, you ll need to change this to fit your own design! 1. Load Flash
More informationQ&A Session for Connect with Remedy - CMDB Best Practices Coffee Break
Q&A Session for Connect with Remedy - CMDB Best Practices Coffee Break Date: Thursday, March 05, 2015 Q: When going to Asset Management Console and making an update on there, does that go to a sandbox
More information