{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture06 - CS107 Computing for Math and Science Click to...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CS107, Prof. Steinberg, S10 1 Lecture 06 Click to edit Master subtitle style CS107: Computing for Math and Science Lecture 06: IF and Nested IF
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS107, Prof. Steinberg, S10 2 Lecture 06 If if boolean expression statements elseif boolean expression statements else statements end Evaluate these one by one until find first one that is true
Image of page 2
CS107, Prof. Steinberg, S10 3 Lecture 06 If if boolean expression Do one set of statements statements elseif boolean expression statements else statements end Do statements corresponding to first true expression If none true, do this. If there is no else, do nothing
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS107, Prof. Steinberg, S10 4 Lecture 06 Example Under what conditions would this print yes? No? if (x > 0) disp(‘no’) else disp(‘yes’) end
Image of page 4
CS107, Prof. Steinberg, S10 5 Lecture 06 Example Under what conditions would this print yes? if (x > 0) disp(‘no’) elseif (y < 0) disp(‘maybe’) else disp (‘yes’) end
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS107, Prof. Steinberg, S10 6 Lecture 06 Testing Ifs Test data should execute every line of code Test data should make every if “barely true” and “barely false” E.g., x > 5, x an integer Barely true: x = 6 Barely false: x = 5 E.g., x > 5, x a real number Barely true: 5.00001 Barely false: x = 5
Image of page 6
CS107, Prof. Steinberg, S10 7 Lecture 06 Barely true/false X X > 5 3 0 4 0 5 0 6 1 7 1 Last false First true
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS107, Prof. Steinberg, S10 8
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern