Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All.

Similar presentations


Presentation on theme: "CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All."— Presentation transcript:

1 CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All rights reserved. Permission is given to CS122 Spring 2009 staff and students to use and reproduce these notes for their own use.

2 Your class instructor and TA Instructor for this section: Office: Email: Telephone: Your TAs are:

3 Announcements Direct questions outside of lab to: –bbVista discussion boards, CLC, contact email section instructor. –Writing to the course coordinator is like writing to Papadakis – too far removed to get noticed –Writing to cs122 mail list sends to all students or will be bounced and ignored.

4 Announcements All members of a group should be able to explain the answers the group gets and be able to knowledgably demonstrate how they were gotten. Graders reserve the right to give partial credit, or credit only to some when they spot-check.

5 Class Overview Lab 2 Part 0 (Repeat of Lab 1, Part 2) Solving with Inequalities Animations Lab 2 Part 1 Code Edit Regions Strings and Printing While Loops Tables

6 Solving With Inequalities Sometimes we solve equations with multiple solutions. We want to limit the solution set to certain criteria. –We can use inequalities! Example: Quadratic with positive/negative roots (Repeat of last week)

7 Solving With Inequalities Recall: To solve a system of equations, we give a set of equations to solve. (Repeat of last week)

8 Constraining Solutions (Repeat of last week)

9 Constraining Solutions We use ‘assuming’ when result is piecewise. This cuts the number of possible solutions: (Repeat of last week)

10 Animations Animations in Maple are just a list of plots. Steps for making animation: –Create a list of plots Each element represents one frame of animation Use plots[display]() to display the list in order (Repeat of last week)

11 Animations Example: (Repeat of last week)

12 Code Edit Regions A region which allows us to edit code in plain text, instead of “pretty print”. There are a few differences: All lines must end with colon or semi-colon –Semi-colon - ; - prints the result of the line to the screen –Colon - : - hides the output Use CTRL-E or CMD-E to execute to the block Show quick DEMO of creating code edit region

13 Code Edit Regions

14

15 Strings and Printing When writing code, we often want print out what is happening in our code. Strings are “strings” of characters surrounded by double-quotes Used by print commands to show us output. Print commands are like semi-colon, but allow for more complex combinations

16 Quick Overview of Strings

17 Printing Two types of print functions in Maple (for use today) –print Prints out a sequence of information –printf Lets us format strings and substitute numbers into strings

18 print()

19 printf()

20

21 While Loops While loops let us repeat a sequence of commands or operations The loop runs until a condition is met. Syntax: while do … end do;

22 While Loops

23 Tables Used in situations where we need to frequently add items to list. Main differences from lists: –Table can grow in size –Can use any value as an index You must be especially careful with tables because the index can be any type.

24 Tables

25 Putting it all together Given a list of the height, angle, and distance, find the length of the left wire. Assume we have wires of size 530 ft. We can cut them shorter but can’t combine them. So we want to check all our tower specifications to see if any guy wires will be too short. We’ll use While loops!

26

27 Final Comments When writing scripts, test your code every few lines Use print statements each step of the way to test your code Remember to comment your code so it is easier to read

28 What you should do now Connect to class web page: www.cs.drexel.edu/complab www.cs.drexel.edu/complab Start up Maple 12 Read Lab 2 directions. Do the work with your partner(s). Both should try to do the work, but the grader will need to look at only one answer to give you credit for doing the problem.

29 Finishing up – save files Make sure your name/user id/section number/ date,time/instructor name are on the verification sheet. Get the verification sheet signed and handed in. Save worksheet on desktop if you haven’t done so already. You can call the file “MyLab2CS122”. This will create a file called MyLab2CS122.mw. Submit a copy to Blackboard site. Email a copy to yourself and/or your lab partners as an attachment so you can look at what you did for review purposes later..mw file should open correctly on any Maple 12 (Mac, Windows, Linux) – file format is portable across system types.

30 Next week – Take quiz 2! Take the second quiz! Go to CLC if you need face-to-face help! Don’t wait until the last minute!


Download ppt "CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All."

Similar presentations


Ads by Google