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

*** shmohamud has quit (Ping timeout: 480 seconds)04:54
*** fkoikoi has quit (Ping timeout: 480 seconds)12:12
shmohamudgood day 12:49
fkoikoi_Good morning shmohamud12:51
scoopergood morning shmohamud how are you doing in health now???12:51
shmohamudI'm doing much better now, thanks for asking12:52
shmohamudso, do you guys have any questions before we kick off today's lesson?12:52
scooperFor me no12:53
shmohamudfkoikoi?12:53
fkoikoi_no12:54
shmohamudscooper, can you write me a function that takes in a number and returns me the same number to the power of 2?12:54
scooperyes12:54
shmohamudfkoikoi, can you write me an example of assigning a value to a variable and then reassigning it to a numeric expression?12:54
shmohamudplease do scooper12:55
scoopershould I all it's just a question????12:55
shmohamudnope, please do12:55
shmohamudand remember it's important to name the function properly12:55
scooperdef exponentiation(number):12:58
scooper    number = number ** number12:58
scooper    return number12:58
scooperprint(exponentiation(13))12:58
shmohamudscooper, great job, that works.12:59
shmohamudMy one recommendation is to use verbs when you're naming functions12:59
scooperOK shmohamud12:59
shmohamudif you're raising to a power, something like raise_to_power12:59
shmohamudbut the name is better than previous, so great job on imrpoving13:00
scooperI will that and put it in to practice when learning13:00
shmohamudfkoifkoi are you there?13:00
shmohamudScooper, are you familiar with the different comparison operators?13:00
scooperyes13:00
shmohamudcan you name 3 now?13:00
scooperyes13:00
shmohamudplease do13:01
scooper!=, >=, <=, ==, 13:01
shmohamudbeautiful13:01
fkoikoi_school = "only student are allow"13:01
fkoikoi_number = 4613:01
shmohamudok, fkoikoi good attempt. The key word is "reassign" that means taking the variable school and assigning it to 4613:03
shmohamudAnd when I say numeric experssion, I mean a chunk of code that executes first using numbers, like 46 + 9 13:03
fkoikoi_okay13:04
shmohamudspencer, do you know how indentation works in Python? For conditionals and loops13:04
scooperyes13:04
fkoikoi_school = "only student are allow"13:05
fkoikoi_school = 46 * 613:05
scooperThe are two ways to indent in python, you either press the space back key on the key four time after use the tab key one time13:06
shmohamudnice13:06
scooperBut this should be done under the condition or loop13:06
shmohamudok, what do we call a function that has no return value in Python?13:06
scoopernull13:07
shmohamudvoid functions, or "not fruitful" functions13:07
shmohamudnull is close enough, in my opinion 13:08
scoopersorry void13:08
scoopermean empty13:08
shmohamudyes13:08
shmohamuddo you guys know how to break out of a loop in python?13:08
scooperyes13:09
fkoikoi_no13:09
shmohamudspencer, can you write a for loop that prints every number from 1 to 100 but has a conditional that if the number is greater than 20, break13:10
shmohamud?13:10
scooperlet me give it a try13:10
shmohamudthis way, we can demonstrate for fkoikoi how break statements work in Python13:11
shmohamudfkoikoi, are you familiar with indexing strings in Python?13:15
scooperdef countingNumber(checkingValue):13:17
scooper    for value in range(100):13:17
scooper        if value > 20:13:17
scooper            break13:17
scooper        return value13:17
scooperprint(countingNumber(value))13:17
fkoikoi_no13:17
scooperplease wait I m still figuring out what when run13:17
shmohamudspencer, did I ask to return the value or print every number leading up to the break?13:18
shmohamudok fkoikoi, we'll jump into indexing right after this :)13:18
scooperyou said print the value13:19
scooperso when the function is called out of the function body13:19
scooperI m expecting it to print the value13:19
shmohamudyes, print every number from 1 to 100 leading up to the break, including the 20 but not 2113:20
shmohamudok, give it another shot and we'll work together if it's not perfect13:21
shmohamudfkoikoi, check out the powerpoint slides here on indexing strings in the meantime: https://www.py4e.com/lessons/strings13:25
scoopernumber1 = 013:26
scoopernumber2 = 10013:26
scooperdef countingNumber(number1, number):13:26
scooper    for value in range(number, number2):13:26
scooper        if value == 20:13:26
scooper            break13:26
scooper            print (value)13:26
scooperprint(countingNumber(number1, number2))13:26
scooperstill not working13:26
scoopernumber1 = 013:27
scoopernumber2 = 10013:27
scooperdef countingNumber(number1, number2):13:27
scooper    for value in range(number1, number2):13:27
scooper        if value == 20:13:27
scooper            break13:27
scooper            print (value)13:27
shmohamudok, you've got a good start here. First, remove number1, number2 arguments from the function, we don't need to call this function with arguments since we know we want to loop high13:27
scooperprint(countingNumber(number1, number2))13:27
scooperI just did13:27
shmohamudsecond, in range(100) just print the number on the next line instead of after the break and inside the conditional. If we have the print statement after the break, it will never run, because the break takes us out of the loop!13:28
shmohamudso, if you move print(value) to be right under the for loop, this should work fine13:28
shmohamudBut also notice, when you're calling a function with arguments, you can't provide undefined variables. print(countingNumber(number1, number2)) doesn't know what number1, number2 are because they're undefined13:29
shmohamudFinally, do you need a print statement when calling this function?13:30
shmohamudas you did with print(countingNumber(number1, number2))?13:30
scooperTypeError: countingNumber() missing 1 required positional argument: 'number2'13:32
shmohamudwhy don't you remove number1, number2 from the entire function, and go back to using range(100) ?13:32
scooperIf I removed the argument this is what will happen shmohamed13:32
shmohamudlet's see the code please13:33
shmohamudfkoikoi are you paying attention? :)13:33
scooperdef countingNumber(number):13:34
scooper    for value in range(100):13:34
scooper        print(value)13:34
scooper        break13:34
scooper        13:34
scooperprint(countingNumber(100))13:34
shmohamudok, so first off, why don't you remove the number argument from the function and also from where you're calling it?13:35
scooperIf I removed the "break" the code will run from 0 t0 9913:35
shmohamudthis is a good start, but let's do some cleanup, ok?13:35
scooperTypeError: countingNumber() missing 1 required positional argument: 'number'13:36
scooperif I removed the argument that will be the error13:36
shmohamudbecause you have to remove it from the function definition too, have you done that?13:37
scooperthat mean I write a void function right???13:37
shmohamudnot necessarily13:37
scooperA will output 0 and NONE13:37
shmohamudbut remember this is just a teaching example for the break statement13:38
shmohamudit will still print numbers up to 20, right?13:38
scooperif I removed the parameter13:38
scooperdef countingNumber():13:38
scooper    for value in range(100):13:38
scooper        print(value)13:38
scooper        break13:38
scooper        13:38
scooperprint(countingNumber())13:38
scooperthat is the code snippet13:38
shmohamudso does this print 113:38
scooperNo13:39
scooperzero and NONE13:39
shmohamudwhat happens?13:39
shmohamudoh wait a minute13:39
shmohamudwhy do you call print(countingNumber())13:39
shmohamud?13:39
shmohamudshouldn't we just call countingNumber()13:39
shmohamudfkokoi, I'm sorry to hear about the headache and stress. Take it easy today, we will have many more sessions. Pay attention where possible, no pressure.13:40
scooperI DID13:40
scooperIt print 013:40
shmohamudscooper, we're almost there!13:40
shmohamudSo, what's left to make it work as I asked?13:41
scooperto set a conditional statement13:41
scooperright???13:41
shmohamudyes, and have it break when it hits 2113:42
shmohamudso we should see numbers from 0 to 20 printed13:42
scooperToday is challenging 13:45
scooperdef countingNumber():13:45
scooper    for value in range(100):13:45
scooper        print(value)13:45
scooper        break13:45
scooper    if value >= 20:13:45
scooper        print(value)13:45
scooper        13:45
scooper(countingNumber())13:45
scooperPlease hold on13:45
shmohamudok13:45
scooperI need to indent the if statement under the for loop13:46
shmohamudyou're doing a great job, by the way.13:46
shmohamudok13:46
shmohamudmake the indent properly13:46
shmohamudthen, ask yourself, where should the break statement go?13:46
scooperI got it13:47
scooperdef countingNumber():13:47
scooper    for value in range(100):13:47
scooper        print(value)13:47
scooper        if value >= 20:13:47
scooper            break13:47
scooper        print(value)13:47
scooper        13:47
scooper(countingNumber())13:48
shmohamudwell done. have you run the code?13:48
scooper+113:48
shmohamudok, two comments13:48
scooperI need to see the previous code to know all of my errors13:49
shmohamudfirst, can you re-write the conditional so it includes 20?13:49
shmohamudI want 20 to be printed out, but not 2113:49
scooper20 is already included13:49
shmohamudso that 20 gets printed out13:49
scooperyes13:49
scooperPlease run the code again13:49
shmohamudit's getting printed out already?13:49
shmohamudOk, second comment: do we need the print(value) after the break?13:51
scooperyes for beginner level13:52
shmohamudwhat do you mean for beginner level?13:52
scooperI mean beginner like me need to do so for now 13:52
shmohamudhahahaha13:52
shmohamudI see. Well, you're doing great, I'm impressed and excited to work with you to make you an expert level.13:53
scooperAm I right for now???13:53
scooperThanks shmohamud13:53
shmohamudYes, you're right. But one more question, do you need to define a function to do this?13:53
scooperYou mean the program we just wrote???13:54
shmohamudyes13:54
shmohamudspencer, can you write a for loop that prints every number from 1 to 100 but has a conditional that if the number is greater than 20, break 13:54
shmohamudthe question ^^13:55
scooperI will say yes, if we will like to use this program in another place... that is why function is so important13:55
shmohamudBingo, good answer!13:56
shmohamudOk, so I have an appointment in 4 minutes. Any last questions before I get going for the day?13:56
scooperBut if we want this to be a global variable that other program can use them we can defined it outside the function13:57
shmohamudcan you define a function as a variable? They're two different animals right?13:57
scooperNo13:58
shmohamudok13:58
scooperit is not advisable to do that according to Python for everybody13:58
shmohamudgood13:58
shmohamudok, any final questions?13:58
scooperyes13:59
scooperWhy do function variable have the same names in seporate function but don't render error or encounter conflict???14:00
scooperexample14:01
shmohamudok scooper can you wait 1 hour for me to finish my appointmenrt?14:01
scooperOK let meet tomorrow14:01
scooperplease shmohamud14:01
scooperAll we should stick around??14:01
*** fkoikoi_ has quit (Quit: Leaving)14:08
shmohamudhi scooper14:51
shmohamudare you still here?14:51
scooperyes14:51
scooperI m here14:51
shmohamudsorry for not replying earlier. 14:51
shmohamudThe appointment was for 10AM14:51
scooperI understand14:52
shmohamudWhy do function variable have the same names in seporate function but don't render error or encounter conflict???14:52
shmohamudis that your question?14:52
scooperyes14:52
scooperProgrammer14:52
shmohamudlol ok, let's see.14:52
scoopershould I put an example ???14:53
shmohamudso, you're wondering why we could have two or more functions that use the same variables inside of them, but there's not an error?14:53
scooperyes14:53
shmohamude.g. def get_info:14:53
shmohamudinfo = "Test info"14:54
shmohamuddef delete_info:14:54
shmohamudinfo = "Test info"14:54
shmohamudlike that?14:54
shmohamudboth functions have info variable defined?14:54
scooperAre the info serving as inter variable right??14:54
scooperin the two function??14:55
scooperIf yes, that is exact what I mean14:55
shmohamudinfo is inside the functions, so it's two different variables even though they have the same name. This is because of what's called "scope"14:55
scooper*exactly14:55
shmohamudLet me find a good resource for you14:55
shmohamudhttps://realpython.com/python-namespaces-scope/#variable-scope14:56
shmohamudthe reason is because the variables are local scope14:57
scooperglobal or local??14:58
shmohamudlocal 14:59
scooperok14:59
shmohamudok scooper 15:02
shmohamudanything else?15:02
scooperNo Shmohamud15:02
shmohamudalrighty, see you tomorrow. Great job toeday.15:02
scooperThanks Shmohamud15:02
shmohamudyou're welcome415:03
shmohamudhave a great rest of the day15:03
scooperANy15:03
scoopermessage from Jeff15:03
shmohamudnope, he's busy this week15:04
scooperAll right???15:05
shmohamudall is well with Jeff15:05
shmohamudspoke to him Monday15:05
scooperDo you stay in Arlington too???15:07
scooperCan I leave now shmohamud???15:08
*** scooper has quit (Quit: Leaving)15:09
*** shmohamud has quit (Remote host closed the connection)15:09
*** shmohamud has quit (Remote host closed the connection)15:20
*** shmohamud has quit (Remote host closed the connection)17:48
*** shmohamud has quit (Remote host closed the connection)17:55
*** scooper has quit (Quit: Leaving)17:57
*** shmohamud has quit (Ping timeout: 480 seconds)18:04
*** shmohamud has quit (Ping timeout: 480 seconds)18:15
*** shmohamud has quit (Ping timeout: 480 seconds)18:36
*** shmohamud has quit (Ping timeout: 480 seconds)18:45

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!