Tuesday, May 28, 2024

M2 Programming Fundamentals

 Greetings,

For, while, if, else, are among some of the most fundamental of operators within Python. Fundamentals are the name for this week. Looking at types of objects in this object-oriented language, and applying methods, arguments, and parameters to loops, conditional statements, and iterable variables. 

In one four-part script I have dissected my name, fixed and played a random number generation game, filled a list with random numbers and then extracted a chosen number from it. This is all executed by beginning to understand how the methods, functions, and variables interact within Python. 

Modules, variables, then code blocks, within them, methods or functions deal out commands with which the language operates. While loops and for loops, work to iterate over a block of code, affecting a variable in particular ways. Methods work to augment an object through prescribed parameters, whereas functions are executed against the variable object input as the parameter. 

Ultimately, through this week I saw that because I am unpracticed it can be significantly time consuming to get a block of code to function as intended. A mere typo, miscapitilization, forgotten quotation or parenthesis can all cause the code not to work. While loops were particularly challenging, especially when working with if / else and break statements. These provide condition trees or stopping points for iterative code, that if executed wrong, could execute indefinitely. 

Below is a simple output, but it is one running of the 4 section script that was created this week. 


I could potentially try to add more break lines in the output to show the more clear delineation between results. But suffice it to say, you see my name at the top, stripped from my full name. Then you see the game of chance played by 8 players. From there the script generates 20 random integers between 0 - 10, populating a list. And from that list, lucky number 7's are stripped out and the new list provided. 

The most satisfying part came from putting all 4 separate pieces together in one script and hitting run. And all of the outputs generate without issue! Sooo satisfying! 


v/r

Brandon

No comments:

Post a Comment

Special Topics - Mod 3 - Lab 6 - Aggregation and Scale

 Hello and Welcome back!  My how time has flown. It has almost been 8 weeks, and 6 different labs. There have been so many topics covered in...