Hello everyone, I hope you are having a fantastic day! I took a brief hiatus from posting due to work related obligation, but I am ready to get back to posting. Today I wanted to keep this short and sweet. I will be talking about tuples. Now what is a tuple you might ask? A…
Author: admin
Post #44 (Python Programming) – Global variables
Within python’s functions any variables defined inside the function can only be used within that function, the function can use variables defined outside of it. Code: a = 3 def function(): print(a) function() Result: 3 Here is an example of how the variable within the function cannot influence the outside variable, it’s as if they…
Post #43 (Python Programming) – Parameterized functions in Python
As I discussed in my last post you can actually use multiple parameters within the functions you create, it is important to note that the parameters within a function are essentially like variables that can only be used within the function they are declared in. You can even reuse the name of parameters within your…
Post #42 (Python Programming) – Functions in python
Let’s say you have a piece of code that is repeated multiple times in your program like so. Code: print(“I have a message”) print(“I have a message”) print(“I have a message”) Now if you want to change your message you will need to change each instance of it, you can avoid this by creating a…
Post #41 (Python Programming) – Lists in lists, the power of matrices
In python believe it or not you actually have the power to put lists within lists. How would one do that? You can use the following code list = [1, 2, 3, 4, 5] for i in range(8): list_2 = [1, 2, 3, 4, 5] list.append(list_2) print(list) The above code creates a list within a…
Post #40 (Python Programming) – More options with lists and the use of in and not in.
Let start off by taking a look at the following code. list = [1, 2, 3, 4, 5] list_2= list del list[1] print(list_2) Now the following code should return the results [1, 2, 3, 4, 5] right? Wrong, the code returns [1, 3, 4, 5] This is because you are setting the list equal to…
Post #39 (Python Programming) – Python’s bubble sort algorithm for lists
In python you need to be able to sort lists right? Well one simple, although inefficient, way to do this is with the bubble sort algorithm. How this works is it compares two elements in the list 1,2 then 2,3, then 3,4 and so on and compares them. If one is bigger than the other…
Post #38 (Python Programming) – Lists in python
Lists in python are quite powerful, it is essentially a variable that can hold multiple values Code: list = [1, 2, 3, 4 ,5] print(list) Result: [1, 2, 3, 4, 5] You can also call specific items in a list as well as append an item to the append end of the list, the lists…
Post #37 (Python Programming) – The power of loops in python
There are two types of loops in python for loops and while loops. Here is a brief explanation of both and then an example. For the for loop the range command allow you to determine how long the loop will last or iterate through several values, start is where the value will begin, end is…
Post #36 (Python Programming) – Conditionals in python
Python allows you to run code if a certain condition is true, you can also use else and elif as well for alternate conditions. The following code is an example of conditionals. It is also important to note that == checks if two values are equal to each other while = assigns a value to…