python tutorial

in the python tutorial i learned about booleans. this is an example of boolean values.
i used it here to find out if something was true of false. for example, 10 > 9, this is true. 10 = 9 this is false. we can use this to create different outcomes based on is something is true or false. for example, you could tell the program that x = 5 and y = 10 and if one of those numbers are higher than the other, we can program is to give a unique response, so if x = 5 and y = 10 it would "YES" but if at any point x becomes higher than y we could make it respond "NO"

some of the simpler stuff has taught me about includes things like variables and creating text, as well as adding comments to lines of code to keep myself organized.

one thing i found a little more confusing were data types, and if I'm going to be honest, I don't think I have fully understood yet.

I have also learned about list which are a really cool and easy way to store multiple items in a single variable. for example.
thislist = ["apple""banana""cherry"]
print(thislist)

You can see that the variable "thisList" holds multiple different messages within it.



something very similar to list are sets. sets pretty much do the same thing that list which is allowing you to store multiple items in a single variable, however there are some slight key differences. for example, sets are unchangeable, and are also unordered therefore they will appear in random order and not the order you typed it out in. lastly sets don't allow duplicates, meaning that is the same item is in a set twice it will only show one of them.

example of sets:


in between the flexibility of list and sets we have tuples. tuple is ordered unchangeable and allow duplicates. to make is simpler here is a list of the differences I've learned about them.

list: ordered, changeable, allow duplicates.
tuples: ordered, unchangeable, allow duplicates.
sets: unordered, unchangeable, don't allow duplicates.






Comments

Popular posts from this blog

Monday, dec 11 2023