Comments (17)
Mmmm.. I wonder if I got this wrong:
("spam" not in "spa span sparql") --> is "spam" not in "spa span sparql"? --> No = True
("egg" > "span") --> is "egg" bigger than "span" (is egg alphabetically bigger than span?) --> No = False
True and not (False)
True and True
True
from 2018-2019.
“Spam” not in “spa span sparql” = T
Not (“egg”>”span”)= F
T and F = F
from 2018-2019.
"spam" not in "spa span sparql" = True
and
not ("egg" > "span") = True
True and True = True
Note: I agree with @delfimpandiani: if "a string S1 is less than another string S2 if the former one precedes the latter one according to a pure alphabetic order" (Table 2, Programming languages lecture notes), I suppose that a string is greater than another string if the former follows the latter in alphabetical order, therefore "egg" > "span" = False because "egg" does not follow "span" in the alphabet.
from 2018-2019.
"spam" not in "spa span sparql" and not ("egg" > "span")
"spam" not in "spa span sparql" = True
not ("egg" > "span") = not False = True
True and True = True
from 2018-2019.
"spam" not in "spa span sparql" = True
("egg" > "span") = False --- not False = True
According to the Boolean value;
True and True = True
from 2018-2019.
"spam" not in "spa span sparql" and not ("egg" > "span")
True and not (False)
True and True
True
from 2018-2019.
from 2018-2019.
"spam" not in "spa span sparql" and not ("egg">"span")
T and not F
T and t
True
from 2018-2019.
"spam" not in "spa span sparql" and not ("egg" > "span")
True and not (False)
True and True
True
from 2018-2019.
"spam" not in "spa span sparql" and not ("egg" > "span")
-
I phase: brackets and first not don't influence each other so I can do them at the same time. Spam Is not in the string "spa span sparql" so "not" will return True. "Egg" is located before "span" so the operator ">" will return False (egg is "less" than "span")
Result:
True and not False -
II phase: I have to do "not" before "and"
Result:
True and True -
III phase: now I can do the last operation "And"
result: True
from 2018-2019.
"spam" not in "spa span sparql" and not ("egg" > "span")
"spam" not in "spa span sparql" and not (False)
True and True
True
Again, we need to execute the operation contained in round brackets "egg" > "span"
. Alphabetically, e is not bigger than s (that is, it comes first in order) so the output is False
. Then we resolve not
operators and, finally, the and
operator.
from 2018-2019.
What is the boolean value of "spam" not in "spa span sparql" and not ("egg" > "span")?
"spam" not in "spa span sparql" and not (False) >> "egg" should be less than "span"
true and not false
true
from 2018-2019.
Applied with strings, the logical operator > ("egg" > "span") uses the alphabetic order for the operation, e.g. "a" < "b" is true, because the letter "a" is listed before "b" in the alphabetic order. Based on this rule, the computation "egg" > "span" is false.
"spam" not in "spa span sparql" and not ("egg" > "span")
true and not(false)
true and true
true
from 2018-2019.
"spam" not in "spa span sparql" and not ("egg" > "span")
"spam" not in "spa span sparql" = True
not ("egg" > "span") = not (False)
True and not (False) = True and True
=> True
from 2018-2019.
"spam" not in "spa span sparql" and not ("egg" > "span")
"spam" not in "spa span sparql" --> true
("egg" > "span") --> false
true and not (false)
true and true
true
from 2018-2019.
Question
In the absence of round brackets, string operations have priority over boolean operations right? I was just wondering since "spam" not in "spa span sparql" is not between round brackets but ("egg" > "span") is. It does completely make sense to me if it works like this, otherwise you might have boolean operators operating on strings rather than booleans. If this is correct this would mean that the round brackets around ("egg" > "span") are redundant. Any body could confirm this by commenting the hooray on my question?
from 2018-2019.
Answering your question, indeed all the comparisons will be executed before any other boolean operation.
from 2018-2019.
Related Issues (20)
- Lecture "Brute-force algorithms", exercise 3 HOT 13
- Lecture "Brute-force algorithms", exercise 4 HOT 16
- Lecture "Brute-force algorithms", exercise 5 HOT 12
- Lecture "Organising information: unordered structures", exercise 1 HOT 21
- Lecture "Organising information: unordered structures", exercise 2 HOT 19
- Lecture "Organising information: unordered structures", exercise 3 HOT 17
- Lecture "Recursion", exercise 1 HOT 18
- Lecture "Recursion", exercise 2 HOT 20
- Lecture "Divide and conquer algorithm", exercise 1 HOT 12
- Lecture "Divide and conquer algorithm", exercise 2 HOT 5
- Lecture "Dynamic programming algorithms", exercise 1 HOT 15
- Lecture "Dynamic programming algorithms", exercise 2 HOT 8
- Lecture "Organising information: trees", exercise 1 HOT 4
- Lecture "Organising information: trees", exercise 2 HOT 4
- Lecture "Organising information: graphs", exercise 1 HOT 14
- Lecture "Organising information: graphs", exercise 2 HOT 12
- Christmas present game + bonus Python exercise
- Lecture "Backtracking algorithms", exercise 1 HOT 3
- Lecture "Greedy algorithms", exercise 1 HOT 2
- Question about an exercise from last year
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 2018-2019.