dans10-10-8

dans10-10-8 - 10/12/2007 Outline ECS 10 10/8 Announcements...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
10/12/2007 1 ECS 10 10/8 Outline ± Announcements ± Homework 2 questions ± Boolean expressions ± If/else statements ± State variables and avoiding sys.exit(…) ± Example: Coin flipping (if time permits) Announcements ± Professor Amenta will be back on Friday ± Dan Alcantara will be covering Monday and Wednesday lectures ± E-mail address: dfalcantara@gmail.com ± Slides will be on class website ± Temporary location: http://idav.ucdavis.edu/~dfalcant/ecs10/10-08-07.ppt Homework 2 ± Homework 2 due Wednesday at 10PM ± Don’t use sys.exit(…) ± Will explain why later today ± Questions? Boolean expressions if name == “” : Boolean expression name = “Anonymous” print “We’ll call you” , name, “!” Boolean algebra ± Named after George Boole (1815 (1815-1864) 1864) ± Main idea: you can write down logic as mathematical formulas, as well as in sentences. ± Logic as a computational system. Python does some of this computation!
Background image of page 1

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

View Full DocumentRight Arrow Icon
10/12/2007 2 Boolean Boolean expressions expressions ± Boolean Boolean is a new data type. is a new data type. ± Booleans can be either True or False. ± We now have four data types (and four kinds of expressions): Data type Examples Integer 1, 10, 53 Floating point 3.14159, 6.29 String “Hey”, “”, “String” Boolean True, False Basic Boolean expressions Expression Expression in English X == Y “X is equal to Y” X != Y “X is not equal to Y” X < Y “X is less than Y” X > Y “X is greater than Y” X <= Y “X is less than or equal to Y” X >= Y “X is greater than or equal to Y” not ______ “Whatever the condition, it’s not True” Boolean expressions are True if the expression in English is True, and False otherwise. Boolean expression examples Boolean expression English expression Value “Something” == “Something” The string “Something” is exactly the same as the string “Something”. True 3 < 5 The integer 3 is less than 5. True 3 > 5 The integer 3 is greater than 5. False “C at” == “ at” == “c at” The string “Cat” is exactly the same as the string “cat”. False “Cat” != “cat” The string “Cat” is different from the string “cat”.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

dans10-10-8 - 10/12/2007 Outline ECS 10 10/8 Announcements...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online