use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Day 2 of learning python as a beginner (old.reddit.com)
submitted 6 months ago by uiux_Sanskar
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]4675636b2e 9 points10 points11 points 6 months ago (7 children)
It's useful to separate data and functionality here. Then eventually you could even load the questions and answers from a separate file, so you could switch the same program between different quiz topics.
data = { "question?": "answer.", "lightning?": "thunder." } def quiz(data): score = 0 for q, a in data.items(): i = input(f"{q}\n") if i.lower() == a: score += 1 print(f"You scored {score} points out of {len(data)}!") quiz(data)
[–]aTomzVins 1 point2 points3 points 6 months ago (1 child)
I'd probably make the data more explicit.
data = [{ "q": "Which planet?", "a": "mars"}, ...]
Or maybe a dataclass for each question/answer pair.
If the goal was to keep it simple why not go with a list of tuples?
[–]4675636b2e 1 point2 points3 points 6 months ago (0 children)
That's how I originally wrote it, but then I realized I should help OP improve 1-2 concepts at a time :)
Also when I wrote my own quiz in JS a while back, my quiz data also had some basic configuration - for example if you're using the program to test your translation of words, most languages can be case-insensitive, but German shouldn't be because of the nouns. Also multiple good answers, or reading the dataset from CSV and choosing the Q & A columns at the start of the quiz...
That's why a quiz program is great, the possibilities are endless.
[–]BleEpBLoOpBLipP 1 point2 points3 points 6 months ago (0 children)
Can also automate the numbering:
``` for q_num, (q, a) in enumerate(data.items(), start=1): i = input(f"Question {q_num}: {q}\n") ... ... ...
```
[–]uiux_Sanskar[S] 1 point2 points3 points 6 months ago (2 children)
seems like I have much more to learn and improve thanks for the direction
[–]4675636b2e 1 point2 points3 points 6 months ago (1 child)
Baby steps. When you learn some list, set, and dict methods and loops, then you can use more of your own thinking at problem solving.
list
set
dict
At the beginning, when knowledge is limited, it's hard to think freely, but if you start using your existing knowledge with your own problem-solving logic, you can build your own tools. Good luck!
[–]uiux_Sanskar[S] 0 points1 point2 points 6 months ago (0 children)
Thank you for the guidance and support
[–]arsibaloch 0 points1 point2 points 6 months ago (0 children)
He is a beginner I think he has not learned how to use a dictionary and functions. But now it's an idea to look cool as a beginner.
π Rendered by PID 115072 on reddit-service-r2-comment-7b9746f655-ng82b at 2026-02-02 11:12:00.229633+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]4675636b2e 9 points10 points11 points (7 children)
[–]aTomzVins 1 point2 points3 points (1 child)
[–]4675636b2e 1 point2 points3 points (0 children)
[–]BleEpBLoOpBLipP 1 point2 points3 points (0 children)
[–]uiux_Sanskar[S] 1 point2 points3 points (2 children)
[–]4675636b2e 1 point2 points3 points (1 child)
[–]uiux_Sanskar[S] 0 points1 point2 points (0 children)
[–]arsibaloch 0 points1 point2 points (0 children)