Revising Code on Grok – Week 1

I have had quite a bit of experience with coding in the past, and so this subject is not very new to me. For the past few lessons I’ve been working on Grok rather than Scratch, with python rather than blockly.

At first, the tasks were easy, as I’d done them plenty of times before. (So I got a little bit bored.)

As I moved along they started to get slightly more challenging. Although, it was more like revising then learning.

That’s when I came across a new area. One that made everything so much easier and more exciting.

The f-string.

The f-string allows me to easily have strings (numbers and other mathematical concepts) in the same line as a sentence. Normally, I would have to write something like this:

print(‘The new number is ‘ + str(new_number) + ‘.’)

Now, with the f-string, I only have to code this:

print(‘The new number is {new_number}.’)

 

The f-string has made everything so much easier!

This helped my learning greatly because it allowed me to complete the tasks a lot quicker and move on to more challenging units.

Sometimes when I write with more than one pair of brackets, I forget to add the second bracket at the end of the sentence. This messes up the whole code. Luckily, though, I am reminded when I press ‘enter’ and I don’t go the start of a new line, and rather, to the middle of a new line.

I also revised on the number section, with adding, subtracting, multiplication, and division.

(I am using the f-string here, with the “f’You have…..”)

 

“len” is another maths/text code word. It counts how many characters are in the text.

This code above was a code for a “Twitter” challenge, counting how many characters the person had left.

 

I also revised on changing the text to all capitals, lower case, or title case.

(Here I am not using the f-string)

 

For me, this is simple. Next time, though, as I move through the unit, the tasks will get harder and I will learn new code.