IRC log of #novawebdev for Wednesday, 2023-05-31

*** 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
shmohamudgood day scooper12:53
*** sysadmin has quit (Ping timeout: 480 seconds)12:58
fkoikoiGood morning shmohamud13:04
shmohamudgood day fkoikoi13:04
fkoikoiHow are you shmohamud?13:05
scoopergood morning shohamud13:05
shmohamudgood good, how're you?13:05
shmohamudI have a cough, probably a minor virus, but I'll be OK13:05
scooperI m fine13:05
scooperspeedy recovery from my end13:05
shmohamudthanks scooper :)13:05
shmohamudso, who wants to present their homework solution first?13:06
fkoikoilet me be the first13:07
shmohamud+113:07
fkoikoiAttendance =[('freena', '17'), ('shallon', '15'), ('thomas', '18')]13:07
fkoikoid = dict(Attendance)13:07
fkoikoiprint(d)13:07
shmohamudlooks pretty good fkoiioi, however, I asked to loop through and print the values of the dict13:09
shmohamudyou printed the entire dict13:10
shmohamudscooper, did you loop through?13:10
scooperWhat do you mean??13:10
scoopershmohamud13:10
shmohamudfrom 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+113:11
shmohamudI just mean the second part, which is to write a for loop that loops through the values of the dict13:11
scooperI follow your instruction13:12
scoopershould I loop through fkoikoi work or paste my13:13
scooper*mine13:13
shmohamudpaste yours please13:13
scooperdictionaryvalue = {"Nationality":"Liberian", "City":"Monrovia", "Place of Birth":"Monrovia"}13:13
scooperfor value in dictionaryvalue:13:13
scooper    print(value, dictionaryvalue[value])13:13
shmohamudfkoikoi, do you see how scooper created the dict without converting the list to dict? It is done in one line instead of two13:14
shmohamudThere's a good lesson in that13:14
shmohamudScooper, this is exactly what I hoped for, great job :)13:14
scooperThanks13:14
shmohamudhowever, 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 keys13:15
shmohamudcan you show me what that would look like?13:15
shmohamudfkoikoi - do you have any questions about how we created the dict and how we looped through?13:16
scoopersorry I was not following first13:17
scoopershould I change what are did shmohamud??13:17
shmohamudchange what you did13:17
scooperok13:17
shmohamudjust rename the dict and the looping variable from value to key13:17
scooperbefore doing so13:18
scooperusing 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
shmohamudoops, I made a mistake. I forgot it's a reserved word. Just call it python_dict13:20
shmohamudi'm going to be right back, restroom break13:20
fkoikoiokay13:22
scoopershmohamud_dict = {"Nationality":"Liberian", "City":"Monrovia", "Place of Birth":"Monrovia"}13:22
scooperfor key in shmohamud_dict:13:22
scooper    print(key, shmohamud_dict[key])13:22
shmohamudexactly what I hoped for13:23
shmohamudfkoikoi are you following how we did that?13:24
fkoikoiyes13:24
shmohamudcan 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
shmohamudfor 3 comrades13:26
scooperhello tmickelson13:26
tmickelsonhello fkoikoi, scooper, and shmohamud13:26
scooperhow are you doing tmickelson???13:27
shmohamudhello tmickelson13:27
fkoikoishmohamud, is the question for me?13:27
shmohamudyes fkoikoi13:27
fkoikoiGood morning tmickelson13:27
fkoikoiokay13:27
tmickelsonim good scooper, how are you13:28
scooperNot really fine tmickelson13:28
scoopertmickelson, is the any update on the namecheap task we tried doing the late time????13:31
scooperwelcome Jeff13:31
shmohamudscooper when you're ready I have another question about dicts for you13:31
shmohamudHi Jeff :)13:32
scooperI m already since tmickelson is not responding13:32
jelknerGood morning, shmohamud!13:32
shmohamuddo you know what the get method is for python dicts?13:32
fkoikoicomrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"}13:32
fkoikoiprint(comrades_dict)13:32
shmohamudawesome job fkoikoi13:33
scooperhmmmm13:33
tmickelsonscooper, you should have receved an email from namecheap about transfering the domain name13:33
shmohamudfkoikoi, can you loop through the keys and values and print out the values using a for loop?13:34
scooperShmohamud please grant be few minutes of absence, let me attend to namecheap email tmickelson is talking about13:35
shmohamud+1 scooper13:35
scooperThanks shmohamud13:35
fkoikoiokay shmohamud13:35
scooper+1 tmickelson13:36
scooperI received the mail since the 25 of May13:36
fkoikoicomrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"}13:38
fkoikoifor d in comrades_dict:13:38
fkoikoi    print(d, comrades_dict)13:38
shmohamudwhat variable represents the key in the dict fkokoi?13:38
tmickelsonscooper, can you follow the instructions in the email13:38
scooperI did I m in already13:39
scooperNow I m trying to "Accept"13:40
fkoikoicomrades_dict13:41
shmohamudthat's the whole dict13:41
tmickelsonscooper, do you need help accepting or is that just a status13:41
tmickelson*status update13:41
scooperNO13:41
shmohamudwhen looping through a dict using a for loop, the looping variable is the key13:42
scooperI m filling in the form already.... just telling you my present status 13:42
shmohamudso in the loop you shared, the "d" is the key13:42
fkoikoiokay13:42
shmohamudcan you rewrite the loop using key as the variable name for the key?13:44
fkoikoi+113:44
fkoikoicomrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"}13:45
fkoikoifor key in comrades_dict:13:45
fkoikoi    print(key, comrades_dict)13:45
shmohamudperfect13:45
shmohamudso now, do you know how to print out the ages using the key and the comrades_dict dict?13:45
fkoikoionly their ages?13:46
shmohamudyes, only their ages 13:46
shmohamudif 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 values13:46
scooperThanks tmickelson I m done for now is the any other thing left???13:46
scooperShmohamud I m back13:47
shmohamudawesome13:48
shmohamuddo you know how to use the get dict method scooper?13:48
scoopernot really acquaint in doing so, though I read on it why doing my assignment13:49
shmohamudok, it's pretty simple. If you write {dict_name}.get('key') it will grab the value or return a default value of None13:49
scooperbut I can give it a try13:50
shmohamuduse the get method to grab one of the values from your dict from earlier13:50
scooperok13:50
shmohamudset it equal to a variable called dict_value13:50
shmohamudthen print dict_value13:50
shmohamudfkoikoi how're you doing?13:55
fkoikoiI'm fine13:55
shmohamudI mean with the question lol13:55
shmohamudgood to hear, though :)13:56
fkoikoion the print statement?13:57
shmohamudusing the for loop to print the ages of comrades_dict13:58
fkoikoiprint(comrades_dict['spencer'])14:00
shmohamudawesome14:01
shmohamudhow would you do that in the loop?14:01
fkoikoicomrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"}14:01
fkoikoifor key in comrades_dict:14:01
fkoikoi    print(comrades_dict['spencer'])14:01
shmohamudclose, but what if I wanted all the different ages to print, not just spencer?14:01
fkoikoilet me try14:02
fkoikoicomrades_dict ={"spencer":"31", "freena":"17", "tmickelson":"21"}14:04
fkoikoifor key in comrades_dict:14:04
fkoikoi    print(key, comrades_dict[key])14:04
shmohamudBingo! Well done!!14:04
shmohamudYou guys are learning too fast for me to keep up. I'm going to have to start prepping more material :D14:05
scoopershmohamud_dict = {"Nationality":"Liberian", "City":"Monrovia", "Place of Birth":"Monrovia"}14:05
scooperfor key in shmohamud_dict:14:05
scooper    print(key, shmohamud_dict.get(key))14:05
shmohamudalso perfect, scooper! Way to go.14:05
scooperIs it what you mean14:05
shmohamudThat's what I was hoping for. You got it14:06
shmohamudas you can see, we're using the get method to grab the value associated with the key14:06
shmohamudKeep in mind this method can be used outside of loops, just to check if a dict has a given value associated with.a key14:07
shmohamudI think we've had a successful session today guys, way to go. Any questions before I hand out some homework?14:07
scooperyes14:08
scooperlet discuss fkoikoi first dictionary assignment14:09
scooperWhy reading the book I saw a method called zip that convert list to dictionary14:09
shmohamudinteresting, let me look that up14:09
scooperBy creating lists14:10
scooperBy creating two lists14:12
shmohamudThe 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
shmohamudit 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() method14:14
shmohamudfkoikoi's answer is about a topic I'm going to review before tomorrow, tuples14:16
shmohamudCan I get back to you tomorrow on how it was possible she made the dict from the tuples, scooper?14:16
fkoikoiShmohamud?14:17
scooperok 14:17
shmohamudYes fkoikoi?14:17
shmohamudFor 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.asp14:18
shmohamudI recommend learning items() and values() 14:19
fkoikoiI 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
shmohamudI will have an answer for you tomorrow, I haven't had a chance to learn tuples myself!14:20
fkoikoiokay14:20
shmohamudGreat job using your resources, by the way. I learned something new from your answer.14:20
shmohamudAny last questions before we call it day guys?14:21
fkoikoithanks14:21
shmohamudyou're welcome14:21
shmohamudalright if there are no questions, I'm logging off for the day14:24
fkoikoiokay14:24
shmohamudhave a great rest of your day guys14:24
fkoikoiyou 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/!