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

Add solution to exercises, lesson 5 #607

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from

Conversation

@Lisanna
Copy link
Contributor

@Lisanna Lisanna commented Jan 14, 2019

Add solution to "What Is Truth?" and "That’s Not Not What I Meant"

Add solution to "What Is Truth?" and "That’s Not Not What I Meant"
Copy link
Contributor

@annefou annefou left a comment

Thanks for adding solutions to the exercises. It looks good on my side.

Copy link
Contributor

@annefou annefou left a comment

Excellent!
Thanks.

@Lisanna Lisanna changed the title Add solution to exercises, lesson 2 Add solution to exercises, lesson 5 Jan 14, 2019
Copy link
Contributor

@maxim-belkin maxim-belkin left a comment

Thanks, @Lisanna, for contributing to the lesson! Please see my comments above below.

> > ## Solution
> > A non-empty string, non-empty list and 1 are considered true.
> > An empty string, an empty list and 0 are considered false.
> {: .solution}

This comment has been minimized.

@maxim-belkin

maxim-belkin Jan 14, 2019
Contributor

I'm dubious here: proposed solution is not a rule but rather a summary of facts presented in the exercise. I'd suggest to say something like: A string is "true" as long as it contains at least one symbol and A list is "true" as long as it contains at least one element. It does not have to be that exact wording, but something along these lines.

> > ## Solution
> > Again, empty string is not true, and non-empty string is true.
> > Not (not true, i.e. false) is true.
> {: .solution}

This comment has been minimized.

@maxim-belkin

maxim-belkin Jan 14, 2019
Contributor

Um, I'm confused. The exercise says:

After reading and running the code below,
write some if statements that use not to test the rule
that you formulated in the previous challenge.

This comment has been minimized.

@annefou

annefou Jan 15, 2019
Contributor

Should we add a solution such as:

if not not '':
print('empty string is true')
if not not 'word':
print('word is true')
if not not []:
print('empty list is true')
if not not [1, 2, 3]:
print('non-empty list is true')
if not not 0:
print('zero is true')
if not not 1:
print('one is true')

This comment has been minimized.

@maxim-belkin

maxim-belkin Jan 15, 2019
Contributor

The task is to

write some if statements that use not to test the rule
that you formulated in the previous challenge.

So, we have to formulate the rule first.
If the rule is

A string is "true" as long as it contains at least one symbol.
A list is "true" as long as it contains at least one element.
Any non-zero number is "true".

Then we could write:

if not 0:
print('not 0 is true')
if not '0':
print('this will not print because our string is not empty')
if not []:
print('not empty list is true')
if not [[]]:
print('this will not print because our list has one element - another empty list')

This comment has been minimized.

@annefou

annefou Jan 15, 2019
Contributor

Yes I agree. And it would be much clearer!

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

Successfully merging this pull request may close these issues.

None yet

3 participants