You welcome, it gets easier over time. The more you practice and even use in real life the easier the task let it be coding to whatever. The key here is you are enjoying it always remember that.
Hi Grasshopper _Heather can you explain the use of + symbol in this case in detail
+ operator can do two things: combine two numbers together (like the + symbol does in mathematics), and concatenating two strings together.
For example, we could have code like:
var myNumber = 5 var myStatement = myNumber + ' is equal to five' print(myStatement)
myStatement combines a number (the value from
myNumber) with the string
myNumber from a number to a string. So the expression would actually look something like
'5' + ' is equal to five'. And the
+ symbol combines these two strings to create
'5 is equal to five'.
We can also create the same output as above using less code, by getting rid of the
myStatement variable. Like this:
var myNumber = 5 print(myNumber + ' is equal to five')
I hope this helps!
The Final Ascent explainer
Open The Lock explainer
The challenge I have is that sometimes I’m not sure what exactly the exercise is asking for.
Looks like you’ve given yourself extra work: you’ve got too many lines of code.
Try resetting your code by tapping on the button with arrows in a circle (the one that looks a little like the recycle symbol); then edit (rather than adding to) the code to replace the
0's with a number of 1 or higher.
I thought I needed to start the code from scratch, it turns out it was easier than I thought.
I am stucked here. All data entered is as per instruction .Plz someone help me.
Could you share a screenshot of your code? I can take a look and hopefully spot how to help you.
Thank you. I fixed it.
Hi, I understand what it’s looking for and completed the exercise, I just don’t fully understand why if x=5 and you’re updating that to a new value of x=x+5 why it’s not 5=5+5. Why does the second x in the equation retain the last value for x, but the first one doesn’t?
x+5 evaluates to
5+5, which evaluates to
10, which is then assigned to the variable on the left, which is
Does that help? I think maybe the tutorial needs to explain more thoroughly that the various symbols do not have quite the same meaning as in mathematics.
In addition to what @Scott_McNay has explained, it may be useful to walk through each element as if we are talking to the computer. So let’s break it down:
x = : this part is telling the computer that we want to assign a new value to
x. Whenever you see the
= symbol it means that the variable (or identifier) on the left is going to be assigned a new value.
x + 1 : this is on the right side of the assignment symbol, meaning it is the new value that will be given to
x. At this point,
x still has it’s old value. The computer will look ‘up’ to see what
x has been holding to date, and then add 1 to it.
Hopefully this helps!
I put in your solution exactly and I still get errors from your app that I can’t complete this puzzle
Are you still stuck on this puzzle? Make sure you’re using
num for numbers and
str for words. If there are quote marks around a number, then it will be seen as a keyboard character, not an amount.
You can also upload a picture of your code here to get another look.
Hrmm… It is confusing how the language always appears to be mathematical but is actually a combination of directive shorthand and math. Instinctively I look at it and think “x” does not equal “x + 5”… (How is it not a circular reference? Is “x =” of “x = x + 5” happening independently of “x + 5”? Wouldn’t it make more sense to write “x + 5 = x” if the goal is to update the value of x? How does the print function portion know to show the value of x rather than displaying “x”?)
Will be interesting to see how complex math functions are handled later on (if those are in the program). Thanks for your explanation.
EDIT: I see you guys answered my questions above. Sorry, disregard my post
print x will always only ever print the contents of the variable named
print "x" will always only ever print the literal string shown within the quotes: “
The difference is that one has quotes and the other doesn’t.
Each language has it’s own rules. In most modern languages, you can use this:
a = b = 2
to determine if
2 and assign
But, I recall seeing code for what I think was an old mainframe version of BASIC in which the value of
2 would be assigned to the variable
b, then the value of the variable
b (which was now 2) would then be assigned to the variable
As a clarification to future readers:
= is the assignment operator. That means “make one side equal to the other side” (usually, change the left side to match the right side).
===, is the equality operator. That means “check if one side is already equal to the other side”.
a = b = 2 will be interpreted as “set
b to 2, and then set
a to the value of
b which is 2”. Which makes
b have a value of 2. The code
a = b === 2 can be rewritten as
a = (b === 2), and you can break it up into two parts:
b === 2, “Is the variable
bstoring the value 2?”. That is either
a = (either true or false depending on if b was equal to 2)
Here is a chart that lists the order that each operator is executed. If you remember the order of operations and PEMDAS from arithmetic, this is the same thing except with more operators included. You’ll notice that assignment