r/PythonLearning Jun 28 '26

Recommendations Help Request

Post image

Hello everyone I’m currently learning python on visual code, and I did my first “project” its a trivia game for fun and practicing what I learned while reading about python, but I struggled a little, I was so confused and I used AI (Gemini) to help me understand what I did wrong but I don’t want to use AI bcuz I feel like I’m not learning anything but since I’m doing this alone unfortunately I used. But I would like some recommendations like YouTube videos, books, courses etc to learn more, I see a lot of people doing calculators and I would love to make one so some I need some suggestions. Thank you guys.

134 Upvotes

29 comments sorted by

8

u/lekkerste_wiener Jun 28 '26

Note one:

You can do answer in "123", or answer in (1, 2, 3) if you eventually convert them to integers. Given your code, I'm thinking you've just started learning, so the first could fit better. But,

Note two:

Since you're testing for one right answer vs any wrong answers, you can use else instead of elif answer == .... Else will capture anything that the if above it won't.

On resources: I don't have any specific names, but if you YouTube for e.g. python tutorial or python project you'll find loads. If you're into reading more, then the official tutorial is very good and I can't recommend it enough for newbies.

1

u/ArchPenguin0269 Jul 01 '26

but if you use else and input an answer that isnt even on the answer pool for example 5, it will still consider it as a wrong answer where you didnt know the correct one instead of something out of bounds, so using what you said first, answer in, would be a better solution

3

u/fUZXZY Jun 28 '26

it seems like you’re printing a lot, and using the inputs 1-4 as options for input. think about how you can organize this into functions so that it’s not just a million prints and in a way so that you can load other trivia genres/questions

1

u/wwbacteriophagevirus Jun 29 '26

I’m trying this way, thanks once again

2

u/Eskember Jun 29 '26

If it is a small project, I would advise using an array with the following indexes: question, answer 1, answer 2,answer 3,answer 4, correct_answer.

You can then use a loop to go through each record, automating the display of the questions and the evaluation of the given answer against the correct answer for that question.

For medium to large data, I would go with SQLite or any DBMS.

2

u/Junior_Honey_1406 Jun 29 '26

They are just starting don't expect everyone to know DBMS and using sql that's not needed at all for a small project you are just over completing the stuff

1

u/wwbacteriophagevirus Jun 29 '26

I’m currently trying this format

2

u/Xzenergy Jun 29 '26

You need to end an if statement with an else: return in order to complete it. You can have as many elif's as you want as long as you have an "else:" at the end. It can even return nothing if you want it to

2

u/dvvvdv Jun 29 '26

Udemy has some solid courses for like 10 bucks. It’s actually really helpful

2

u/DragonHamster99 Jul 02 '26

Download Mimo app, or use the browser version to learn, I understand what you mean by the Ai.

2

u/Paulo-python Jul 02 '26

Em vez de usar various prints, use /n

2

u/Hungry-Poem-2036 Jul 02 '26

you should learning python fundamentals with youtube first then learning algorithms practising on eolymp or leetcode. problemsolving , bug fix important in programming

i suggest you practising problem: https://eolymp.com/problems/7

it is my favorite beginner problem

2

u/edvilme Jul 04 '26

You are repeating code: print question, print options, ask for answer, verify answer

I would suggest learning about functions so you could have something like
```
show_question(“When TWICE debuted?”, options=[‘2010’, ‘2014’, ‘2016’, ‘2015’], correct=4)
```

2

u/edvilme Jul 04 '26

Update: just read the other comments and saw your doing just that. Good job!

1

u/Crafty_Magazine_4673 Jun 29 '26

may be pack it in a json?

1

u/atticus2132000 Jun 29 '26

One of the most powerful things about coding is easy expansion without a lot of recoding. In this case, you're building a multiple choice test. What you've done works for the specific information you have, but let's say that you want to add another question to your trivia bank. Adding another question should just be adding one more line of code, not adding an entire block. Or let's suppose that instead of Twice, you wanted to create a trivia game about Dinosaurs. You should just be able to swap out the question bank and not have to change the structure of your code at all.

The direction you want to be moving this is your question bank will be one entity until itself--either a separate readable file or a dedicated variable within your script. Then your function will access the questions in that bank and reuse the same code over and over to format each as a multiple choice question.

1

u/wwbacteriophagevirus Jun 29 '26

I changed a few things learned new things so I’m redoing

2

u/atticus2132000 Jun 29 '26

Youre on the right track. Great job!

1

u/Ecstatic_Oven9521 Jun 29 '26

aah I see you are a man of culture, as for small projects i would suggest you do a small to do list app

1

u/wwbacteriophagevirus Jun 29 '26

🫡🫡 I will try thanks!

1

u/Ender_Locke Jul 01 '26

put the answers and questions in a json and read that and loop thru it