Mike Dane is a software developer, teacher at a university level, and makes extensive youtube videos on python, Javascript, and other programming languages. He additionally hosts videos on Giraffe Academy.
Mike Dane goes on to say python is one of the easiest programming languages to learn, as there are little syntax errors. You basically just type what you want to say, and python performs it for you (the computer executes the instructions that we give it). The more complex the instructions, the more complex the task being carried out. It executes lines of code in order (top to bottom).
Type in name of variable, and value of variable in quotation marks (separate variable name with an underscore)
Use plus signs to attach your statement to your variable
Anita Whitehill taught one way how to use variables in Python, while Mike Dane showed me another, and explained why it is important.
-Variables are very useful, because instead of changing a variable in multiple lines, you only have to change the variable value itself. You would no longer have to look through each line and change it manually, so it's extremely efficient and time saving if you have thousands of lines of code and need to change a value.
(For example, if you have a character named John in a story, and need to change the name to Mark, instead of manually typing the name throughout the entire code, you can create a variable called “character_name”, and would only have to change the name in that line of code.)
When you change the value of a variable midway through a sequence, the value changes for that variable from now on, but the original value stays the same above.
-Can make code uppercase or lowercase in this example using functions (function=a block of code that performs a specific operation)
-isupper is asking python whether or not the string is entirely upper case, and will respond with true or false (true if entirely upper case or false if not).
-If you want to see how many characters are in your string, type in len
-If you want to know a specific character in the string, use [ ]. If you want to know the first, character, use [0]. It does start at zero, many other programming languages do too.
-Now, let's say you want to do the opposite, and want to find where a specific character is, use your variable, then .index().
-If you need to replace a word, use .replace(:”The word you want to replace”, “the new word you want to replace it with”)
List Functions
Tuples
A type of data structure, a "container" where we can store different values, but are different from lists. A list uses square brackets , tupples use parentheses
Lists can change, and you can assign different values. Tupples, can not change. You use tubbles for data that will never change. Coordinates are good for tupples, as they do not change.
Functions
A collection of code that performs a specific task.
Return Statement
If Statements
Responds to the information given. When something is not defined, check to see if it is in parentheses. Boolean variables are true and false, so let's do a boolean of statement.
Dictionaries
Allows you to store information in key value pairs. You can create a bunch of key value pairs, and when you want to access a key piece of information in the dictionary, you can refer to it by its key. The word is the key. The value is the definition. Use { } when creating dictionaries. Make sure to name dictionary first. You need to make sure you have different keys or words in your dictionary, or else it will not work. When you want to access a specific key, refer to the dictionary by name, use [ }, and print the key name. You can also use .get(“Name of key”)
When you have a key that is not mappable to any value, you type in “not a valid key”. If you type in a key that is mappable and also type “not a valid key”, you will just get the definition of that key, as long as it is in the dictionary. However, if it is not in the dictionary, it will automatically say “not a valid key”, as it is not mappable.
While Loop
Keeps running the code unless stopped by a command given by the user