65.3k views
0 votes
Assume that the following variables contain the values shown:

numberBig = 100 wordBig = "Constitution"
numberMedium = 10 wordMedium = "Dance"
numberSmall = 1 wordSmall = "Toy"

For each of the following Boolean expressions, decide whether the statement is true, false, or illegal. Please be sure to explain why the answer is false or illegal.
Example: a. numberBig > numberSmall = True
Boolean Expression Your answer
a. numberBig > numberSmall
b. numberBig < numberMedium
c. numberMedium = numberSmall
d. numberBig = wordBig
e. numberBig = "Big"
f. wordMedium > wordSmall
g. wordSmall = "TOY"
h. numberBig <= 5 * numberMedium + 50
i. numberBig >= 2000
j. numberBig > numberMedium + numberSmall
k. numberBig > numberMedium AND numberBig < numberSmall
l. numberBig = 100 OR numberBig > numberSmall
m. numberBig < 10 OR numberSmall > 10
n. numberBig = 300 AND numberMedium = 10 OR numberSmall = 1
o. wordSmall > wordBig
p. wordSmall > wordMedium

Assume that the following variables contain the values shown: numberBig = 100 wordBig-example-1

2 Answers

3 votes
Boolean Expression Your answer
a. numberBig > numberSmall True
b. numberBig < numberMedium False
c. numberMedium = numberSmall False
d. numberBig = wordBig Illegal
e. numberBig = "Big" Illegal
f. wordMedium > wordSmall True
g. wordSmall = "TOY" False
h. numberBig <= 5 * numberMedium + 50 True
i. numberBig >= 2000 False
j. numberBig > numberMedium + numberSmall True
k. numberBig > numberMedium AND numberBig < numberSmall Illegal
l. numberBig = 100 OR numberBig > numberSmall True
m. numberBig < 10 OR numberSmall > 10 False
n. numberBig = 300 AND numberMedium = 10 OR numberSmall = 1 False
o. wordSmall > wordBig False
p. wordSmall > wordMedium True

Step-by-step explanation:

d. numberBig = wordBig : This is illegal because numberBig is an integer while wordBig is a string.
e. numberBig = "Big" : This is illegal because "Big" is a string while numberBig is an integer.
k. numberBig > numberMedium AND numberBig < numberSmall : This is illegal because AND cannot be used to combine two inequalities.
n. numberBig = 300 AND numberMedium = 10 OR numberSmall = 1 : This may produce unexpected results because AND has a higher precedence than OR. Adding parentheses would make the expression clearer.
User Chetter Hummin
by
7.4k points
2 votes

Answer:

a. True (because 100 is greater than 1)

b. False (because 100 is not less than 10)

c. False (because 10 is not equal to 1)

d. Illegal (because you cannot compare a number to a string)

e. Illegal (because you cannot compare a number to a string)

f. True (because "Dance" comes after "Toy" in alphabetical order)

g. False (because "Toy" is not equal to "TOY")

h. True (because 5 * 10 + 50 = 100, and 100 is less than or equal to 100)

i. False (because 100 is not greater than or equal to 2000)

j. True (because 100 is greater than 10 + 1)

k. Illegal (because "AND" should be in all caps)

l. True (because 100 is equal to 100 or 100 is greater than 1)

m. False (because neither 100 nor 1 meet these conditions)

n. True (because 100 is not equal to 300 and 10 is equal to 10)

o. False (because "Toy" comes before "Constitution" in alphabetical order)

p. True (because "Toy" comes after "Dance" in alphabetical order)

User Daniel Eriksson
by
8.3k points