"Django Basics" was retired on August 28, 2021.

Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift 2.0 Basics Swift Operators Working With Operators

Don't quit understand the second part that's being asked

I understand the first part as it's requesting us to use both constants currently given "value, divisor" and divide both which will provide a 0 remainder. I did that by let result = (value) / (divisor). I'm confused on the second part. How should I proceed? I tried comparing results to the other operations given but I get errors. Not sure how to proceed. Thank you for all the help and explanation.

operators.swift
// Enter your code below
let value = 200
let divisor = 5

let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5

// Task 1 - Enter your code below
let result = (value) / (divisor)
// Task 2 - Enter your code below
result == someOperation
result == anotherOperation

2 Answers

Hi Steven,

I'm assuming you are asking about Step 2 of Task 1, is this correct? If so, then maybe this will help you out:

For step 1, you almost got it right, but not exactly. You are asked to use the "remainder operator" which looks like this: %. Instead, you used the "division operator" which looks like this: /. There's a subtle difference between the two.

If you use the "division operator" in step 1 of this challenge, you will get a result of 40, because 200 divided by 5 is 40. However, if you use the "remainder operator" as asked in this challenge, you will get a completely different answer of 0. The remainder operator doesn't just divide the two values. Instead, it first divides the two values, then returns the remainder. Since 200 divided by 5 is exactly 40, there is no remainder, so the result is 0.

For step 2, you are asked to compare the 'result' you just calculated against the value 0, and assign the resulting value to a new constant called 'isPerfectMultiple'. You're on the right track as you are using the comparison operator ==, but you haven't declared the new variable 'isPerfectMultiple' yet, and you haven't compared the result against the value of 0.

I hope this helps!

Hi Steven,

The question is **In this task, we have two math operations. Without computing the values of those operations, we'd like to know if the first operation, someOperation is greater than, equal to or less than anotherOperation.

Use the greater than or equal to operator and assign the Boolean result of the comparison to a constant named isGreater.**

You have two constants already defined which are the result of some operations that you can see.

The question wants to see if one is greater than the other and assign the result of that to a further constant called isGreater.

So,

let isGreater = someOperation > anotherOperation // read comment below; operator should be <= 

Let me know if that makes sense.

Steve.

Johan Sjöholm
Johan Sjöholm
Courses Plus Student 1,009 Points

Thanks Steve for your feedback to Stevens question! Also I got stuck here and even if your answer made me complete the challenge I decided to re-do it and this time include also the "equal to" operator since the question states it to be included as well (as I interpreter it):

let isGreater = someOperation >= anotherOperation

Also this answer completed the challenge successfully and my question is how come both answers was approved? Is not this: >= the same as "greater than or equal to" i.e like in my example compared with only "greater than" used in your example Steve:

let isGreater = someOperation > anotherOperation

thanks for clarifying! Best regards Johan

Hi Johan,

I think your answer is the more appropriate given the question's wording. I hadn't noticed that; thank you for pointing that out!

The tests behind the challenge must not test for two equal values being compared and assigned. I've no idea why. But, given someOperation and anotherOperation are of fixed value, and I don't think they are equal, the correct boolean value ends up assigned to isGreater whichever operator is used.

Steve.