<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Charlotte Gale</title>
    <description>The latest articles on Forem by Charlotte Gale (@charlottegale).</description>
    <link>https://forem.com/charlottegale</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2151175%2F54f76335-53ba-4f48-84aa-8c5186733b1a.jpeg</url>
      <title>Forem: Charlotte Gale</title>
      <link>https://forem.com/charlottegale</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/charlottegale"/>
    <language>en</language>
    <item>
      <title>Building a Harry Potter Quiz in Python</title>
      <dc:creator>Charlotte Gale</dc:creator>
      <pubDate>Mon, 15 Sep 2025 09:45:05 +0000</pubDate>
      <link>https://forem.com/charlottegale/building-a-harry-potter-quiz-in-python-1m5n</link>
      <guid>https://forem.com/charlottegale/building-a-harry-potter-quiz-in-python-1m5n</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Every developer has to start somewhere, and for me that meant turning my love for Harry Potter into code.&lt;br&gt;
As part of my CS101 portfolio project, I built a simple command-line interface (CLI) quiz game that tests your knowledge of the wizarding world. &lt;br&gt;
Along the way, I learned how to use Python classes, loops, and input validation to create an interactive experience right in the terminal.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why This Project
&lt;/h2&gt;

&lt;p&gt;I could have gone with Tic-Tac-Toe, or Blackjack, but I wanted something a bit more personal (and magical). A Harry Potter quiz felt like the perfect balance of fun and achievable... and let's be honest, adding house points makes everything better.&lt;/p&gt;
&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fed0hpvwu1vah2mk702l5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fed0hpvwu1vah2mk702l5.png" alt=" " width="714" height="303"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;At its heart, this quiz is built on a simple &lt;code&gt;Question&lt;/code&gt; class in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;question_text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;question_text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;choices&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;answer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each &lt;code&gt;Question&lt;/code&gt; object stores the text, the multiple-choice options, and the correct answer.&lt;/p&gt;

&lt;p&gt;The game then:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Loops through a list of &lt;code&gt;Question&lt;/code&gt; objects&lt;/li&gt;
&lt;li&gt;Prints the question and choices&lt;/li&gt;
&lt;li&gt;Uses &lt;code&gt;input()&lt;/code&gt; to get the user's response&lt;/li&gt;
&lt;li&gt;Checks if the answer is correct&lt;/li&gt;
&lt;li&gt;Awards house points accordingly&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The project was a great way to practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using OOP (Object-Oriented Programming) for cleaner structure&lt;/li&gt;
&lt;li&gt;Validating user input to avoid crashes&lt;/li&gt;
&lt;li&gt;Keeping score across multiple rounds&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Challenges and Fixes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"Double input" bug&lt;/strong&gt;: At one point, my quiz was asking for the answers twice per question. Turned out I had two &lt;code&gt;input&lt;/code&gt; lines in the method instead of one. Lesson learned: Always check for duplicate prompts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Input validation&lt;/strong&gt;: Making sure the program doesn't crash when the user types "lol" instead of "1". A simple loop with &lt;code&gt;isdigit()&lt;/code&gt; fixed that.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Python's class system makes it much easier to manage repetitive data (like quiz questions).&lt;/li&gt;
&lt;li&gt;Clean CLI design matters, even something as simple as &lt;code&gt;print("=" * 40)&lt;/code&gt; makes the output easier to read.&lt;/li&gt;
&lt;li&gt;Debugging is just as much about reading your own logic as it is about the language itself.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Future Improvements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Randomise the order of questions&lt;/li&gt;
&lt;li&gt;Add categories (e.g. "Book Only", "Movies", "Hardcore Lore")&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;You can check out the full code here:&lt;br&gt;
&lt;a href="https://github.com/CharlotteGale/Python_Terminal_Game#" rel="noopener noreferrer"&gt;Potterhead Quiz&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clone it, run it with &lt;code&gt;python quiz.py&lt;/code&gt;, and see how many points you can earn for your house.&lt;br&gt;
&lt;em&gt;Full instructions to be found in the repository's &lt;code&gt;README.md&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This project was my first real taste of using Python to create something interactive and fun. It's not flashy, but it's functional, and gave me hands on practice with OOP, user input, and Git workflows. Most importantly, it showed me how even a small project can be a stepping stone to bigger, more complex ones.&lt;/p&gt;

</description>
      <category>codecademy</category>
      <category>cs101</category>
      <category>python</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
