[Tutor] Python Mastermind Help
Hello, I’ve been given an assignment in which I need to recreate the game Mastermind. I’ve been attempting it for approx a week with little to no progress. I was hoping someone would be able to point me in the right direction. here is what I’ve got: import random def masterMind(): userGuess = raw_input("Guess my 5 digit password:”) while True: if len(userGuess) != 5: userGuess = input("Guess my 5 digit password:”) Much appreciated. AD ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Question
Hey! So luckily with the texts that were sent to me, I was able to figure out the answer(yay)! Unfortunately I am now stuck on a different question. "Write a function called highlight() that prompts the user for a string. Your code should ensure that the string is all lower case. Next, prompt the user for a smaller 'substring' of one or more characters. Then replace every occurrence of the substring in the first string with an upper case. Finally, report to the user how many changes were made (i.e., how many occurrences of the substring there were).” On Jan 11, 2014, at 1:04 AM, Alex Kleider wrote: > On 2014-01-10 17:57, Amy Davidson wrote: >> Hey Danny, >> I just started taking the course (introduction to Computer Science) on >> last Tuesday, so I am not to familiar. I have been doing my best to >> understand the material by reading the text book, Learn Python the >> hard way. > > A lot of people seem to think "the Hard Way" is the way to go. I disagree. > I found that Allen Downey's book is excellent and free (although the book is > also available in 'real' print which works better for me.) > > http://www.greenteapress.com/thinkpython/ > > My copy covers Python 2.7, you use Python 3 I believe, but I doubt that that > will be too much of a problem. At the intro level the differences are few. > > ak > >> In my quest to answer the question given to me, I have searched the >> internet high and low of other functions thus, I am familiar with the >> basic knowledge of them (i.e. starting with def) as well as examples. >> We can attempt the approach to the method that you prefer. >> Thans for helping me, by the way. >> On Jan 10, 2014, at 5:25 PM, Danny Yoo wrote: >>> On Fri, Jan 10, 2014 at 2:00 PM, Keith Winston wrote: >>>> Amy, judging from Danny's replies, you may be emailing him and not the >>>> list. If you want others to help, or to report on your progress, >>>> you'll need to make sure the tutor email is in your reply to: >>> Hi Amy, >>> Very much so. Please try to use "Reply to All" if you can. >>> If you're wondering why I'm asking for you to try to recall any other >>> example function definitions, I'm doing so specifically because it is >>> a general problem-solving technique. Try to see if the problem that's >>> stumping you is similar to things you've seen before. Several of the >>> heuristics from Polya's "How to Solve It" refer to this: >>> http://en.wikipedia.org/wiki/How_to_Solve_It >>> If you haven't ever seen any function definition ever before, then we >>> do have to start from square one. But this would be a very strange >>> scenario, to be asked to write a function definition without having >>> seen any previous definitions before. >>> If you have seen a function before, then one approach we might take is >>> try to make analogies to those previous examples. That's an approach >>> I'd prefer. >> ___ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Question
Hey Danny, I just started taking the course (introduction to Computer Science) on last Tuesday, so I am not to familiar. I have been doing my best to understand the material by reading the text book, Learn Python the hard way. In my quest to answer the question given to me, I have searched the internet high and low of other functions thus, I am familiar with the basic knowledge of them (i.e. starting with def) as well as examples. We can attempt the approach to the method that you prefer. Thans for helping me, by the way. On Jan 10, 2014, at 5:25 PM, Danny Yoo wrote: > On Fri, Jan 10, 2014 at 2:00 PM, Keith Winston wrote: >> Amy, judging from Danny's replies, you may be emailing him and not the >> list. If you want others to help, or to report on your progress, >> you'll need to make sure the tutor email is in your reply to: > > Hi Amy, > > Very much so. Please try to use "Reply to All" if you can. > > If you're wondering why I'm asking for you to try to recall any other > example function definitions, I'm doing so specifically because it is > a general problem-solving technique. Try to see if the problem that's > stumping you is similar to things you've seen before. Several of the > heuristics from Polya's "How to Solve It" refer to this: > >http://en.wikipedia.org/wiki/How_to_Solve_It > > If you haven't ever seen any function definition ever before, then we > do have to start from square one. But this would be a very strange > scenario, to be asked to write a function definition without having > seen any previous definitions before. > > If you have seen a function before, then one approach we might take is > try to make analogies to those previous examples. That's an approach > I'd prefer. > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Python Question
Hi, I am a university student who is struggling with writing functions in Python. I’ve been attempting to write a function in Python for over 2 hours with no progress. The function must be called, printID and take a name and student number as parameter and prints them to the screen. This is my closest guess: def print_ID(“Amy Davidson”, 1) Student = “Amy Davidson” StudentN = 1 print (“StudentName:”, Student) print (“StudentNumber:”, StudentN) If you could help correct my work and explain, that would be great! Thanks, Amy Davidson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor