Open essepuntato opened 4 years ago
False
Work: True and not (True) True and False False
The Boolean value is TRUE because: -"spam" not in "spa span sparql" returns TRUE -"egg"> "span" returns FALSE (I summed the values of the letters according to the alphabetical order so e=5, g=7, s=19, p=16, a=1, n=14 so egg=19 and span=50) -not FALSE (result of previous operations) is TRUE -TRUE and TRUE is TRUE
"spam" not in "spa span sparql" -> T not ("egg" > "span") -> not(F) -> T "spam" not in "spa span sparql" and not ("egg" > "span") -> T
@giorgiasampo Thank you for your detailed explanation! I thought comparisons were purely just alphabetical by word (so whichever would come first in a dictionary was considered larger). Now I understand đź‘Ť
@essepuntato Thank you Professor Peroni. For anyone else that is confused about comparing strings I found this helpful explanation with a few simple exercises at the bottom to clear up the rules for comparing strings.
@SarahTew @giorgiasampo
Indeed the comparisons with strings are alphabetical, but the one that comes first in a dictionary is lesser than the other. E.g.:
"this string" > "another string"
is True
since "t"
(first character of the first string) is greater than "a"
(first character of the second string)
“spam” not in “spa span sparql” and not (“egg”>”span)
-> “spam” not in “spa span sparql” and not False
[first solve the part in the brackets]
-> True and True
[second step solve the not
operations]
-> True
[finally solve the and
operation]
"spam" not in "spa span sparql" and not ("egg" > "span")
True and not ("egg" > "span")
True and not False
True and True
True
"spam" not in "spa span sparql" and not ("egg" > "span")
True and not False
True and True
then True
The answer is True: "spam" not in "spa span sparql" and not ("egg" > "span") True and not False [("egg" > "span") is False because egg comes before (<) "span" in alphabet] True and True True
The boolean value is True:
"spam" not in "spa span sparql" and not ("egg" > "span")
"spam" not in "spa span sparql" and not (False)
"spam" not in "spa span sparql" and True
True and True
True
TRUE: "spam" not in "spa span sparql" and not ("egg" > "span") "spam" not in "spa span sparql" and not False True and True True
The boolean value is TRUE. First of all, we analyze the first condition about the two strings "spam" and "spa span sparql". "Spam" NOT in "spa span sparql" = TRUE
So, we check the second one.
So, TRUE and TRUE= TRUE
"spam" not in "spa span sparql" and not ("egg" > "span") => false because "s" is greater than "e" (I think I understand) "spam" not in "spa span sparql" and not (False) True and True True
"spam" not in "spa span sparql" and not ("egg">"span")?
True and not (False) True and True = TRUE
This expression returns the boolean value True
"spam" not in "spa span sparql" and not ("egg" > "span"). "spam" not in "spa span "sparql" is TRUE. not("egg">"span") is TRUE ("egg" greater than "span" is false and with not TRUE) TRUE and TRUE is TRUE so TRUE
The boolean value is True.
We solve the operation in () first. "egg" is not greater than "span" by alphabetical value, so the result is False. the first part is True ("spam" is not in the string). True and not False returns True.
"spam" not in "spa span sparql" and not ("egg" > "span") ("spam" not in "spa span sparql") and not ( False ) (True) and (True) True
"spam" not in "spa span sparql" and not ("egg" > "span")
True and not False True and True True
The Boolean value is True. Here is the procedure:
"spam" not in "spa span sparql" and not ("egg" > "span")
"spam" not in "spa span sparql"
-> True
True and not ("egg" > "span")
("egg" > "span")
-> False because "e" comes before "s"
True and not (False)
True and True
True`
"spam" not in "spa span sparql" and not ("egg" > "span") "spam" not in "spa span sparql" and not false "spam" not in "spa span sparql" and true true and true true
"spam" not in "spa span sparql" and not ("egg" > "span") ("egg" > "span") = F "spam" not in "spa span sparql" = T T and not (F) not (F) = T T and T T
What is the boolean value of
"spam" not in "spa span sparql" and not ("egg" > "span")
?