IRC log of #novawebdev for Friday, 2024-01-12

*** fkoikoi has quit (Ping timeout: 480 seconds)12:52
*** tboimah has quit (Ping timeout: 480 seconds)12:52
*** Janet has quit (Quit: Leaving)13:14
ubuntouristHi Janet tboimah_ 14:01
ubuntouristI do not have any great wisdom to dispense today...14:01
tboimah_Good morning ubuntourist14:01
ubuntouristI have become less helpful because I believe the web pages that Jeff has sent will teach you almost everything you need.14:03
tboimahsure14:03
ubuntouristBut I am here for questions and the occasional tip.14:03
ubuntouristI was talking a lot with svaye about truth tables last time. 14:04
tboimahokay let me send you some question14:04
tboimahjust give me a minute14:04
ubuntouristFor me, understanding Boolean logic and Boolean algebra, and binary were invaluable.14:05
ubuntouristtboimah, okay...14:05
JanetHi Mr. Cole14:06
ubuntouristhi Janet 14:06
tboimahwhy is this print('100' == '0100', end=' ')14:07
tboimahprint('100' > '0100', end=' ')14:07
tboimahprint('100' > '80', end=' ')14:07
tboimahprint('200' < '80', end=' ')14:07
tboimahprint('200' < '800') code giving False True False True True14:07
tboimahas the answer14:07
ubuntouristhi dcammue I don't think I have an e-mail address for you.14:08
tboimahthat question is for you ubuntourist14:08
dcammueyes14:08
svayeGood morning Mr Cole14:08
dcammuehere is it14:08
ubuntouristtboimah, got it. 14:09
dcammuedainelcammue@gmail.com,   my novaweb mail is giving hard time so just use this one for now14:09
ubuntouristtboimah, think about the quote marks...14:09
ubuntouristdcammue, thanks.14:10
tboimahyeah i understand that is a string14:10
tboimahnot an intreger14:10
ubuntouristtboimah, Good. So, now, think about strings. Which is "less" than the other:14:10
ubuntourist"Bob" or "Joe"?14:11
tboimahBob14:11
ubuntouristRight again. Now:14:12
ubuntourist"Bob" == "OBob"? True or false?14:12
tboimahFalse14:13
ubuntourist"100" == "0100"? True or false?14:13
gabrielfalse14:14
ubuntourist"10" > "01"?14:14
tboimahTrue14:15
ubuntouristAnd so "100" > "010" and "100" > "0100000000" because in ALPHABETICAL order, 1 will ALWAYS come after 0, and 1 is the first "letter" in one of the two strings.14:18
tboimahOkay i understand now it deal with the first number.14:19
tboimahit is not looking at the length14:19
ubuntouristIf you change 0, 1, 2, 3, ... to A, B, C, D it makes it clearer..14:20
ubuntouristtboimah, Right. Exactly.14:20
tboimahI get the understanding now14:20
tboimahThank you14:20
ubuntouristIt is lookiing at how you would find them in an index of a book if they were strings.14:21
ubuntouristHow is everyone else doing? Questions?14:21
tboimahI have one more question14:21
ubuntouristtboimah, go ahead14:22
tboimahwhy is the print('123abc'.isalnum(), end=' ')14:23
tboimahprint('abc'.isalnum(), end=' ')14:23
tboimahprint('12'.isalnum(), end=' ')14:23
tboimahprint('@'.isalnum(), end=' ')14:23
tboimahprint('123_abc'.isalnum(), end=' ')14:23
tboimahprint(''.isalnum()) giving the answer to be True True True False False False14:23
ubuntouristisalnum means is_al_num mean is alpha-numeric. 14:25
ubuntouristIt only includes alphabetic characters or numeic characters. A-Z, a-z, and 0-9.14:26
ubuntouristAnything else is punctuation or something else. Not alphanumeric.14:26
ubuntourist(Actually, I am speaking with my American bias. We live in a bigger world now,14:27
ubuntouristbut I am usually only dealing with English. Now there are lots of other characters that would be14:27
ubuntouristconsidered "alphabetic". But I've never tried feeding Arabic, Hebrew, Chinese or Japanese14:28
ubuntouristcharacters into Python and asking if they are alphanumeirc.)14:28
tboimahokay i understand now when ever it dose not content an alphabet or a number is a False14:30
tboimahbut if dose then it is a True14:30
ubuntouristIf any character in the string is not a number or letter, then it's false. Otherwise, it's true.14:31
tboimahsure14:31
ubuntourist(For an English speaker it becomes strange: I studied a little bit of Chinese, and I like the grammar:14:32
ubuntouristTo ask a question, you can either make a statement and add a question mark to the end, or you can ask a "multiple choice" question.14:33
ubuntouristFor example, I would not say "How are you?" I would say "You are fine question mark" or I would say "You are fine or not fine"14:34
ubuntouristand expect you to answer "I am fine".14:34
ubuntourist"Ni hao" = "You are fine". 14:35
ubuntourist"Ni hao ma" = "You are fine question". 14:35
ubuntourist"Ni hao bu hao" = "You are fine not fine"14:35
ubuntouristSo, because "ma" means "?" is the Chinese way of printing "ma" a punctuation mark or a letter? I don't know.14:36
tboimahokay14:38
gabrielok14:38
ubuntouristAnyway, if you end up doing Python work for a Chinese person or organization, isalnum() could give interesting results. ;-)14:39
tboimahwaiting to experence that in the fature14:40
tboimah*future14:40
ubuntouristBy the way, if you have not read the IRC log of my discussion with svaye on Boolean and truth tables, 14:41
ubuntouristI recommend that you do.14:41
tboimahI did that already14:41
tboimahBoolean have to do with "True" and "False"14:41
ubuntouristAnd later, we can do the same thing with bits. Instead of having five variables that are set to True or False,14:42
ubuntouristwe can have ONE variable, and use five bits of the variable to set them to 1 or 0 instead.14:42
ubuntourist( tboimah and mulbah had a preview of this when we were talking about "chmod" "rwx" and octal. So talk with them about it.)14:44
ubuntourist(rwxr-xr-x   =  111101101   =   755)14:45
ubuntourist( = True, True, True, True, False, True, True, False, True)14:45
tboimahsure14:45
tboimahfor everywhere you see "1" you represent it by True and where you "0" you represent it by False14:46
tboimah*see14:46
ubuntouristIn many of your Python programs you will have several conditions, and often it is clearer to have separate variables for different conditions.14:47
ubuntouristBut sometimes, it will make sense to combine all the conditions into a single variable using bits instead.14:47
ubuntouristUsing permissions as an example, you could have lots of variables:14:48
ubuntouristowner_read = True14:48
ubuntouristowner_write = True14:49
ubuntouristowner_execute = True14:49
ubuntouristgroup_read = True14:49
ubuntouristgroup_write = False14:49
ubuntourist... and so on. OR, you could have one variable:14:50
ubuntouristpermissions = 0o755        # 0o  means "octal". So 755 octal.14:50
tboimah0x755 means "hexadecimal" 75514:51
tboimahis that right14:52
ubuntouristtboimah, yes but I was trying to stick with the "rwxr-xr-x" example. So I didn't want to talk about hexidecimal.14:52
tboimahokay14:53
tboimahsorry that14:53
tboimah*for14:53
ubuntouristtboimah (You can't use hex with "chmod" you can only use the letters or the octal value)14:53
ubuntouristtboimah, but it is good to know about 0o, 0x and 0b for binary14:54
ubuntouristtboimah, they will all come in very handy at some point in your careers. (I use hex more than octal or binary.)14:54
ubuntouristWhen writing code ask yourself:14:55
tboimahOkay thanks for the motivation14:55
ubuntourist1. Is it clear? Did I choose good variable names, and good comments? If I am on vacation, or sick or move to a different country, will someone else be able to improve my code?14:56
ubuntourist2. Is it "modular"? Do not try to write code that is a 900-page masterpiece novel or a 5-hour movie. Write small stories and chapters that can be broken apart14:57
ubuntouristand put together in different ways to tell larger stories. When you do something "clever"14:58
ubuntouristthink about "What if I want to do that clever thing in another program?"14:58
ubuntouristIf you start creating functions, and later, classses and objects, you will be able to reuse your code in14:59
ubuntouristdifferent ways.14:59
ubuntouristWhen you use "import" that's what you're doing: Someone has taken the time to break big ideas into small14:59
ubuntouristreusable parts that let you make your programs simpler and easier to understand.15:00
ubuntouristThese are good things to think about now, while your programs are small and managable. Establish good habits early,15:01
ubuntouristso that you won't need to break your bad habits later.15:01
tboimahokay15:02
ubuntouristI have a joke with jelkner - I keep telling him I am going to write a book called "Worst Practices"15:03
ubuntouristthat will teach students all of my bad habits that I have not succeeded in breaking.15:03
ubuntouristOne of the "best practices" is called DRY -- Don't Repeat Yourself. 15:04
ubuntouristBut my book will have RYE -- Repeat Yourself Everywhere. 15:05
ubuntouristDRY means  you should avoid just copying and pasting the same code again and again.15:05
ubuntouristInstead, you should turn it into a function. For example, you really don't need multiplication: You can 15:06
ubuntouristmultiply by repeating addition again and again. But that is a very stupid thing to do. 15:06
ubuntouristInstead of "x = 5 * 20" I could write:15:07
ubuntouristx = 015:07
ubuntouristfor y in range(5):15:07
ubuntourist    x = x + 2015:07
ubuntouristDumb.15:08
ubuntouristAny time you are thinking "... there should be an easier way to achieve some result ..." there probably is.15:09
dcammuex = 10015:09
ubuntouristdcammue, ha-ha. Yes, true. But I was trying to make a point about how multiplication was repeated addition. ;-)15:10
ubuntouristLearn to search and read the Python Reference Manual. It can be hard to understand but it is a gold mine of15:11
ubuntouristfunctions and objects that will make your code so much better.15:11
gabrieldidn't get15:12
ubuntouristhttps://docs.python.org/3/py-modindex.html15:12
fkoikoi i15:12
ubuntouristhttps://docs.python.org/3/library/index.html15:12
*** fkoikoi has quit (Quit: Leaving)15:12
gabrielokay15:13
ubuntouristgabriel, didn't get what?15:14
*** mulbah has quit (Remote host closed the connection)15:15
ubuntouristAnyway, I don't really have anything to say.15:15
ubuntouristSo, if no one has questions, I guess we are done for today...15:16
tboimahokay thanks for today15:17
tboimahIt was real great15:17
tboimah*really15:17
ubuntouristWell, then. I will check in on Monday, but really, I won't have much to tell you. I'll just be available for questions.15:21
ubuntouristBye for now.15:21
*** ubuntourist has left #novawebdev (Leaving)15:21
*** gabriel has quit (Quit: Leaving)15:55
*** svaye has quit (Quit: Leaving)16:18
*** fkoikoi has quit (Ping timeout: 480 seconds)16:19
*** dcammue has quit (Ping timeout: 480 seconds)16:20
*** mulbah has quit (Ping timeout: 480 seconds)16:20
*** tboimah has quit (Ping timeout: 480 seconds)16:20
*** shmohamud has quit (Remote host closed the connection)20:28
*** shmohamud has quit (Ping timeout: 480 seconds)20:37
*** shmohamud has quit (Ping timeout: 480 seconds)20:51
*** shmohamud has quit (Ping timeout: 480 seconds)21:25
*** shmohamud has quit (Ping timeout: 480 seconds)21:36
*** shmohamud has quit (Ping timeout: 480 seconds)22:11
*** shmohamud has quit (Ping timeout: 480 seconds)22:31
*** shmohamud has quit (Ping timeout: 480 seconds)22:59

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