SlideShare a Scribd company logo
ACM init() 
Day 1: October 23, 2014
Kelly
Akshay
Daniel
Welcome! 
Welcome to ACM init(), a Computer Science class for 
beginners. 
Over the course of the next few weeks, you will be 
learning Ruby, a flexible, widely used programming 
language.
About the Course 
• This course assumes no prior programming 
experience 
• Hosted by the Association for Computing 
Machinery (ACM) 
• This course will be teaching you how to code in 
a language called Ruby 
• NO EXAMS!!!!
ACM Init() lesson 1
Resources for You 
Our website: acm.cs.ucla.edu 
Slides: slideshare.net/uclaacm 
Facebook: https://www.facebook.com/groups/717821374976381/ 
Want to contact us? 
Kelly: omalleyk@ucla.edu 
Daniel: dduan@yahoo.com 
Akshay: akshaybakshi@ucla.edu
Remember: If you 
have any questions, 
ask! Chances are 
someone else has the 
same question and is 
hesitant to ask.
If you don’t 
understand 
something, it is more 
important that you 
learn it than we finish 
everything today.
Why Computer Science? 
• Computer Science is a fast 
growing field with a surplus of 
high-paying jobs 
• Learning a programming 
language will enhance your 
resume and make you more 
desirable to companies 
• Furthermore, learning how to 
code will better your problem-solving 
skills and help you in 
all of your classes 
Source: http://www.ovrdrv.com/blog/making-computer-science-cool/
The numbers speak for 
themselves... 
Source: http://code.org/promote
Who knows what a 
programming 
language is?
Why Learn Ruby? 
• Ruby is easy to read and use, 
and is considered to be one of 
the best first languages to 
learn 
• Ruby developers are in high 
demand 
• Ruby is useful -- Ruby on Rails 
is one of the most popular 
web programming platforms in 
the startup community
Let's Get Started!
Computing the Factorial of a 
Number 
• Factorial: written as #! 
• For example, 5! is 5*4*3*2*1 = 120 
• I wrote a simple program called fact.rb that will 
compute the factorial for us 
• Let's try it out! Compute the factorial of 6. 
• ruby fact.rb 6
ACM Init() lesson 1
A Bit About Computers 
Computers think in 0s and 1s. Everything that you input into a 
computer gets stored in this manner. For example: 
You don't need to know how this conversion works. However, the concept is 
important because it is the reason why we need programming languages. 
Human-readable programming languages go through a process that 
converts them to binary, which can be understood by the compter.
How do we make our code 
work? 
Ruby is what is called an interpreted language. That means 
that the computer runs one line of code at a time. 
We can't just type code into a word document and hope it will 
magically do something. We need an interpreter that will help 
the computer understand our code.
koding.com 
koding.com is an easy way to run code that requires no 
downloading or storage space.
Enter your email and choose a username
This is what you should see once you log in.
Let's learn how to run a program. Type 
puts "I love computers!" 
into the top window in Koding.
Now, save the file. Select the option Save As.
Select a directory to save the file in. I choose a directory I 
created called ACMclass. Now, name the file myfirstfile.rb
Press Save
The file has been saved! Now, let's run it.
First, we need to make sure we are in the right directory. Type 
in cd 'theDirectoryYouSavedIn' then press Enter. 
It changed!
Now we can access our file! Time to run it. Type in 
ruby myfirstfile.rb 
This tells Koding that we are about to run a Ruby file.
Press Enter, and it runs! The screen printed out "I love 
computers!"
Time to start learning 
Ruby.
Data Types 
• Why? Say "five". Did you say 5 or five? 
• There are three main data types in Ruby: numbers, 
booleans, and strings. 
• Numbers: Exactly what it sounds like. (example: 1, 
400, 45.7) 
• Booleans: Something that is either true or false. 
• String: A word or phrase. (example: "Hello World!")
Variables 
We can store these data types in variables so we can 
come back and use them again later. 
Take a look: 
Now if we want to use any of these stored values 
again all we have to do is type the variable name!
Math 
There are six main math operations we are going to go over 
today.
+ - * / 
• + is addition 
• - is subtraction 
• * is multiplication 
• / is division 
• These work the same way 
your calculator does -- no 
surprises here
** and % 
• ** (exponent) raises one 
number to the power of 
another. For example, 2**3 
would be 8 because 2*2*2=8 
• % (modulus) returns the 
remainder of division. For 
example, 25%7 would be 4 
because 25/7 is 3r4.
Printing to the Screen 
There are two main commands that will allow you to 
print text out to the screen. 
These commands are 'puts' and 'print'.
'puts' vs 'print' 
The 'print' command just takes whatever you give it and prints 
it to the screen. 
'puts' (for "put string") is slightly different: it adds a new (blank) 
line after the thing you want it to print.
'puts' vs. 'print' example
String Methods 
• Remember, a string is is word or a phrase. Ruby 
provides several methods for us to make it easier to 
use strings 
• '.length' : finds the length of the string 
• '.reverse' : reverses the string 
• '.upcase' : changes all letters to uppercase 
• '.downcase' : changes all letters to lowercase
String Methods Example
We've covered all the Ruby syntax 
we're going over for today. Now, 
let's learn a bit about writing good 
code.
Comments 
What if you write a really long program then not look at it for a 
year? What if you're working on a project with other people 
and you have to share your code? 
We need a way to explain what is going on in the programs we 
write. 
The solution? Comments.
How to add comments 
Comments are a tool we have to communicate what our code 
is intended to do. 
To put a comment in your code all you have to do is type 
# your comment here 
Anything that comes after '#' and is on the same line will be 
ignored when the code is being run.
Comment Example
Naming Conventions 
• Remember that we can give values to variables so we can use the same 
value again later 
• We can name these variables whatever we want 
• Doesn't it make sense to give variables descriptive names? 
• Some naming rules: 
• Separate words with underscores '_' 
• Do not start a variable name with a number, symbol, or uppercase 
letter 
• The variable name should describe what the variable contains or will 
be used for
Naming Examples
What we covered 
• A little bit about Ruby 
• How to use Koding 
• Data types: numbers, string, and booleans 
• Variables 
• Math 
• How to print to the screen 
• String methods 
• How to write good code
Any questions? 
Office Hours will be right after the 
class every time.

More Related Content

PDF
Intro to javascript (6:27)
David Coulter
 
PPTX
SCCI'14 - Appsplash [2] Code!
Essam Hassan
 
PDF
Object Relational Mapping with Dapper (Micro ORM)
Muhammad Umar
 
PDF
Effective text editing with vim
xprayc
 
PDF
C++ 11 Style : A Touch of Class
Yogendra Rampuria
 
PDF
Backend roadmap
wassimbenfatma1
 
PPTX
Week 8 intro to python
brianjihoonlee
 
PPTX
2018-09 - F# and Fable
Eamonn Boyle
 
Intro to javascript (6:27)
David Coulter
 
SCCI'14 - Appsplash [2] Code!
Essam Hassan
 
Object Relational Mapping with Dapper (Micro ORM)
Muhammad Umar
 
Effective text editing with vim
xprayc
 
C++ 11 Style : A Touch of Class
Yogendra Rampuria
 
Backend roadmap
wassimbenfatma1
 
Week 8 intro to python
brianjihoonlee
 
2018-09 - F# and Fable
Eamonn Boyle
 

Similar to ACM Init() lesson 1 (20)

PDF
Rubykin
Trần Thiện
 
PPTX
Ruby -the wheel Technology
ppparthpatel123
 
PPTX
Ruby
Alaa Afifi
 
PDF
CPAP.com Introduction to Coding: Part 1
johnnygoodman
 
PDF
Ruby training day1
Bindesh Vijayan
 
PDF
Ruby tutorial
knoppix
 
PDF
Intro to Programming (1)
Justin Reese
 
PDF
ACM init() Spring 2015 Day 1
UCLA Association of Computing Machinery
 
PDF
06 ruby variables
Walker Maidana
 
PDF
Ruby Presentation
platico_dev
 
PDF
00 ruby tutorial
Walker Maidana
 
PDF
Ruby_Basic
Kushal Jangid
 
PPTX
Ruby Programming Language - Introduction
Kwangshin Oh
 
PDF
Ruby An Introduction
Shrinivasan T
 
PPTX
Ruby introduction part1
Brady Cheng
 
PDF
APU RoR Workshop Series #1 - Introduction to Programming
Jimmy Ngu
 
PPTX
Intro to Ruby/Rails at TechLady Hackathon
kdmcclin
 
PDF
20 ruby input output
Walker Maidana
 
PPTX
Ruby Basics
NagaLakshmi_N
 
Rubykin
Trần Thiện
 
Ruby -the wheel Technology
ppparthpatel123
 
CPAP.com Introduction to Coding: Part 1
johnnygoodman
 
Ruby training day1
Bindesh Vijayan
 
Ruby tutorial
knoppix
 
Intro to Programming (1)
Justin Reese
 
ACM init() Spring 2015 Day 1
UCLA Association of Computing Machinery
 
06 ruby variables
Walker Maidana
 
Ruby Presentation
platico_dev
 
00 ruby tutorial
Walker Maidana
 
Ruby_Basic
Kushal Jangid
 
Ruby Programming Language - Introduction
Kwangshin Oh
 
Ruby An Introduction
Shrinivasan T
 
Ruby introduction part1
Brady Cheng
 
APU RoR Workshop Series #1 - Introduction to Programming
Jimmy Ngu
 
Intro to Ruby/Rails at TechLady Hackathon
kdmcclin
 
20 ruby input output
Walker Maidana
 
Ruby Basics
NagaLakshmi_N
 
Ad

More from UCLA Association of Computing Machinery (15)

PDF
UCLA ACM Spring 2015 general meeting
UCLA Association of Computing Machinery
 
PDF
UCLA Geek Week - Claim Your Domain
UCLA Association of Computing Machinery
 
PDF
Intro to Hackathons (Winter 2015)
UCLA Association of Computing Machinery
 
PDF
An Introduction to Sensible Typography
UCLA Association of Computing Machinery
 
PPTX
Building a Reddit Clone from the Ground Up
UCLA Association of Computing Machinery
 
PDF
ACM Fall General Meeting
UCLA Association of Computing Machinery
 
PDF
ACM Teach - Hackathon Tips and Tricks - Spring 2014
UCLA Association of Computing Machinery
 
PDF
ACM General Meeting - Spring 2014
UCLA Association of Computing Machinery
 
UCLA ACM Spring 2015 general meeting
UCLA Association of Computing Machinery
 
UCLA Geek Week - Claim Your Domain
UCLA Association of Computing Machinery
 
Intro to Hackathons (Winter 2015)
UCLA Association of Computing Machinery
 
An Introduction to Sensible Typography
UCLA Association of Computing Machinery
 
Building a Reddit Clone from the Ground Up
UCLA Association of Computing Machinery
 
ACM Fall General Meeting
UCLA Association of Computing Machinery
 
ACM Teach - Hackathon Tips and Tricks - Spring 2014
UCLA Association of Computing Machinery
 
ACM General Meeting - Spring 2014
UCLA Association of Computing Machinery
 
Ad

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Software Development Methodologies in 2025
KodekX
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 

ACM Init() lesson 1

  • 1. ACM init() Day 1: October 23, 2014
  • 5. Welcome! Welcome to ACM init(), a Computer Science class for beginners. Over the course of the next few weeks, you will be learning Ruby, a flexible, widely used programming language.
  • 6. About the Course • This course assumes no prior programming experience • Hosted by the Association for Computing Machinery (ACM) • This course will be teaching you how to code in a language called Ruby • NO EXAMS!!!!
  • 8. Resources for You Our website: acm.cs.ucla.edu Slides: slideshare.net/uclaacm Facebook: https://www.facebook.com/groups/717821374976381/ Want to contact us? Kelly: [email protected] Daniel: [email protected] Akshay: [email protected]
  • 9. Remember: If you have any questions, ask! Chances are someone else has the same question and is hesitant to ask.
  • 10. If you don’t understand something, it is more important that you learn it than we finish everything today.
  • 11. Why Computer Science? • Computer Science is a fast growing field with a surplus of high-paying jobs • Learning a programming language will enhance your resume and make you more desirable to companies • Furthermore, learning how to code will better your problem-solving skills and help you in all of your classes Source: http://www.ovrdrv.com/blog/making-computer-science-cool/
  • 12. The numbers speak for themselves... Source: http://code.org/promote
  • 13. Who knows what a programming language is?
  • 14. Why Learn Ruby? • Ruby is easy to read and use, and is considered to be one of the best first languages to learn • Ruby developers are in high demand • Ruby is useful -- Ruby on Rails is one of the most popular web programming platforms in the startup community
  • 16. Computing the Factorial of a Number • Factorial: written as #! • For example, 5! is 5*4*3*2*1 = 120 • I wrote a simple program called fact.rb that will compute the factorial for us • Let's try it out! Compute the factorial of 6. • ruby fact.rb 6
  • 18. A Bit About Computers Computers think in 0s and 1s. Everything that you input into a computer gets stored in this manner. For example: You don't need to know how this conversion works. However, the concept is important because it is the reason why we need programming languages. Human-readable programming languages go through a process that converts them to binary, which can be understood by the compter.
  • 19. How do we make our code work? Ruby is what is called an interpreted language. That means that the computer runs one line of code at a time. We can't just type code into a word document and hope it will magically do something. We need an interpreter that will help the computer understand our code.
  • 20. koding.com koding.com is an easy way to run code that requires no downloading or storage space.
  • 21. Enter your email and choose a username
  • 22. This is what you should see once you log in.
  • 23. Let's learn how to run a program. Type puts "I love computers!" into the top window in Koding.
  • 24. Now, save the file. Select the option Save As.
  • 25. Select a directory to save the file in. I choose a directory I created called ACMclass. Now, name the file myfirstfile.rb
  • 27. The file has been saved! Now, let's run it.
  • 28. First, we need to make sure we are in the right directory. Type in cd 'theDirectoryYouSavedIn' then press Enter. It changed!
  • 29. Now we can access our file! Time to run it. Type in ruby myfirstfile.rb This tells Koding that we are about to run a Ruby file.
  • 30. Press Enter, and it runs! The screen printed out "I love computers!"
  • 31. Time to start learning Ruby.
  • 32. Data Types • Why? Say "five". Did you say 5 or five? • There are three main data types in Ruby: numbers, booleans, and strings. • Numbers: Exactly what it sounds like. (example: 1, 400, 45.7) • Booleans: Something that is either true or false. • String: A word or phrase. (example: "Hello World!")
  • 33. Variables We can store these data types in variables so we can come back and use them again later. Take a look: Now if we want to use any of these stored values again all we have to do is type the variable name!
  • 34. Math There are six main math operations we are going to go over today.
  • 35. + - * / • + is addition • - is subtraction • * is multiplication • / is division • These work the same way your calculator does -- no surprises here
  • 36. ** and % • ** (exponent) raises one number to the power of another. For example, 2**3 would be 8 because 2*2*2=8 • % (modulus) returns the remainder of division. For example, 25%7 would be 4 because 25/7 is 3r4.
  • 37. Printing to the Screen There are two main commands that will allow you to print text out to the screen. These commands are 'puts' and 'print'.
  • 38. 'puts' vs 'print' The 'print' command just takes whatever you give it and prints it to the screen. 'puts' (for "put string") is slightly different: it adds a new (blank) line after the thing you want it to print.
  • 40. String Methods • Remember, a string is is word or a phrase. Ruby provides several methods for us to make it easier to use strings • '.length' : finds the length of the string • '.reverse' : reverses the string • '.upcase' : changes all letters to uppercase • '.downcase' : changes all letters to lowercase
  • 42. We've covered all the Ruby syntax we're going over for today. Now, let's learn a bit about writing good code.
  • 43. Comments What if you write a really long program then not look at it for a year? What if you're working on a project with other people and you have to share your code? We need a way to explain what is going on in the programs we write. The solution? Comments.
  • 44. How to add comments Comments are a tool we have to communicate what our code is intended to do. To put a comment in your code all you have to do is type # your comment here Anything that comes after '#' and is on the same line will be ignored when the code is being run.
  • 46. Naming Conventions • Remember that we can give values to variables so we can use the same value again later • We can name these variables whatever we want • Doesn't it make sense to give variables descriptive names? • Some naming rules: • Separate words with underscores '_' • Do not start a variable name with a number, symbol, or uppercase letter • The variable name should describe what the variable contains or will be used for
  • 48. What we covered • A little bit about Ruby • How to use Koding • Data types: numbers, string, and booleans • Variables • Math • How to print to the screen • String methods • How to write good code
  • 49. Any questions? Office Hours will be right after the class every time.