Squashing Bugs and New Ideas

After writing my daily post yesterday, I ended up working on making a quiz of my own (since it was listed under “Hacks” in the Python quiz page) and failed to make it work correctly. Because I did not understand the “input” Python function, all answers, correct or not, reacted as if they were incorrect.

With slightly more Python knowledge, I went to bed that night knowing I could definitely improve my old random number generator from Monday. So…

The Python Quiz

At first, yesterday, I started making a survey without even knowing it was a potential Hack for the week. The whole joke was going to be that it said there were no right or wrong answers, but only certain responses were “correct.” Just a little goofy thing. I wasn’t able to create the semi-diverse range of responses that would be based on anticipated answers because I was pretty tunnel-visioned into what was provided in that page. Later, I decided to do some independent research.

I then saw the tip to make a quiz about Python functions and reworked the survey. Plagiar-inspired by the Python quiz’s defined “question_and_answer” and “question_and_response” functions, I used the same basic template to make my own quiz that’s just a bit more personal. I decided to express my icnreasing fluency by asking for the user’s name (which is reused throughout the quiz), giving a status check halfway through the quiz, and determining whether or not the user failed based on their score. As was mentioned in the Hacks, I also used math to calculate the score percentage based on the ratio of correct answers to questions.

Work on this quiz is not quite finished. Please stay tuned for its full release.

The Random Number Generator

My random number generator can now be reset and retried as many times as the user wants. I decided, since I gave Python a defined identity the first time around, I would really lean into it by giving his dialogue a strange, quirky style. Like the first time, I also kept the option to generate a second random number for the user to get lucky.

However, this time, Python recognizes if the second generated number is the same as the first. As he says, he’ll share a secret with you if you manage to generate the same number twice…and no peeking in the code!

I even used some more complex math mixed with ‘if’ and ‘and’ functions to make Python give a special response if the two numbers are relatively close to each other, but not quite the same.

Have fun with that! You can access it right now.

What’s Coming Up?

I’m really just gonna focus on completing Hacks tasks from the APCSP fastpages as well as the Python quiz. As the RNG machine may imply, I have spent a minute or two minutes or half an hour or more messing with code for my own amusement, but as a fairly busy weekend approaches, I’ll make sure to buckle down.

More to come! Stay tuned…