r/learnprogramming • u/palpalpalwarp • Mar 29 '21
I made a site that randomly generates python practice programs to teach reading fluency (update)
I've been a programming tutor for about 7 years. From this, I've learned that beginners' writing ability is often heavily limited by their reading ability, so I made a site to randomly generate python programs for the user to read and figure out the output. The quizzes can be customized for your ability level and what topic you want to focus on. I posted it here a while ago and you all seemed to like it, so since then I've made some additions. I've added an account system so that you can sign up to track your scores so that you can tell whether you're getting faster. Before each quiz you'll see your current personal best so that you know what to aim for to beat your record. You'll also see a graph of your progress after each quiz and all of your graphs on your user dashboard.
Here's the link to the control flow exercise: https://trprt.io/python-practice-problems-ifs-loops-control-flow
Let me know if this helps you!
64
u/MrNubishly Mar 29 '21
Just found how much i suck at python. Failed 10 times on the very easy setting
25
u/palpalpalwarp Mar 29 '21 edited Mar 29 '21
Can you share some examples and say what you got confused about? That would help me make the exercises more accessible. If anybody else got stuck, feel free to reply to this comment too!
26
u/SinisterMJ Mar 29 '21
I failed on one repeatedly, then tested it on my system, and the answer on the website was wrong. Happened only once unfortunately, and didn't save it, but the code was something like
e = 5 d = 5 b = 1 for i in range(1,3): b -= 5/d e += 4 * band the website said expected result -1 (while it should have been 1). Aside from that one example (it was on medium with loops and int only) it works quite nicely.
16
u/palpalpalwarp Mar 29 '21
Was the final line print(e) or print(b)? e is 1, but b is -1.
18
u/SinisterMJ Mar 29 '21
It was print(e). I copy&pasted the code, so I am sure I took the right variable. But I did like another 2 dozen examples, and they all worked fine. I make sure to DM you if I encounter anything again.
43
u/palpalpalwarp Mar 29 '21 edited Mar 29 '21
Thanks! Bugs are inevitable, so I appreciate whenever users give any details that can help me track them down.
2
u/XilamBalam Mar 30 '21 edited Mar 30 '21
I was doing one with in short
e=5 y = 4 e += y/2The answer was 7 but the right solution was 6. When i checked the "review programs" section the line was changed to
e += y/42
u/young-and-mild Mar 30 '21
As a beginner, it would be helpful if there was a key or quick reference for the syntax being used in each question (at least on the very easy setting)
2
u/palpalpalwarp Mar 31 '21
I've just added a "help" button which will show a reference for whichever operations are used in each question. Let me know if that helps!
5
u/vicyuste1 Mar 29 '21
I know nothing about python, just 1 month of java programming I managed to almost get them right. Missing some very specific expressions I've never seen. So I'd say it's pretty on point! Great job
9
u/drowsy-cthulhu Mar 30 '21
While this form of exercise might be a good practice, don't use it as a measure of how good at python (or programming) you are. People learn differently, and while this might be a good way for some people to learn, these examples are by no means representative of production code.
Developers are not meant to be human compilers. The ability to write code in a sensible, readable way is much more important then the ability to make sense of arcane gibberish. On a real project, I wouldn't let this sort of code pass code review. And if I had to change something in an existing codebase, and the code happened to look like this, I wouldn't even bother to fully make sense of it. I'd probably only try to understand the bare minimum so that I can write a test around it, and then I'd reimplement the method, replacing its guts with code that does the same thing but makes sense to human readers (in other words, I'd effectively delete the original code).
Again, I'm not bashing palpalpalwarp's website, it's a cool thing, but don't think your performance there reflects your overall skill level as a developer.
66
Mar 29 '21
Randomly generates the problems on the fly or randomly picks a problem from a list of pre-developed programs? Because if these programs are actually being novelly generated every time....that is really sick. Really cool and helpful either way.
83
u/palpalpalwarp Mar 29 '21
Thanks! They're randomly generated on the fly, so they'll be different every time. There's no pre-developed list.
34
Mar 29 '21
How did tou write the random generation? Would love to attempt something like this for JavaScript but can’t even think of where to begin
70
u/palpalpalwarp Mar 29 '21 edited Mar 29 '21
It's a pretty big project, so I'd recommend starting small: first write a function to generate random mathematical expressions, like x+3, 5*x, x-5*y, etc. From there you can write another function which uses the other one to make multi-line programs that assign to variables then modify them. Next you'd need to add if statements, then nested if statements, etc. Programs have a tree structure, where each branch is its own program (although a branch may depend on variables defined elsewhere in the tree). You'll need to get very comfortable with recursion.
One trick is that you don't need to always generate programs to fit the criteria you want -- you can just generate one, run it, and if the output doesn't fit what you want, generate a new one.
I'm actually planning to add javascript versions of the exercises to the site once I fill out the python functionality more.
9
u/Academy- Mar 29 '21
Super interesting. How do you generate random if statements?
10
u/palpalpalwarp Mar 29 '21
Everything is broken down into simpler sub-statements which are composed together.
So there's the function mentioned earlier to generate mathematical expressions like "x+3", then it's relatively simple to use that function to write another one which will generate expressions like "y>x+3", then another function to generate expressions like "if y>x+3:", etc.
6
u/Academy- Mar 29 '21
Ok. So then do you wrap it as a string and evaluate literal? This is blowing my mind lol
7
u/palpalpalwarp Mar 29 '21
I'm not sure if this answers your question, but it uses skulpt to run the python code in-browser.
7
u/Academy- Mar 29 '21
Thanks. How you did this will have me wondering for a while. Please make a YouTube video about this lol
4
u/Toshiro454 Mar 29 '21
Do you use any machine learning in the process?
6
u/palpalpalwarp Mar 29 '21
Nope, it doesn't use any machine learning, but that would definitely be interesting to experiment with.
3
3
7
u/Sellebjergen Mar 29 '21
Damn, this seems really cool! would you mind sharing how you're generating the code? I'm kinda curious :D
15
u/palpalpalwarp Mar 29 '21
I wrote functions to generate each sub-component (e.g. individual mathematical expressions like x+5), then used those functions to write other functions to generate larger sub-components (like y=x+5), and so on. Programs have a tree structure, so composing things in this way is a natural fit for the problem. I also used a lot of recursion.
7
u/Pepper2012 Mar 29 '21
Would it be possible to build one that works with objects and classes to better grasp the child/parent relationships and hierarchies as well as public/private methods and attributes? I'm working through learning those now and this would be helpful. I'm enjoying the problems and the difficulty setting!
9
u/palpalpalwarp Mar 29 '21
Yes, that's definitely on the to-do list! Right now the only exercise types are control flow, boolean expressions, and functions, so classes/oop would make a great 4th exercise.
2
3
u/SunstormGT Mar 29 '21
Tried it on mobile (iphone11) and I can enter the awnser for the first question but after I click continue the keyboard doesnt popup anymore when I click the textbox.
3
u/palpalpalwarp Mar 29 '21
Thanks for reporting this, I'll look into it.
3
u/SunstormGT Mar 29 '21
I now found out this only happens after you click ‘show awnser’. I you use the keyboard enter I works as intended.
2
u/palpalpalwarp Mar 29 '21
Thanks for clarifying!
Is it possible you're clicking the message box above the input box instead of the input box, and that's why the keyboard's not coming up?
1
u/datsyuks_deke Mar 30 '21
I ended up having to click back outside of the box where you put your answer. Then click back on inside the box to get the keyboard to come back up.
3
u/Metallifax Mar 29 '21
Very cool site, bookmarked! Any way I can follow the project?
4
u/palpalpalwarp Mar 29 '21
There's a newsletter signup link here: https://www.trprt.io/subscribe
You can also sign up to make an account which will let you track your scores on the exercises and optionally give you email reminders so you don't forget to practice. The signup link is here: https://www.trprt.io/signup/
1
3
u/zimady Mar 30 '21
Secondary computer science teacher here. This could be exceptionally useful to support a programming course. I will be sharing it in a range of computer science teacher groups I am a member of. Would you like me to direct any feedback to you and, if so, where should I send them to do that? (not all use Reddit). Alternatively, I could gather any feedback and pass it on to you?
In terms of my feedback, even the "Very Easy" setting would be too complex to use this with some groups. The procedures are of course not very complex, but the use of some operators would make it so, specifically: % (modulus), ** (exponentiation), // (floor division), and += or -= (and similar). I would want to introduce this with first time programmers as a practice technique after teaching basic operators and sequence. At this age (anything around 10-13) I would lean on their maths knowledge to introduce basic mathematical operators, sequencing using BODMAS, and variable assignment - so pretty much exactly what you have in the "Very Easy" Int configuration, just without the slightly more complex operators I have mentioned. I don't typically introduce those operators until later.
My other thought is that this could be a very useful tool to test and practice highly targeted skills. For example, having introduced a few assignment operators beyond = (such as +=, - =, *=, /=) I would like to be able to set practice that uses specifically these operators, or even a subset.
So, a specific request that would address both these observations: it would be great to have further configuration options (perhaps hidden behind an "advanced config" reveal) that would enable one to select which mathematical and assignment operators to include in the quiz questions so they could be targeted specifically at what has been taught so far. I haven't looked beyond "Very Easy" to see what configuration options could be included there, but I anticipate that the more difficult the quiz level, the less config granularity would be required as programmers become more versatile and confident in figuring out stuff they haven't been taught explicitly.
With this capability, there is something else that would be very useful for teachers: if the configuration options were mirrored in the URL, this could be shared with students (by the teacher) such that when they open the URL in their browser, a quiz will be generated reflecting that preset configuration (thereby targeting specific skills). Since the questions are generated randomly, each student would get a unique quiz, which is a very attractive feature to encourage independent problem solving.
This suggestion provides a rudimentary means for a teacher to use the tool with many students in a structured manner. If you were interested in further developing features for teachers, you would need to consider some means for the teacher to be able to collect quiz results on a per student basis so they can assess progress and areas of weakness to target with future teaching and practice.
Which leads me to my final suggestion, which would also be useful to any programmer using the tool. It should be relatively easy to assign some measure of complexity to each quiz question. For example, as you point out, the "programs" can be decomposed into a tree structure - the more branches, the more complex. Also, "complexity points" could be awarded differentially based on the complexity of the operators/loops/data types/type conversion etc used. With a measure of complexity, it would be possible to provide this to the user as a measure of their progress. I'm imagining that someone could, for example, have a high score on loops but a lower score on if statements with multiple comparisons, thus helping them to target future study/practice effort. Such a feature would be very useful to teachers to help identify progress and weak spots for individual students.
Sorry for the super long response - it's testimony to the great potential I see in your excellent tool.
1
u/palpalpalwarp Mar 30 '21
Thanks for your detailed response! There are all great suggestions and line up with what I've been thinking as well.
There's a contact form located here: https://www.trprt.io/contact
You can also email me directly at [email protected] (this is preferred).
Please send me an email so we can discuss this in more detail.
2
u/jinchuika Mar 29 '21
This is freaking awesome. I'm planning to use something like this with my students at algorithms 101. Let me know where can I create feature requests and what would be the best way to help implementing them. This had a lot of potential
1
u/palpalpalwarp Mar 29 '21
Thanks! There's a contact form here: https://www.trprt.io/contact
You can also reply to me right here on reddit.
39
13
u/M_krabs Mar 29 '21
Me: "I'm good for a beginner"
*tries an easy problem
Me: "Damn... back to kindergarden I go!"
14
u/AnalBreathingBrother Mar 29 '21
I'm not exaggerating when I say that this could be a million-dollar project.
1
Mar 29 '21
I found a minor bug. If you put the time duration setting on unlimited, the clock to show elapsed time goes up faster than one tick per second. This is not affected by difficulty or types.
Great project I had fun trying it out!
2
u/palpalpalwarp Mar 29 '21
Thanks for reporting this bug. I can't seem to replicate it on my end. What type of device and web browser are you using? And how much faster does the time go up? E.g. about twice as fast as normal, or only a little faster? Also, is it very regular, or does it go up at an uneven speed?
1
Mar 30 '21
I am using a Firefox web browser on my Linux desktop. I disabled all plugins. It goes up probably 3-5 times as fast at an uneven speed.
2
u/palpalpalwarp Mar 30 '21
Thanks for following up. I just tested it on firefox on linux and still can't replicate it, but I made some changes to the code that may fix the issue (unfortunately I can't test it myself to see whether the change helped, since it doesn't occur for me). Can you try it again and let me know if it's fixed?
1
1
u/datsyuks_deke Mar 30 '21
Man this is awesome. Thank you for creating this. Currently I’m playing it on my phone and I noticed that there is not an enter button to press after putting in my answer. I only see this show answer and end quiz.
1
u/palpalpalwarp Mar 30 '21
You can press the "enter" button on your phone's keyboard. It's the same key as what you would use to type a new line.
1
u/datsyuks_deke Mar 30 '21
I feel dumb. I thought I did press that and it didn’t work. Let me check again.
Edit: yep absolutely works. Well I’m dumb.
Thanks man. This program is awesome and helpful.
1
u/menothinkofusername Mar 30 '21
The generation thinks up some really weird stuff (e.g. whole blocks of code that you need to recognize never run). I love it.
2
u/palpalpalwarp Mar 30 '21
Thanks! Yep, that's intentional -- an important part of becoming an expert at anything is learning which parts of a situation to focus on and which you can safely ignore.
1
u/menothinkofusername Mar 30 '21
Exactly. By the way, can we see the source code? I know you described how it was implemented in other comments, but I’d love to read some code for it :).
2
u/palpalpalwarp Mar 30 '21
If you right click and do "view page source" the js links are in the head of the page. "programgenerator" is the one with most of the code for generating the programs. I can't link it directly because the exact url changes whenever I push an update.
1
u/DangerousWish2266 Mar 30 '21
I liked the website, it is very helpful as well, but I have a question does your website creates questions on the fly (automatically) or you have a database of questions from which questions are asked?
1
u/palpalpalwarp Mar 30 '21
They're randomly generated on the fly, so they'll be different every time. There's no pre-developed list.
1
u/Reythx Mar 30 '21
hey, some feedback I'd like to add is that it's a little bit annoying that you cannot see the result of the last question if the time limit ends, cause i cannot figure out what I didn't do wrong
1
u/palpalpalwarp Mar 30 '21
All of the programs are listed after the quiz. If you scroll down, the last one should be at the bottom, even if you didn't finish it.
3
1
u/thelguapo Mar 29 '21
It's great but there's no enter command on mobile so users can't submit if they're on mobile.
1
u/palpalpalwarp Mar 29 '21
"Enter" on mobile is the same thing as "new line" or "return." It should be at the bottom right of the keyboard.
2
u/Padi48 Mar 29 '21
I started learning Python by myself not so long ago, and found this really helpful! Thank you!
2
2
2
2
2
u/chappedpeach Mar 29 '21
This is perfect timing! I'm starting to hit a wall and really struggle in my Python class right now so I'll be using this, thanks!
2
Mar 30 '21
This is amazing. Thank you so much!
I wish there was a way to select number of questions rather than the time limit though.
1
1
1
u/LeftHandedFapper Mar 29 '21
As a beginner student I appreciate this so much!
Any other tips for the journey?
1
1
1
1
1
1
1
1
1
u/buggorilla Mar 29 '21
Thanks a lot! Will definitely work through it 👍👍 Are you also interested in developing the same for JavaScript? Against thanks a lot for your effort 😊👍
1
u/phutureambassador Mar 29 '21
This is great thank you!! I need to familiarize myself with Python more and this is a great way to do it.
1
1
1
1
1
1
u/Doopapotamus Mar 29 '21
I hope you add this to your portfolio somewhere and this gets you some form of nice job! This is excellent for a beginner like me!
1
1
u/ab7C9 Mar 29 '21
This is great, bookmarked and passed on.
I do have a suggestion but as it has been mentioned that some of the questions are programmatically generated, it may be difficult to implement.
If someone gets an answer wrong and they click show answer, maybe a break down of the block of code to either increase the understanding through explanation or to solidify existing knowledge.
I also realise whilst writing, that it's purpose is reading fluency so please feel free to discard the above or save it for where applicable.
1
1
1
1
u/AssignmentNo809 Mar 30 '21
I didn't check what sub this was in, and because I am a teacher, I thought this was reading fluency practice for elementary students. I'm an idiot.
1
1
u/tk9WWRD2VFQIM74E Mar 30 '21
Nice work! This will be very helpful to many learners.
As an aside, these problems make it blatantly obvious that functional programming provides for quicker and easier discernment.
1
1
u/Shmlack Mar 30 '21
I love it!!! This is exactly what I needed. You did an awesome work! Thanks! 🙏🤘🙌
1
u/SnailForce Mar 30 '21
Whoa man, that’s awesome, i plan on taking advantage pf this in the future to help me get the hang of python
1
1
1
1
1
1
u/philovdy Mar 30 '21
This is seriously awesome !!! I hope you get to monetize some part of this at least. So much work involved !!!
1
1
u/awesoumi Mar 30 '21
Thank you for creating this. I recently started learning Python and this is super helpful.
1
1
u/Combobreaker6889 Apr 02 '21
This is so cool! I appreciate you for making this and sharing it with us!
1
1
0
5
72
u/phakyt Mar 29 '21
I love it already