Hello, One of my absolute favorite places to go to practice Python questions from is https://projecteuler.net . It's just Maths based questions that cannot be solved by hand without consuming a Ton of time because of the high limits. This is how I learnt Python. By solving problems from the site in Python! Happy to provide more tips wrt this if required.
Regards Abhi R <http://abhiramr.com> On Tue, Aug 10, 2021 at 2:56 AM Hope Rouselle <hrouselle@jevedi.xotimo> wrote: > I'm looking for questions to put on a test for students who never had > any experience with programming, but have learned to use Python's > procedures, default arguments, if-else, strings, tuples, lists and > dictionaries. (There's no OOP at all in this course. Students don't > even write ls.append(...). They write list.append(ls, ...)). > > I'd like to put questions that they would have to write procedures that > would would be real-world type of stuff, without error checking, > exceptions and such. So if you think of something more or less cool > that uses loops, we can sometimes simplify it by assuming the input has > a certain fixed size. > > I came up with the following question. Using strings of length 5 > (always), write a procedure histogram(s) that consumes a string and > produces a dictionary whose keys are each substrings (of the string) of > length 1 and their corresponding values are the number of times each > such substrings appear. For example, histogram("aaaaa") = {"a": 5}. > Students can "loop through" the string by writing out s[0], s[1], s[2], > s[3], s[4]. > > I'd like even better questions. I'd like questions that would tell them > to write procedures that would also have inverses, so that one could > check the other of the other. (A second question would ask for the > inverse, but hopefully real world stuff. One such question could be > parsing a line separate by fields such as "root:0:0:mypass:Super User" > and another that gives them ["root", 0, 0, ...] and asks them to write > "root:0:0:mypass:..." You get the idea.) > > Students know how to use str(). But they don't know how to use type(), > so they can't really check for the type of the input. I probably > couldn't ask them to write a prototype of a tiny subset of pickle, say. > > I think you get the idea. I hope you can provide me with creativity. I > have been looking at books, but every one I look at they introduce loops > very quickly and off they go. Thank you! > -- > https://mail.python.org/mailman/listinfo/python-list > -- -Abhiram R -- https://mail.python.org/mailman/listinfo/python-list