exercise7SOLUTION.docx - 44-141 Exercise 7 Solutions 1 2 Evaluate each of the following expressions(a(4 > 3 and 23 > 10 True False(b(4 > 6 or 10 < 2 6

exercise7SOLUTION.docx - 44-141 Exercise 7 Solutions 1 2...

This preview shows page 1 - 2 out of 2 pages.

44-141 Exercise 7 Solutions 1. Evaluate each of the following expressions. (a) (4 > 3 and 23 > 10) True False (b) (4 > 6 or 10 < 2 * 6) True False (c) ((7 >= 3 + 4) or 6 < 4 / 2 and 2 < 5 % 3) True False (d) not(7 <= 4 or 2 != 5 and 8 >= 4) True False 2. Assume we have declared and initialized the variables below. x = 2 y = 5 z = 8 a = False b = True Evaluate the following expressions. (a) (x – z == y) True False (b) (x * z > z * y or b) True False (c) (x * z < z * y and a) True False (d) (x * z > z * y and a or b) True False (e) not (x * z > z * y and a or b) True False
Image of page 1

Subscribe to view the full document.

3. Assume x and y are variables. Translate each phrase into an equivalent boolean expression. (a) x is less than 20 _______x < 20_________________ (b) x is between 1 and 100 (inclusive) __(x >= 1) and (x <= 100)________ (c) y is either 1 or 5 or 10 __(y == 1) or (y == 5) or (y == 10)___
Image of page 2

Unformatted text preview: (d) Both x and y are positive __(x &gt; 0) and (y &gt; 0)____________ (e) Neither x nor y is positive _(x &lt;= 0) and (y &lt;= 0)___________ 4. Assume the following variables have been declared. isVoter, validExamScore, evenNumber, age, examScore, number Circle the value stored in the boolean variable after the execution of each set of statements. (a) age = 30 isVoter = age &lt;=18 True False (b) age = 16 isVoter = age &lt;=18 True False (c) number = 11 evenNumber = number % 2 == 0 True False (d) number = 4 evenNumber = number % 2 == 0 True False (e) examScore = 60 validExamScore = examScore &gt;= 0 and examScore &lt;= 100 True False (f) examScore = 110 validExamScore = examScore &gt;= 0 and examScore &lt;= 100 True False...
View Full Document

  • Spring '16
  • DianaLinville

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

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes