Skip to main content

Featured

Space Explorers Book 7: Answers and Explanations

Memunic Space Explorers › Book 7: Memoon and the Search for Another Home › Answers and Explanations Answers and Explanations Habitable means life could live there; inhabited means life does live there. A world can be habitable and empty, as an unoccupied flat has a roof and water but nobody in it. The Moon has almost no air, so water would boil or freeze, and its gravity is only about one-sixth of Earth’s, too weak to keep air. Accept also: no greenhouse blanket, so it swings between very hot and very cold. Venus. It matches Earth in size and roughly in mass, but its thick carbon dioxide air traps heat, making it hot and crushing. “Twin” is only true for size and weight. A dip of 1 per cent means (planet width divided by star width) squared is 0.01, so the ratio is 0.1: the planet is about a tenth as wide as the star. Repeats at the same gap show the planet is going round the star in 12 days, and rule out a one-time event such as a passing object. A planet shines only by reflected l...

Byte by Byte Book 8: Chapter 14 – Using AI as a Coding Assistant Responsibly

Byte by Byte › Book 8: Real-World Coding, Data and AI › Chapter 14: Using AI as a Coding Assistant Responsibly

Chapter 14: Using AI as a Coding Assistant Responsibly

🔎 The Case

Pip, now eleven and impatient, asks a chatbot to "make a quiz app" and pastes the 200 lines it returns into the Truth Desk site. It almost works. Then it fails on the first quiz with an apostrophe in a question, and Pip has no idea why, because he never understood the code. Memoon sits down with him. "An AI can be a brilliant helper," she says. "But it can't be the one who understands. That job is yours."

💡 The Concepts

What AI coding assistants do well:

  • Explain an error message or a confusing line of code.
  • Suggest how to approach a problem, or several approaches to compare.
  • Write small, routine pieces (a function to format a date) that you then read and test.
  • Review your code and point out bugs, edge cases or unclear names.
  • Generate test cases you hadn't thought of.

Where they fail:

  • They hallucinate functions or libraries that don't exist.
  • They produce code that runs but is subtly wrong (logic errors), or insecure (for example, putting user input into innerHTML , Chapter 4).
  • They don't know your whole project, data or requirements unless you tell them.
  • They may use outdated versions of libraries.

The responsible workflow:

  1. Think first. Write your own plan or pseudocode before asking.
  2. Ask small and specific. "Write a JavaScript function that returns true if a string contains only digits" beats "make my app".
  3. Give context. Language, version, what you have tried, the exact error message.
  4. Read every line. If you can't explain a line, ask the AI to explain it, or don't use it.
  5. Test it yourself with normal, boundary and wrong inputs (Chapter 15).
  6. Credit it. Note in a comment or report where AI helped. Follow your school's rules.
  1. Protect secrets. Never paste passwords, API keys or other people's personal data into a chatbot.

Learning vs producing. While you are learning, the struggle is the learning. Use AI as a tutor that gives hints, not a machine that gives answers. A good prompt: "Don't give me the code. Give me a hint about why my loop never ends."

Licences. Code you find online or get from AI may be copied from projects with licences. Open-source licences (MIT, GPL, Apache) say how code may be reused. For school projects, small snippets are fine with credit; for products, check.

🛠️ Build It

  1. Explain a bug. This Python has a logic error. Ask an AI assistant to explain (not fix) it, then fix it yourself:
def average(marks):
    total = 0
    for m in marks:
        total += m
        return total / len(marks)
print(average([80, 90, 70]))   # should be 80.0
  1. Review AI code. Ask: "Write a JavaScript function isValidPin(pin) that returns true for exactly 4 digits." Then test it yourself with: "1234" , "123" , "12345" , "12a4" , "" , " 1234" . Did it pass all six? Write down any failure.
  2. Hint-only tutoring. Pick a Test Yourself challenge you found hard in an earlier chapter. Ask an AI for hints only, never the answer, and solve it.
  3. Record your use. Start an AI use log for your capstone: date, tool, what you asked, what you used, what you changed.

✅ Case Closed

Pip deletes the 200 pasted lines and rebuilds the quiz in three small functions, asking the AI to explain each error as it happens. The apostrophe bug turns out to be a string broken by a quote character, and this time Pip finds it himself. His version is shorter, and he can explain every line of it.

Think About It: If an AI writes most of a program, who is responsible when it fails: the AI company, the student, or the teacher who allowed it?

❓ Test Yourself

  1. Give three good uses and three risks of AI coding assistants.
  2. Why should you write a plan before asking an AI for code?
  3. Improve this request: "fix my code".
  4. What should you never paste into a chatbot?
  5. What is an open-source licence?
  6. Challenge: Explain in plain words what was wrong with average() in Build It step 1.

📚 Key Terms

AI coding assistant · pseudocode · context · code review · edge case · hallucinated library

  • insecure code · hint-based tutoring · attribution · AI use log · open-source licence · MIT

licence · GPL · secret / API key

Keep learning with Byte by Byte

Explore Book 8: Real-World Coding, Data and AI. Find the ebook, purchase details and teaching slides on MemuniCity.

Watch this chapter on YouTube

Comments

Popular posts from this blog

CA-7 Job Status and Failure Reason Codes

Here are the various status codes that You may see for jobs in the Queue or Logs in CA-7. R-C0002 R-C0003 R-C0099 R-C0255 R-JCLER A-U0002 A-U0004 A-U0015 A-U0043 A-U4095 A-SOC7 A-U4000 Reason Code/Job Status Code explanation: The indication of the job's current disposition. Values and their meanings are: A-Snnnn-- The job has failed with a system abend. A-Unnnn --The job has failed with a user abend. C-Cnnnn --The job has completed successfully and is going through completion processing. E-ARFATT-- An error occurred during the attempt to attach ARF definitions. This can result if the ARFSET specified is not defined. A diagnostic message may have been written to the CA-7 log, the OS console, or to the trailer queue for the job (in which case it can be displayed using LQ,JOB=x,LIST=ALL). E-ARFERR ---The job encountered an error in the ARF processing. Do a LARFQ command for the job to get more specific information. E-SEGERR --The job has been requeued...

Whistling Winds and Waterfalls: 4 Days of Magic in Shillong

Nestled in the clouds, where the scent of pine trees mingles with the rhythm of waterfalls and the tunes of local guitar-strumming youth—Shillong is more than a place. It’s a vibe. If you’ve got 3 nights and 4 days, you’ve got just enough time to fall in love. Here’s how to make the most of it—food, fun, fog and fantastic views included. Day 1: Shillong, We’re Coming for You! You land in Guwahati, barely out of the airport when the hills start calling. You hop into your cab, Spotify on, windows down, and the three-hour ride to Shillong begins. Just when you think it can’t get better, you stop at Umiam Lake —a lake so calm, it looks like someone ironed the water. By evening, you’re sipping hot chai in Laitumkhrah, maybe nibbling on spicy momos or pork jadoh from a roadside stall. You’re checked into your charming hotel ( Tripura Castle if you fancy old-world royalty, Ri Kynjai if you’re into lakeside poetry). The breeze whispers secrets of waterfalls and pine forests. Sleep well, drea...

Installing and Configuring Hadoop on Ubuntu as a Pseudo Distributed Single Node Cluster

Briefly what is psuedo-distributed single node Hadoop cluster: It is a Hadoop distributed cluster having Single Node. All the five daemons (NN,DN,JT,TT,SNN) are running as individual JVM (java process) instances. We will get all distributed features of Hadoop. This mode is used to develop, test, and staging (before production) Map Reduce programs quickly. It writes all the system, daemon and user logs to different files on the cluster To install Hadoop in this mode, we have to modify the hadoop-env.sh, core-site.xml, hdfs-site.xml, mapred-site.xml. hadoop-env.sh contains all the Environment variables which are required for running Hadoop. All the default values are fine, Only we have to modify the JAVA_HOME=“The location of Java Home Directory” Core-site.xml contains all the cluster specific information like io, temp directory, sorting, file system uri etc. Hdfs-site.xml contains all the parameters which are specific to HDFS like name node directory, data node directory...