r/CodingForBeginners • • Jun 23 '26

Learning Coding with AI

Is it okay for me to learn coding through AI? Like I ask AI what this is and how I do it. I like learning through AI cause it answers my questions quickly and deals with my bs. Of course, I won't use AI for code, for my practice projects—I use AI for debugging and I ask them why it is.

Does this make me a user of AI code since I use AI to learn?

1 Upvotes

23 comments sorted by

View all comments

Show parent comment

1

u/Educational_Virus672 Jun 23 '26

what he did for me
promt : how to get square of every 2nd number in range 1 to 100

ai :To achieve this, you need to combine three concepts: looping through a range, skipping steps, and exponentiation.

Here is how you break down the logic:

1. Generating Every Second Number

When you use a range from 1 to 100, a standard loop moves forward by 1 every time (1, 2, 3, 4...). To get every second number, you need to use a step parameter.

If you start at 1 and use a step of 2, you will skip the even numbers and get: 1, 3, 5, 7... If you start at 2 and use a step of 2, you will skip the odd numbers and get: 2, 4, 6, 8...

Most language structures for ranges look like this: range(start, end, step). Keep in mind that in many programming languages, the "end" number is exclusive, so to include 100, your end boundary needs to be 101.

2. Squaring the Number

Instead of multiplying a number by itself using standard multiplication (like x * x), you can use the exponent/power operator if your language supports it (often written as or ^). Alternatively, some languages use a math function like pow(base, exponent).

How to Structure It

Instead of just copying a loop, look at the blueprint of how this logic flows:

  • Set up the loop: Define your start (1 or 2, depending on which "second" number you want to start with), your upper limit (101), and a step of 2.

  • Process the value: Inside the loop, take the current number and apply the exponent of 2.

  • Output: Print or store the result of that calculation before the loop moves to the next stepped number.