FreeCampus Python
  • Home
  • Learn
  • FAQ
  • Projects
  • Debugging

FAQ and Common Issues

  • FAQ and Common Issues
  • Unexpected Keyword Arguments in Classes
  • Running Code and Understanding Output
  • Names, Values, and Types

FAQ and Common Issues

faq
debugging
beginner
Find a familiar symptom, inspect one clue, and test a small fix without guessing.

Open this lesson in Google Colab

How to use this FAQ

Use this chapter when Python does something surprising and you are not sure which article can help. Begin with the words that describe what you see, such as “unexpected keyword argument,” “nothing printed,” “this name is undefined,” or “Python will not add these values.”

Each FAQ page is a standalone article: start with the short answer, then read as much of the explanation as you need. If you want to experiment, use its Open in Colab link and follow this optional routine:

  1. Find the symptom that resembles the problem.
  2. Predict one likely cause before applying a fix.
  3. Run the smallest example and inspect the evidence.
  4. Change one thing, then run the example again.
  5. Explain what the result showed in one sentence.

While experimenting, keep one small troubleshooting note with four parts: symptom, clue, change, and result. You can stop when the article answers your question or continue into the linked course lessons for structured practice.

Find your question

Choose the article whose questions sound most like your current problem.

Unexpected keyword arguments

Understand why a class rejected a keyword, how calls reach __init__, and why instance methods begin with self.

Read the article

Running code and output

Find out why nothing printed, why a notebook can show an old result, and when to restart the runtime.

Read the article

Names, values, and types

Debug undefined variables, surprising assignments, text from input(), and operations that combine incompatible types.

Read the article

TipSearch with the symptom

Search for the words Python showed you and describe what happened, not only what you hoped would happen. For example, search for unexpected keyword argument level, NameError undefined name, or input returns text rather than my code is broken.

Questions answered elsewhere

This FAQ provides short diagnostic paths. Use the main lessons when you need a complete explanation and more practice.

If you need help with… Continue with…
A traceback or named exception Error Messages
Inspecting a program while it runs Debugging Tools
Making a small example to share Minimal Reproducible Examples
Classes, instances, methods, and self Object-Oriented Basics
Variables and Python types Values, Variables, and Types
Text input and printed output Strings, Input, and Output
Colab cells and runtimes Google Colab

Return to the full lesson path when the immediate problem is solved.

Choose the next useful step

Use the evidence in each situation to choose one small diagnostic step.

{
  const scripts = Array.from(
    document.querySelectorAll("script.fcpython-ojs-quiz-config")
  );
  const script = scripts.find(
    (node) => node.dataset.fcpythonRendered !== "true"
  );

  if (!script) {
    return html`<div class="fcpython-quiz fcpython-quiz-warning">
      Quiz configuration was not found.
    </div>`;
  }

  script.dataset.fcpythonRendered = "true";
  const quiz = JSON.parse(script.textContent);
  const container = html`<div class="fcpython-quiz"></div>`;
  const title = document.createElement("h3");
  title.textContent = quiz.title;
  container.appendChild(title);

  const instructions = document.createElement("p");
  instructions.textContent = quiz.instructions;
  container.appendChild(instructions);

  const feedbackNodes = [];

  quiz.questions.forEach((question, questionIndex) => {
    const fieldset = document.createElement("fieldset");
    fieldset.className = "fcpython-quiz-question";

    const legend = document.createElement("legend");
    legend.textContent = `${questionIndex + 1}. ${question.prompt}`;
    fieldset.appendChild(legend);

    question.options.forEach((option, optionIndex) => {
      const label = document.createElement("label");
      label.className = "fcpython-quiz-option";

      const input = document.createElement("input");
      input.type = "radio";
      input.name = `${quiz.id}-${question.id}`;
      input.value = String(optionIndex);

      const text = document.createElement("span");
      text.textContent = option;

      label.appendChild(input);
      label.appendChild(text);
      fieldset.appendChild(label);
    });

    const feedback = document.createElement("p");
    feedback.className = "fcpython-quiz-feedback";
    feedback.setAttribute("aria-live", "polite");
    feedbackNodes.push(feedback);
    fieldset.appendChild(feedback);
    container.appendChild(fieldset);
  });

  const actions = document.createElement("div");
  actions.className = "fcpython-quiz-actions";

  const check = document.createElement("button");
  check.type = "button";
  check.textContent = "Check answers";

  const reset = document.createElement("button");
  reset.type = "button";
  reset.textContent = "Reset";

  const score = document.createElement("p");
  score.className = "fcpython-quiz-score";
  score.setAttribute("aria-live", "polite");

  check.addEventListener("click", () => {
    let correctCount = 0;

    quiz.questions.forEach((question, questionIndex) => {
      const selected = container.querySelector(
        `input[name="${quiz.id}-${question.id}"]:checked`
      );
      const feedback = feedbackNodes[questionIndex];

      if (!selected) {
        feedback.textContent = "Choose an answer before checking.";
        feedback.className = "fcpython-quiz-feedback";
        return;
      }

      const selectedIndex = Number(selected.value);
      if (selectedIndex === question.answer_index) {
        correctCount += 1;
        feedback.textContent = `✅ Correct. ${question.explanation}`;
        feedback.className = "fcpython-quiz-feedback is-correct";
      } else {
        const answer = question.options[question.answer_index];
        feedback.textContent = `❌ Not yet. Correct answer: ${answer}. ${question.explanation}`;
        feedback.className = "fcpython-quiz-feedback is-incorrect";
      }
    });

    score.textContent = `Score: ${correctCount}/${quiz.questions.length}`;
  });

  reset.addEventListener("click", () => {
    container.querySelectorAll("input[type='radio']").forEach((input) => {
      input.checked = false;
    });
    feedbackNodes.forEach((feedback) => {
      feedback.textContent = "";
      feedback.className = "fcpython-quiz-feedback";
    });
    score.textContent = "";
  });

  actions.appendChild(check);
  actions.appendChild(reset);
  container.appendChild(actions);
  container.appendChild(score);
  return container;
}

Keep the FAQ useful

When you encounter a repeated question that is not covered here, record:

  • the exact symptom or error message;
  • the smallest code that shows it;
  • the clue that identified the cause;
  • the smallest change that fixed it; and
  • the lesson that explains the underlying concept.

Questions with the same theme can become a cohesive FAQ article. A single question that already has a full course lesson should become a short link rather than duplicated material.

Back to top
Unexpected Keyword Arguments in Classes

FreeCampus Python — learn by building, explaining, and debugging.

 
  • Edit this page
  • Report an issue
  • GitHub