Your SlideShare is downloading. ×
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

CPAP.com Introduction to Coding: Part 1

297

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
297
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
1
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction To CodingJohnny Goodman
  • 2. We Tried To Get Jeremy To TeachBut...3:49:17 PM Ashley Thompson: I will work on Jeremy.3:49:30 PM Ashley Thompson: He told me to contact hisagent… which isnt a "no".
  • 3. ● You will see coding● You will learn basic concepts● You will know where to go to practice● You will know where to go with questionsWhat Todays Session Will Do
  • 4. ● Teach you ever more advanced concepts● Teach you how to code on your local box● Teach you how to leverage existing code● Build stuff that is day to day usefulWhat Future Sessions Will Do
  • 5. There are too many concepts to pack into anhour.Were going to go in smaller chunks.We are "eating our veggies" today by learning alot of concepts which will relate later.No SQL Today
  • 6. What Is Coding?Playing with numbers and words until they areuseful, then saving them and reusing them.
  • 7. Computers vs. HumansComputers are like this 10101101010101.Humans are like this "hi! k. thx, bye"This is "hi! k. thx, bye" in computer:011010000110100100100001001000000110101100101110001000000111010001101000011110000010110000100000011000100111100101100101
  • 8. Code Like A HumanI do not want to write a bunch of 1s and 0s.I need a coding language to take my Englishand turn it into 1s and 0s for me.Many good languages do this.I like Ruby.
  • 9. Where Do I Go To...Ruby?To punch stuff in and see what Ruby does:● http://tryruby.org/To go through a structured, type it in course:● http://www.codeacademy.com/tracks/ruby
  • 10. Where Do I Go To...Ruby?To ask questions to other coders:http://stackoverflow.com/questions/tagged/ruby
  • 11. Todays Coding Concepts● Words and Numbers● Storage● Comments● Running Code● Comparisons● Arrays● Commands On Variables● If/Else Statement
  • 12. WordsIn code, you store words in Strings.Examples:● "I am a string because I am words"● "I am also a string"● "jello"Quote signs tell the computer that its a String.
  • 13. NumbersIn code, you store numbers in Integers.Examples:● 5● 555● 102125No quote strings needed.
  • 14. Youll need to do three things to store stuff:● To make up a name● Type an equals sign● Type a word or numberExample:save_me = "this will be stored to save_me"Storing Values
  • 15. pudding = "word or number"The made up name pudding is commonlycalled a variable.johnny = "hi hi"carolyn = "bye bye"johnny and carolyn are variables.Storing Values
  • 16. Lets store "my words" to the my_value variable:my_value = "my words"Display that variable with the puts command:puts my_value=> "my words"Storing Values
  • 17. Examples of how to store Strings:words = "my words"oscar = "grouch"johnny = "occasionally grouchy"Storing Values
  • 18. Examples of how to store Integers:total = 5 + 4another = 10 - 3last = 42 * 125Storing Values
  • 19. Another Example:pudding = "tasty goodness"puts pudding=> "tasty goodness"This is because we stored "tasty goodness" topudding, then said "print the value of pudding"Storing Values
  • 20. Storing ValuesYou can use variables just as if they were theoriginal value they store.Example:one = 1two = 2three = one + twoputs three=> 3
  • 21. Storing ValuesYou can overwrite variables with new datavar = "this wont last"puts var=> "this wont last"var = "overwrite the current data"puts var=> "overwrite the current data"
  • 22. Storing ValuesYou can store variables to other variablesNumber Example:one = 1also_one = oneputs also_one=> 1
  • 23. Comments tells the computer to skip the line.The symbol for a comment is the # sign.Here are what comments look like:#var1 = "test"#my comment line will be skipped#var1 = "test2" a third skipped lineComments
  • 24. Comments are used by coders to add context,warning and overviews of code#This will store "hi" to myvarmyvar = "hi"#This will store 2 + 2 to the variable fourfour = 2 + 2Comments
  • 25. To run code:1. Go to the command line2. Type in Ruby code3. Get a response from RubyRunning Code, The Command Line
  • 26. Where do you find command lines?1. Inside tutorials like codeacademy/tryruby2. On your computer, if ruby is installed (irb)3. On other computers where ruby is installed,like if IT configures one and gives you credsRunning Code, The Command Line
  • 27. Lets move to the command line and runexamples weve worked on so far.1. Johnnys command line2. The code academy tutorialRunning Code, The Command Line
  • 28. If Ruby is installed on your computer:1. Create a file.2. Make it end in .rb (instead of .doc, .txt, etc)3. Navigate to the files directory via commandline4. $>ruby my_file.rbRunning Code, From A File
  • 29. If you have downloaded a Ruby focused texteditor, you can also load and run the file rightfrom the GUI.Lets pause for examples.Running Code, From A File
  • 30. The == sign tells us if two values are equal:1 == 1=> true1 == 2=> falseComparisons
  • 31. one = 1two = 2one == 1=> trueone == two=> falseComparisons
  • 32. Welcome Back
  • 33. ArraysArrays let you store a group of the same data toone variable.Some examples of groups:people = [johnny, robert, nelson, jayson]animals = [sloth, toad, zebra]presidents = [clinton, bush, obama]
  • 34. ArraysTo get all that data back out$> people=> ["johnny", "robert", "nelson", "jayson"]$> puts peoplejohnnyrobertnelsonjayson
  • 35. ArraysTo get only one element out, you need to learna trick...Arrays are zero indexed.Meaning you count and reference the elementsfrom 0.
  • 36. Arrays0 1 2 3[johnny, robert, nelson, jayson]Examples:people[0] => johnnypeople[2] => nelson
  • 37. Arrays
  • 38. Commands On VariablesFirst, lets just look at it:people=> [johnny, robert, nelson, jayson]people.count=> 4
  • 39. Commands On VariablesYou can call commands on variables.Structure:<variable>.<command>Example:people.count=> 4
  • 40. Commands On VariablesHeres another one:people=> ["johnny", "robert", "nelson", "jayson"]people.reverse=> ["jayson", "nelson", "robert", "johnny"]
  • 41. Commands On VariablesIf you want to see all the commands you areallowed to call on a given variable, use themethods commandpeople.methods=> [:inspect, :to_s, :to_a, :to_ary, :frozen?,:==, :eql?, :hash, :[], :[]=, :at, :fetch, :first, :last, :concat, :<<, :push, :pop, :shift, :unshift, :insert, :each, :each_index, :reverse_each, :length, :size, :empty?, :find_index, :index, :count]
  • 42. More Helpful Array CommandsAdd a new person to people:people.push(jenny)=> ["johnny", "robert", "nelson", "jayson","jenny"]
  • 43. More Helpful Array CommandsRemove the last person from people:people.pop=> "jenny"people=> ["johnny", "robert", "nelson", "jayson"]
  • 44. If/Else StatementA variables value can be used as a decisionpoint that determines which code to run next.You do this using an if / else statement.
  • 45. If/Else Statement, StructureIf / Else Structure:if variable == <value>#run this code if trueelse#run this code if falseend
  • 46. If/Else Statement, Example 1one = 1if one == oneputs "true, one equals one"elseputs "false, one does not equal one"end=> "true, one equals one"
  • 47. If/Else Statement, Example 2one = 1if one == 2puts "true, one equals one"elseputs "false, one does not equal one"end=> "false, one does not equal one"
  • 48. Command Line ExamplesTime for command line examples...
  • 49. The Big PictureA web page does this:1. Queries a database and stores data toarrays2. Loops through the arrays3. Manipulates elements of the arrays4. Displays results to the user
  • 50. The Big PictureYou know:1. How to create and store variables2. How to manipulate variables with commands3. About arrays4. How to decide which code to run via IF/Else
  • 51. The Big PictureYou do not know:1. How to loop through arrays2. How to wrap code in reusable methods3. How to wrap methods in reusable classes4. How to use other peoples code
  • 52. The Big PictureOnce you fill those holes in, you have the coreconcept of how to build any web page.You can also look at a web page and say "Iknow how they did that" in a conceptual way.
  • 53. The Big PictureCode is slowly automating everything.Code is the new universal language.Nearly every other skill will eventually be codeinvolved or code dependant.Be in the "can code" part of the work force.
  • 54. Next Time● Loops● Arrays + Loops● Classes and Methods● Connecting To Databases● Looping Through Database Query Results● Using Other Peoples Code In Yours

×