Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lecture "Programming languages", exercise 2 #11

Open
essepuntato opened this issue Oct 20, 2020 · 22 comments
Open

Lecture "Programming languages", exercise 2 #11

essepuntato opened this issue Oct 20, 2020 · 22 comments
Labels

Comments

@essepuntato
Copy link
Contributor

What is the boolean value of "spam" not in "spa span sparql" and not ("egg" > "span")?

@SarahTew
Copy link

False

Work:
True and not (True)
True and False
False

@giorgiasampo
Copy link

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

@edoardodalborgo
Copy link

"spam" not in "spa span sparql" -> T
not ("egg" > "span") -> not(F) -> T
"spam" not in "spa span sparql" and not ("egg" > "span") -> T

@SarahTew
Copy link

SarahTew commented Oct 21, 2020

@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.

@essepuntato
Copy link
Contributor Author

essepuntato commented Oct 21, 2020

@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)

@ChiaraCati
Copy link

“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]

@fcagnola
Copy link

"spam" not in "spa span sparql" and not ("egg" > "span")
True and not ("egg" > "span")
True and not False
True and True
True

@dbrembilla
Copy link

"spam" not in "spa span sparql" and not ("egg" > "span")
True and not False
True and True then True

@vanessabonanno
Copy link

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

@AlessandraFa
Copy link

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

@gabrielefiorenza
Copy link

TRUE:
"spam" not in "spa span sparql" and not ("egg" > "span")
"spam" not in "spa span sparql" and not False
True and True
True

@LuisAmmi
Copy link

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.

  • NOT ("Egg"> "Span")
  • NOT (FALSE) --> because the first letter of "Egg" comes before "S" in the alphabet, so it's not "greater than" the second one.
  • TRUE

So, TRUE and TRUE= TRUE

@samuelespotti
Copy link

"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

@GiuliaMenna
Copy link

"spam" not in "spa span sparql" and not ("egg">"span")?

True and not (False)
True and True = TRUE

@SusannaPinotti
Copy link

This expression returns the boolean value True

@yunglong28
Copy link

"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

@laurentfintoni
Copy link

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.

@penelopelask
Copy link

"spam" not in "spa span sparql" and not ("egg" > "span")
("spam" not in "spa span sparql") and not ( False )
(True) and (True)
True

@lauratravaglini
Copy link

"spam" not in "spa span sparql" and not ("egg" > "span")

True and not False
True and True
True

@AleRosae
Copy link

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`

@IlaRoss
Copy link

IlaRoss commented Oct 24, 2020

"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

@enri-ca
Copy link

enri-ca commented Oct 24, 2020

"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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests