Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Like this? Share it with your network

Share

Class 6a ruby math

on

  • 2,145 views

In this second half of Class 6, we will investigate a few of Ruby's capabiities to complete advanced formatting and mathematical calculation.

In this second half of Class 6, we will investigate a few of Ruby's capabiities to complete advanced formatting and mathematical calculation.

Statistics

Views

Total Views
2,145
Views on SlideShare
2,139
Embed Views
6

Actions

Likes
0
Downloads
4
Comments
0

1 Embed 6

http://developer.innovait.ca 6

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Class 6a ruby math Presentation Transcript

  • 1. Math Hacks in Ruby
    Class 6a – Ruby Math
  • 2. Introduction
    Ruby Basics
    Puts
    Gets
    Some basic math operations
    “+”, “-”, “*”, “/”
    Formatting and Advanced Math
    Line formatting (right/left justification, centering)
    Exponents, roots, the Math Object
  • 3. Agenda
    Review the Assignment 3 solution
    Add formatting
    to make interface and output more attractive
    To make interface more intuitive
    To make output more functional
    Advanced Math
    Exponents and Roots
    Absolute and Modulus
    Math::pi and rand
  • 4. Formatting
    Example – our class average assignment
    Preferred format/ line length of 60
     StudentMarks
    Sam 75
    Susan 78
    George 87
    Anne 92
    Joe 67
    _____ _____
    Average 76.5
  • 5. Demonstration
    IPO
    Input
    Processing
    Output
    Code
  • 6. Ruby Math: Exponent and Root
    Exponent
    Notation a**b
    a to the power of b
    Example
    Root
    Using Math Object
    Math.sqrt(val)
    Using math formula
    x**0.5
  • 7. Ruby Math: Absolute & Modulus
    Absolute
    Notation a=x-y.abs
    Example
    Modulus (gizinta, what’s left?)
    Notation a=x%y
    Example: Kids Inc. Summer Camp
  • 8. Ruby Math: Random & Pi
    Random
    Use: rand(max_val)
    Result is zero based
    Example
    Math:Pi
    Use Math::Pi*(val)
    Example: Volume of a cylinder
    IPO first?
  • 9. Summary
    Exponent (a**b)
    Root (sqrt or a**b/c.to_f)
    Absolute (abs)
    Modulus (a%b)
    Random (rand(x))
    Pi (Math::PI)
  • 10. Project 1: Calculator/Converter
    Objectives
    Apply mathematical formulas to real problems
    Apply a programmatic approach to a solution
    Apply basic ruby mathematical operations
    Apply basic ruby formatting
    Grading – in 3 parts
    Due Date: Week of Nov 15
    Next Week: Part of class for project work, problems, challenges, ideas