*** scooper has quit (Quit: Leaving) | 03:24 | |
*** scooper has quit (Remote host closed the connection) | 12:10 | |
*** scooper has quit (Quit: Leaving) | 12:21 | |
*** scooper has quit (Read error: Connection reset by peer) | 12:38 | |
shmohamud | good day scooper | 12:53 |
---|---|---|
*** sysadmin has quit (Ping timeout: 480 seconds) | 12:58 | |
fkoikoi | Good morning shmohamud | 13:04 |
shmohamud | good day fkoikoi | 13:04 |
fkoikoi | How are you shmohamud? | 13:05 |
scooper | good morning shohamud | 13:05 |
shmohamud | good good, how're you? | 13:05 |
shmohamud | I have a cough, probably a minor virus, but I'll be OK | 13:05 |
scooper | I m fine | 13:05 |
scooper | speedy recovery from my end | 13:05 |
shmohamud | thanks scooper :) | 13:05 |
shmohamud | so, who wants to present their homework solution first? | 13:06 |
fkoikoi | let me be the first | 13:07 |
shmohamud | +1 | 13:07 |
fkoikoi | Attendance =[('freena', '17'), ('shallon', '15'), ('thomas', '18')] | 13:07 |
fkoikoi | d = dict(Attendance) | 13:07 |
fkoikoi | print(d) | 13:07 |
shmohamud | looks pretty good fkoiioi, however, I asked to loop through and print the values of the dict | 13:09 |
shmohamud | you printed the entire dict | 13:10 |
shmohamud | scooper, did you loop through? | 13:10 |
scooper | What do you mean?? | 13:10 |
scooper | shmohamud | 13:10 |
shmohamud | from yesterday: the homework is the create a python dictionary with 3 key-value pairs. Then, write a for loop that prints out all the values in the dict. | 13:11 |
scooper | +1 | 13:11 |
shmohamud | I just mean the second part, which is to write a for loop that loops through the values of the dict | 13:11 |
scooper | I follow your instruction | 13:12 |
scooper | should I loop through fkoikoi work or paste my | 13:13 |
scooper | *mine | 13:13 |
shmohamud | paste yours please | 13:13 |
scooper | dictionaryvalue = {"Nationality":"Liberian", "City":"Monrovia", "Place of Birth":"Monrovia"} | 13:13 |
scooper | for value in dictionaryvalue: | 13:13 |
scooper | print(value, dictionaryvalue[value]) | 13:13 |
shmohamud | fkoikoi, do you see how scooper created the dict without converting the list to dict? It is done in one line instead of two | 13:14 |
shmohamud | There's a good lesson in that | 13:14 |
shmohamud | Scooper, this is exactly what I hoped for, great job :) | 13:14 |
scooper | Thanks | 13:14 |
shmohamud | however, the naming could be improved. Instead of dictionaryvalue could you call it dict? and instead of "for value in dictionaryvalue" it would be better to do "for key in dict" since you're looping through keys | 13:15 |
shmohamud | can you show me what that would look like? | 13:15 |
shmohamud | fkoikoi - do you have any questions about how we created the dict and how we looped through? | 13:16 |
scooper | sorry I was not following first | 13:17 |
scooper | should I change what are did shmohamud?? | 13:17 |
shmohamud | change what you did | 13:17 |
scooper | ok | 13:17 |
shmohamud | just rename the dict and the looping variable from value to key | 13:17 |
scooper | before doing so | 13:18 |
scooper | using dict is a reserve word for dictionary when use with a open and close parenthesis will the name not affect my program if I still maintain the curly bracket?? | 13:19 |
shmohamud | oops, I made a mistake. I forgot it's a reserved word. Just call it python_dict | 13:20 |
shmohamud | i'm going to be right back, restroom break | 13:20 |
fkoikoi | okay | 13:22 |
scooper | shmohamud_dict = {"Nationality":"Liberian", "City":"Monrovia", "Place of Birth":"Monrovia"} | 13:22 |
scooper | for key in shmohamud_dict: | 13:22 |
scooper | print(key, shmohamud_dict[key]) | 13:22 |
shmohamud | exactly what I hoped for | 13:23 |
shmohamud | fkoikoi are you following how we did that? | 13:24 |
fkoikoi | yes | 13:24 |
shmohamud | can you write me a dict called comrades_dict and create key value pairs where the key is the comrade's name and the value is their age? | 13:25 |
shmohamud | for 3 comrades | 13:26 |
scooper | hello tmickelson | 13:26 |
tmickelson | hello fkoikoi, scooper, and shmohamud | 13:26 |
scooper | how are you doing tmickelson??? | 13:27 |
shmohamud | hello tmickelson | 13:27 |
fkoikoi | shmohamud, is the question for me? | 13:27 |
shmohamud | yes fkoikoi | 13:27 |
fkoikoi | Good morning tmickelson | 13:27 |
fkoikoi | okay | 13:27 |
tmickelson | im good scooper, how are you | 13:28 |
scooper | Not really fine tmickelson | 13:28 |
scooper | tmickelson, is the any update on the namecheap task we tried doing the late time???? | 13:31 |
scooper | welcome Jeff | 13:31 |
shmohamud | scooper when you're ready I have another question about dicts for you | 13:31 |
shmohamud | Hi Jeff :) | 13:32 |
scooper | I m already since tmickelson is not responding | 13:32 |
jelkner | Good morning, shmohamud! | 13:32 |
shmohamud | do you know what the get method is for python dicts? | 13:32 |
fkoikoi | comrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"} | 13:32 |
fkoikoi | print(comrades_dict) | 13:32 |
shmohamud | awesome job fkoikoi | 13:33 |
scooper | hmmmm | 13:33 |
tmickelson | scooper, you should have receved an email from namecheap about transfering the domain name | 13:33 |
shmohamud | fkoikoi, can you loop through the keys and values and print out the values using a for loop? | 13:34 |
scooper | Shmohamud please grant be few minutes of absence, let me attend to namecheap email tmickelson is talking about | 13:35 |
shmohamud | +1 scooper | 13:35 |
scooper | Thanks shmohamud | 13:35 |
fkoikoi | okay shmohamud | 13:35 |
scooper | +1 tmickelson | 13:36 |
scooper | I received the mail since the 25 of May | 13:36 |
fkoikoi | comrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"} | 13:38 |
fkoikoi | for d in comrades_dict: | 13:38 |
fkoikoi | print(d, comrades_dict) | 13:38 |
shmohamud | what variable represents the key in the dict fkokoi? | 13:38 |
tmickelson | scooper, can you follow the instructions in the email | 13:38 |
scooper | I did I m in already | 13:39 |
scooper | Now I m trying to "Accept" | 13:40 |
fkoikoi | comrades_dict | 13:41 |
shmohamud | that's the whole dict | 13:41 |
tmickelson | scooper, do you need help accepting or is that just a status | 13:41 |
tmickelson | *status update | 13:41 |
scooper | NO | 13:41 |
shmohamud | when looping through a dict using a for loop, the looping variable is the key | 13:42 |
scooper | I m filling in the form already.... just telling you my present status | 13:42 |
shmohamud | so in the loop you shared, the "d" is the key | 13:42 |
fkoikoi | okay | 13:42 |
shmohamud | can you rewrite the loop using key as the variable name for the key? | 13:44 |
fkoikoi | +1 | 13:44 |
fkoikoi | comrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"} | 13:45 |
fkoikoi | for key in comrades_dict: | 13:45 |
fkoikoi | print(key, comrades_dict) | 13:45 |
shmohamud | perfect | 13:45 |
shmohamud | so now, do you know how to print out the ages using the key and the comrades_dict dict? | 13:45 |
fkoikoi | only their ages? | 13:46 |
shmohamud | yes, only their ages | 13:46 |
shmohamud | if you want you can print their name too. I just want to make sure you know how to use keys and a dict to access dict values | 13:46 |
scooper | Thanks tmickelson I m done for now is the any other thing left??? | 13:46 |
scooper | Shmohamud I m back | 13:47 |
shmohamud | awesome | 13:48 |
shmohamud | do you know how to use the get dict method scooper? | 13:48 |
scooper | not really acquaint in doing so, though I read on it why doing my assignment | 13:49 |
shmohamud | ok, it's pretty simple. If you write {dict_name}.get('key') it will grab the value or return a default value of None | 13:49 |
scooper | but I can give it a try | 13:50 |
shmohamud | use the get method to grab one of the values from your dict from earlier | 13:50 |
scooper | ok | 13:50 |
shmohamud | set it equal to a variable called dict_value | 13:50 |
shmohamud | then print dict_value | 13:50 |
shmohamud | fkoikoi how're you doing? | 13:55 |
fkoikoi | I'm fine | 13:55 |
shmohamud | I mean with the question lol | 13:55 |
shmohamud | good to hear, though :) | 13:56 |
fkoikoi | on the print statement? | 13:57 |
shmohamud | using the for loop to print the ages of comrades_dict | 13:58 |
fkoikoi | print(comrades_dict['spencer']) | 14:00 |
shmohamud | awesome | 14:01 |
shmohamud | how would you do that in the loop? | 14:01 |
fkoikoi | comrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"} | 14:01 |
fkoikoi | for key in comrades_dict: | 14:01 |
fkoikoi | print(comrades_dict['spencer']) | 14:01 |
shmohamud | close, but what if I wanted all the different ages to print, not just spencer? | 14:01 |
fkoikoi | let me try | 14:02 |
fkoikoi | comrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"} | 14:04 |
fkoikoi | for key in comrades_dict: | 14:04 |
fkoikoi | print(key, comrades_dict[key]) | 14:04 |
shmohamud | Bingo! Well done!! | 14:04 |
shmohamud | You guys are learning too fast for me to keep up. I'm going to have to start prepping more material :D | 14:05 |
scooper | shmohamud_dict = {"Nationality":"Liberian", "City":"Monrovia", "Place of Birth":"Monrovia"} | 14:05 |
scooper | for key in shmohamud_dict: | 14:05 |
scooper | print(key, shmohamud_dict.get(key)) | 14:05 |
shmohamud | also perfect, scooper! Way to go. | 14:05 |
scooper | Is it what you mean | 14:05 |
shmohamud | That's what I was hoping for. You got it | 14:06 |
shmohamud | as you can see, we're using the get method to grab the value associated with the key | 14:06 |
shmohamud | Keep in mind this method can be used outside of loops, just to check if a dict has a given value associated with.a key | 14:07 |
shmohamud | I think we've had a successful session today guys, way to go. Any questions before I hand out some homework? | 14:07 |
scooper | yes | 14:08 |
scooper | let discuss fkoikoi first dictionary assignment | 14:09 |
scooper | Why reading the book I saw a method called zip that convert list to dictionary | 14:09 |
shmohamud | interesting, let me look that up | 14:09 |
scooper | By creating lists | 14:10 |
scooper | By creating two lists | 14:12 |
shmohamud | The zip() function returns a zip object, which is an iterator of tuples where the first item in each passed iterator is paired together, and then the second item in each passed iterator are paired together etc. | 14:13 |
shmohamud | it looks like it doesn't convert it to a dict, but rather into a zip object that can be made readable by converting that using the tuple() method | 14:14 |
shmohamud | fkoikoi's answer is about a topic I'm going to review before tomorrow, tuples | 14:16 |
shmohamud | Can I get back to you tomorrow on how it was possible she made the dict from the tuples, scooper? | 14:16 |
fkoikoi | Shmohamud? | 14:17 |
scooper | ok | 14:17 |
shmohamud | Yes fkoikoi? | 14:17 |
shmohamud | For homework, I want you both to pick two new dict methods and come with an example for how to use both: https://www.w3schools.com/python/python_ref_dictionary.asp | 14:18 |
shmohamud | I recommend learning items() and values() | 14:19 |
fkoikoi | I did my assignment using the dict function from the book I read. I didn't read on tuples so can you please tell me how the difference or similarity between the dict function and tuples? | 14:19 |
shmohamud | I will have an answer for you tomorrow, I haven't had a chance to learn tuples myself! | 14:20 |
fkoikoi | okay | 14:20 |
shmohamud | Great job using your resources, by the way. I learned something new from your answer. | 14:20 |
shmohamud | Any last questions before we call it day guys? | 14:21 |
fkoikoi | thanks | 14:21 |
shmohamud | you're welcome | 14:21 |
shmohamud | alright if there are no questions, I'm logging off for the day | 14:24 |
fkoikoi | okay | 14:24 |
shmohamud | have a great rest of your day guys | 14:24 |
fkoikoi | you too shmohamud | 14:24 |
*** shmohamud has quit (Remote host closed the connection) | 14:24 | |
*** shmohamud has quit (Ping timeout: 480 seconds) | 14:33 | |
*** tmickelson has quit (Quit: leaving) | 14:48 | |
*** shmohamud has quit (Remote host closed the connection) | 14:49 | |
*** fkoikoi has quit (Quit: Leaving) | 15:08 | |
*** scooper has quit (Read error: Connection reset by peer) | 15:13 | |
*** sysadmin has quit (Ping timeout: 480 seconds) | 15:24 | |
*** jelkner has quit (Quit: Leaving) | 16:26 | |
*** shmohamud has quit (Remote host closed the connection) | 16:34 | |
*** shmohamud has quit (Ping timeout: 480 seconds) | 16:43 | |
*** sysadmin_ has quit (Quit: Leaving) | 16:54 | |
*** shmohamud has quit (Ping timeout: 480 seconds) | 17:54 | |
*** shmohamud has quit (Remote host closed the connection) | 19:39 |
Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!