What is the difference between the following two tests: w.isupper () and not w.islower ()?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
It's a question at the crossroads between computing and set theory
I just immersed myself in the Python documentation to answer this question
Let say $w$ is a string. What is the difference between the following two tests:
w.isupper ()
andnot w.islower ()
For me, the difference is that, in mathematical terms, w.isupper ()
means
$$∀x ∈ w, x∈ Upper$$
not w.islower ()
means
$$∃ x ∈ w, x ∉ Lower$$
I do not know if it is enough for everyone to say that it is different, it is Set theory and, sometimes, I really need time to understand it.
Also, there may be other computational or python reasons that I do not know
This question is from chapter 1 of Natural Language Processing with Python
python
add a comment |Â
up vote
0
down vote
favorite
It's a question at the crossroads between computing and set theory
I just immersed myself in the Python documentation to answer this question
Let say $w$ is a string. What is the difference between the following two tests:
w.isupper ()
andnot w.islower ()
For me, the difference is that, in mathematical terms, w.isupper ()
means
$$∀x ∈ w, x∈ Upper$$
not w.islower ()
means
$$∃ x ∈ w, x ∉ Lower$$
I do not know if it is enough for everyone to say that it is different, it is Set theory and, sometimes, I really need time to understand it.
Also, there may be other computational or python reasons that I do not know
This question is from chapter 1 of Natural Language Processing with Python
python
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
It's a question at the crossroads between computing and set theory
I just immersed myself in the Python documentation to answer this question
Let say $w$ is a string. What is the difference between the following two tests:
w.isupper ()
andnot w.islower ()
For me, the difference is that, in mathematical terms, w.isupper ()
means
$$∀x ∈ w, x∈ Upper$$
not w.islower ()
means
$$∃ x ∈ w, x ∉ Lower$$
I do not know if it is enough for everyone to say that it is different, it is Set theory and, sometimes, I really need time to understand it.
Also, there may be other computational or python reasons that I do not know
This question is from chapter 1 of Natural Language Processing with Python
python
It's a question at the crossroads between computing and set theory
I just immersed myself in the Python documentation to answer this question
Let say $w$ is a string. What is the difference between the following two tests:
w.isupper ()
andnot w.islower ()
For me, the difference is that, in mathematical terms, w.isupper ()
means
$$∀x ∈ w, x∈ Upper$$
not w.islower ()
means
$$∃ x ∈ w, x ∉ Lower$$
I do not know if it is enough for everyone to say that it is different, it is Set theory and, sometimes, I really need time to understand it.
Also, there may be other computational or python reasons that I do not know
This question is from chapter 1 of Natural Language Processing with Python
python
edited yesterday
William Elliot
5,0722414
5,0722414
asked 2 days ago


Marine1
798722
798722
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
Assuming w
is a string (or a byte array or something similar), the docs say following:
str.isupper()
Return true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise.
And
str.islower()
Return true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.
So w.isupper()
checks whether all characters are in uppercase, while w.islower
checks whether all characters are in lowercase. Therefore not w.islower()
checks whether there is at least one uppercase character.
This is exactly what you've guessed in your post.
Yes but what aboutw = a?b
– Marine1
2 days ago
What isa?b
? Consider posting further questions as seperate posts.
– flawr
2 days ago
a?b
It's a string, it's still the same question
– Marine1
2 days ago
@Marine1:a?b
may be Python syntax for some string, but we're not Python experts enough to know which string that is ...
– Henning Makholm
2 days ago
@Marine1 ifw = a?b
anda?b
is a string, then so isw
, and the answer is also the same.
– flawr
2 days ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Assuming w
is a string (or a byte array or something similar), the docs say following:
str.isupper()
Return true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise.
And
str.islower()
Return true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.
So w.isupper()
checks whether all characters are in uppercase, while w.islower
checks whether all characters are in lowercase. Therefore not w.islower()
checks whether there is at least one uppercase character.
This is exactly what you've guessed in your post.
Yes but what aboutw = a?b
– Marine1
2 days ago
What isa?b
? Consider posting further questions as seperate posts.
– flawr
2 days ago
a?b
It's a string, it's still the same question
– Marine1
2 days ago
@Marine1:a?b
may be Python syntax for some string, but we're not Python experts enough to know which string that is ...
– Henning Makholm
2 days ago
@Marine1 ifw = a?b
anda?b
is a string, then so isw
, and the answer is also the same.
– flawr
2 days ago
add a comment |Â
up vote
1
down vote
Assuming w
is a string (or a byte array or something similar), the docs say following:
str.isupper()
Return true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise.
And
str.islower()
Return true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.
So w.isupper()
checks whether all characters are in uppercase, while w.islower
checks whether all characters are in lowercase. Therefore not w.islower()
checks whether there is at least one uppercase character.
This is exactly what you've guessed in your post.
Yes but what aboutw = a?b
– Marine1
2 days ago
What isa?b
? Consider posting further questions as seperate posts.
– flawr
2 days ago
a?b
It's a string, it's still the same question
– Marine1
2 days ago
@Marine1:a?b
may be Python syntax for some string, but we're not Python experts enough to know which string that is ...
– Henning Makholm
2 days ago
@Marine1 ifw = a?b
anda?b
is a string, then so isw
, and the answer is also the same.
– flawr
2 days ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Assuming w
is a string (or a byte array or something similar), the docs say following:
str.isupper()
Return true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise.
And
str.islower()
Return true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.
So w.isupper()
checks whether all characters are in uppercase, while w.islower
checks whether all characters are in lowercase. Therefore not w.islower()
checks whether there is at least one uppercase character.
This is exactly what you've guessed in your post.
Assuming w
is a string (or a byte array or something similar), the docs say following:
str.isupper()
Return true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise.
And
str.islower()
Return true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.
So w.isupper()
checks whether all characters are in uppercase, while w.islower
checks whether all characters are in lowercase. Therefore not w.islower()
checks whether there is at least one uppercase character.
This is exactly what you've guessed in your post.
answered 2 days ago


flawr
10.9k32043
10.9k32043
Yes but what aboutw = a?b
– Marine1
2 days ago
What isa?b
? Consider posting further questions as seperate posts.
– flawr
2 days ago
a?b
It's a string, it's still the same question
– Marine1
2 days ago
@Marine1:a?b
may be Python syntax for some string, but we're not Python experts enough to know which string that is ...
– Henning Makholm
2 days ago
@Marine1 ifw = a?b
anda?b
is a string, then so isw
, and the answer is also the same.
– flawr
2 days ago
add a comment |Â
Yes but what aboutw = a?b
– Marine1
2 days ago
What isa?b
? Consider posting further questions as seperate posts.
– flawr
2 days ago
a?b
It's a string, it's still the same question
– Marine1
2 days ago
@Marine1:a?b
may be Python syntax for some string, but we're not Python experts enough to know which string that is ...
– Henning Makholm
2 days ago
@Marine1 ifw = a?b
anda?b
is a string, then so isw
, and the answer is also the same.
– flawr
2 days ago
Yes but what about
w = a?b
– Marine1
2 days ago
Yes but what about
w = a?b
– Marine1
2 days ago
What is
a?b
? Consider posting further questions as seperate posts.– flawr
2 days ago
What is
a?b
? Consider posting further questions as seperate posts.– flawr
2 days ago
a?b
It's a string, it's still the same question– Marine1
2 days ago
a?b
It's a string, it's still the same question– Marine1
2 days ago
@Marine1:
a?b
may be Python syntax for some string, but we're not Python experts enough to know which string that is ...– Henning Makholm
2 days ago
@Marine1:
a?b
may be Python syntax for some string, but we're not Python experts enough to know which string that is ...– Henning Makholm
2 days ago
@Marine1 if
w = a?b
and a?b
is a string, then so is w
, and the answer is also the same.– flawr
2 days ago
@Marine1 if
w = a?b
and a?b
is a string, then so is w
, and the answer is also the same.– flawr
2 days ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2871875%2fwhat-is-the-difference-between-the-following-two-tests-w-isupper-and-not-w-i%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password