[Tutor] Create command

Steve Willoughby steve at madscience.zone
Wed Sep 21 20:27:20 EDT 2022


Ok, that’s good. Now try putting that in a loop so it asks over and over, then look at changing if from the question of name and age to the commands the assignment is asking for.

> On 21-Sep-2022, at 17:06, Dominique Hagler <dbhagler at gmail.com> wrote:
> 
> I started over and this is what I have so far. <Screenshot 2022-09-21 200608.png>
> 
> On Wed, Sep 21, 2022 at 7:18 PM Steve Willoughby <steve at madscience.zone> wrote:
> It looks like you’re getting used to using Python in interactive mode, which is a good way to become familiar with the language features or try out an idea quickly.
> 
> However, for this it sounds like you’re going to need to write a Python program of your own which interacts with the user, so I’d start by working on putting together some kind of loop which prompts the user, reads their command, and then figures out what they want to do based on the input they typed, then repeat.
> 
> So look at how while and for loops work, and how to read input from the user using the input function, then look for ideas on how to examine the string entered by the user to see if it’s a “put”, “fetch”, or “exit” command.
> 
> Once you have that much working, I’d add the details of setting up some kind of storage and retrieval. It’s not clear from the problem given whether they want you to permanently store the data so if you restart the program you still have all the data stored previously, or just need to hold it in memory for retrieval during the same run of the program.
> 
> 
> 
>> On 21-Sep-2022, at 16:11, Dominique Hagler <dbhagler at gmail.com <mailto:dbhagler at gmail.com>> wrote:
>> 
>>  Hi Steve,
>> 
>> This is what I have come up with. Sorry still not sure how to save it correctly.
>> 
>> <NR1.py>
>> <NR2.py>
>> 
>> 
>> Thank you, 
>> 
>> Dominique Hagler
>> Have a great day!
>> 
>> Sent from an iPhone, so please excuse brevity and typos!
>> 
>>> On Sep 21, 2022, at 6:57 PM, Steve Willoughby <steve at madscience.zone <mailto:steve at madscience.zone>> wrote:
>>> 
>>> Dominique,
>>> 
>>> It looks like you have an interesting homework exercise there to figure out. I don’t see a specific question from you, though. What have you tried so far? How did that work? What are your thoughts for where to proceed with this?
>>> 
>>> We can help guide you in your course of discovery here, but we need something to start with since we’re not going to do your homework for y ou. 
>>> 
>>>> On 21-Sep-2022, at 03:36, Dominique Hagler <dbhagler at gmail.com <mailto:dbhagler at gmail.com>> wrote:
>>>> 
>>>> Create a command line tool for storing and fetching key-value pairs. In other words, given a key and a value, which are both strings, it can store key and value together, and then return that value when fetched by that key. The tool must be able to be run from the command line by typing "key-value", though it is acceptable to also require the path or an extension (eg, "./key-value.rb" is fine). If needed, it is acceptable to include a setup script that must be run before the tool can be run. Running the tool must open an interactive session that accepts put, fetch, and exit commands. When ready to accept a command, it must output the string "> " as a command prompt.
>>>> 
>>>> My command example: 
>>>> 
>>>> Person1 = { “name” : “ Daisy”, “age”: 20}
>>>> 
>>>> 
>>>> Thank you, 
>>>> 
>>>> Dominique Hagler
>>>> Have a great day!
>>>> 
>>>> Sent from an iPhone, so please excuse brevity and typos!
>>>> _______________________________________________
>>>> Tutor maillist  -  Tutor at python.org <mailto:Tutor at python.org>
>>>> To unsubscribe or change subscription options:
>>>> https://mail.python.org/mailman/listinfo/tutor <https://mail.python.org/mailman/listinfo/tutor>
>>> 
> 
> 
> 
> -- 
> Thank You,
> Dominique Hagler
> 
> 
> 



More information about the Tutor mailing list