Trying to learn something new…:)
A programming language is a set of rule used to create and execute commands on a computer. Python is a high level/very precise scripting language for general purpose programming, for building web technologies, software, conduct data analysis, power Instagram. Python compiles down to C, which compiles down to Assembly, which compiles down further to the lowest, bite level of 0’s and 1’s.
Talk to Me Like I’m 5
Python script works top down, as an interpreter language. Working in IDE, terminal on mac, The steps: 1) Use your Command Line to start the python engine (call up your user directory, AKA ~). Then, we built a game, where the computer executes a command you’ve scripted in Sublime Text, the engine works line by line, once finished, python exists.
$ python <name.file.py>
Even if I can never code, I like knowing the symbols and acronyms and things. A brief demo of my new found conquests:
- “~” is shorthand for your home directory (user directory)
- “CD” is “Change Directory”
- “LS” is “List,” for example, to list everything in a current directory (file)
- “.” is “current directory”
- “..” is “parent directory”
- “print” is to “print the value of a variable”
- Things inside () are called “arguments”
- ! is said as “bang!”
- RTFM is shorthand for “read the effing manual”
There are variables, symbolic names associated with a variable-held in memory in some form of character. Variables are mutable and can be changed overtime. In your sublime text file with the script you will run, set your variable, apples = 5, and then tell the computer what to do with it, print apples, then save the file. Open your terminal, type “$ python filename.py”, hit enter, and the computer will “print” the number “5.”
Modules are the means of organizing python; modules make python valuable. Code can be reused. Modules sounded a lot like downloading a palette of stencils or fonts for Photoshop or Illustrator. Something open source, pre-existing, and there to save time coding something complex by advantageously applying the code built by another’s industry and creativity. The Python download comes with standard modules and users can also download modules on the internet, such as “scipy” and “numpy.” The easiest way to find new modules is Google.
It got very complicated with functions, the routine defined in sublime text. This routine can be used over and over again and is constructed by stringing together commands.
It’s easier to look at a line of code as a user might read a sentence in English. Once the user can understand that variables are the nouns and functions are the verbs, it’s much easier for the brain to latch onto reading a line of code and become familiar with writing.
>, <, = =, <=, >=, !=
There are “types” in python: integer (int), floats (float), strings (str), and Boolean (bool). Types can be compared: >, <, = =, <=, >=, !=
Conditionals are expressions that evaluate to true or false using a keyword. Conditionals precede a block of code to control execution and can be chained together to make complex decisions. For example:
go to the store
if (has_eggs == True):
Buy 12 eggs
elif (has_eggs_beaters == true)
This is to say “only if the store as eggs, buy 12 eggs” or if the store has eggs (true) then execute everything that follows below that is indented. In this case, only the indented line “buy 12 eggs.”
“elif” is shorthand for “If/Else”, a short circuit that says “stop execution if this meets your criteria.”
Loops are a means by which to execute code repeatedly. They allow to define a stopping condition. There are two kinds! “For” which is a defined number of time for code to loop. “While” loops could go on forever. You have to identify which behavior you’d like the code to activate.
Color me drunk with power
It’s was such an interesting workshop! Definitely check out General Assembly courses. Very worthwhile. The teacher was really fantastic and I hope I’ve gotten everything correctly in this post. He spoke fast! I’d really like to learn and I think Python is one easy way to learn programming because it reads like English.
References & Tutorial Resources
- General Assembly, Intro to Python
- Boston Python Meetup