Just my personal advice, focus on quality - some areas you could expand your code (Pythons not really my area so apologies for any errors)
- General advice that most guides will tell you. Focus on dabbling in as many general programming features & structures as possible (Conditional statements, Arrays/Hashmaps, etc.) - they are the bread, butter and cheese of most programs, and you will struggle to get far (if anywhere) without learning them.-
- You didn't need to create three seperate 'varQuiz' variables. You could've re-used one. Good naming plays an unexpectedly large role in programming, ideally your identifier should
only reference what it's doing, so in this case it should've simply be named "answer" or "userResponse", "varQuiz" doesn't describe the variable at all really. Golden standard here should be that you could give the variable name to a non-programmer without the context and they can identify its usage.
- Rather than checking for an exact response, check for a.) A partial response b.) Ignore case sensitivity, for example for question 2 (Grass blue, etc.) rather than checking for a case sensitive "False", just change the users answer to lowercase and check for lowercase 'f' in the answer. Already there's a slight issue with stating to the user "True or
false" and only accepting "False" with an uppercase F - despite prompting the user for 'false'.
- Really nitpicky: Whilst i personally try to make most/all of my magic numbers/Strings a constant declared at the start of a method/class, in this case you might want to at least create a constant String for 'thats correct!' and 'thats wrong!' and reference them in the user prompt, this is a very very basic case of the 'DRY' principle (
Don't repeat yourself - if you so much as touch copy + paste when programming, ask whether you really need to copy paste or if you can move it to its own independent variable/method and reference that) the reasons behind this are thus
- - If you needed to change "Thats wrong" to "Thats incorrect", at the moment you would need to alter two separate sentences. If this had fifty questions, you might need to alter FIFTY sentences - or, if you kept the response in a single variable and reference that, you only need to change a single sentence. It greatly reduces the risk of forgetting to alter one of many many sentences (which can introduce errors). Whilst it may seem like it'd take longer to move it to its own constant/reference that constant - it'll save you a lot of time in future and keep your code neater. A stitch in time saves nine.
- To expand your code out, though you may not be able to share this via repl.it and, generally something you should learn as part of the basics, you could keep a text file of questions/answers in whatever format (Maybe question colon answer) - read it line by line, and break it down into a list of questions/answers, you'd then have the ability to ask the user random questions and would be able to avoid hardcoding questions/answers/magic strings.
- For full 'hardmode' at that level of learning you could have each line in a text file containing the following. [questions]:[full answer]:[keywords] - this allows you to implement my first point, searching peoples response for lowercased key words rather than checking the entire string.
- If you want to hook this into an Ircbot at some stage, the functionality to load questions/have users answer them quite easily slips into the role of a quizbot (assuming you want to custom design it). Hell why stop there, once you get the full hang of things you could even make a
Countdown bot (or any other question/answer based gameshow) for irc.
Edit:Heres a working code example with some of the suggested cleanups, feel free to ask any questions or hit me up on steam.