Giter Club home page Giter Club logo

padawan-coding-exercises-no-03's Introduction

Coding Exercises No. 03

  1. In this exercise, I want you to clone a remote git repo and prepare your local git repository that will contain all of the coding exercises.

Step 1: Create a new repository at github.com. Give it name of padawan-coding-exercises-no-03. Don't initialize it with a README, .gitignore, or license

Step 2: Clone this remote repository to your local machine

$> git clone https://github.com/vulcansmithy/padawan-coding-exercises-no-03.git

Step 3: Change directory to the cloned git repo

$> cd padawan-coding-exercises-no-03

Step 4: Rename the local repository's current 'origin' to 'upstream'

$> git remote rename origin upstream

Step 5: Give the local repository an 'origin' that points to your repository

$> git remote add origin https://github.com/KrstnP/padawan-coding-exercises-no-03.git

Step 6: Push the local repository to your repository on github

$> git push origin master

Step 7: Create a new git branch called develop

$> git checkout -b develop

 

  1. Give the formula for computing the Area of a Circle

Area of a Circle formula

Wherein, the value p represent the value of Pi, or 3.141592653589793, nd the value r is the given radius.

Your challenge is to write a ruby program that uses a constant variable to reprsent the value of pi, and compute the Area of the Circle. Once the Area o the Circle is computed, display the result on the screen.

Your code should look like something like this

<your ruby Constant variable> = 3.141592653589793
radius = 250
area_of_a_circle = <your ruby Constant variable> * (radius ** 2)

The expected output of your ruby program should look like this

The computed Area of a Circle is 1963.4954084936207 

Additional challenge. Can you explain what the code radius ** 2 means? What does the ** ruby operator do? Clue.  

  1. Given the formula for computing the Circumference of a Circle

Area of a Circle formula

wherein, p represent the value of Pi, 3.141592653589793, and d is a given diameter of a circle.

write a program that uses a constant variable to reprsent the value of pi, which is 3.141592653589793, and compute the Circumference of a Circle. Then display the result on the screen.

  1. Given you have a hash called h
h = { :key_a => 35, :key_b => 84.50, :key_c => true, :key_d => "grace" }

write a ruby program that retrieve the value of 35 from the hash. Then display the retrieve value using the String interpolation. The output should looks like this

Retrieved the value 35 from the hash variable 'h'
  1. Given you have a hash called h
h = { :key_a => 35, :key_b => 84.50, :key_c => true, :key_d => "grace" }

write a ruby program that change the value of what :key_c is associated with. Change it from true to false. Then output the new value of key_c to the screen. The output should look like below. Again, use String interpolation to display the result.

The new value of h[:key_c] is now false.
  1. Given the following key-value pair
key..... :first_name
value... "Matt"

key..... :last_name
value... "Murdock"

key..... :occupation
value... "Lawyer"

key..... :company
value... "Nelson and Murdock Attorneys at Law"

key..... :email1
value... "[email protected]"

key..... :email2
value... "mattDD@nelson_and_murdock.com"

write a ruby program that contains a hash called contact_info. Use the above list as the values stored in the contact_info hash variable.

  1. Given the following key-value pair
key..... :title
value... "The Mysterious Affair at Styles"

key..... :author
value... "Agatha Christie"

key..... :year_published
value... 1920

key..... :genre
value... "Crime Novel"

write a ruby program that contains a hash called book_card. Use the above list as the values stored in the book_card hash variable.

  1. Using the hash given in exercise no. 5, write a program that delete or remove a specific key-value pair stored in the hash h. The one that you're going to remove is the :key_c. Once the key-value pair is remove, display to the screen the update content of the hash h. Clue.

  2. Using the hash given in exercise no. 6, write a program that would display all the keys used in hash contact_info. To retrieve the keys used, there is a function or method that you can call. Do a research on internet to figure out what is this method or function that you can use. Clue.

  3. Using the hash found in exercise no. 6, write a ruby program that would iterte to each key-value pair in the hash contact_info. Clue. The code should look like something like

contact_info.[insert method here] do |[insert something here],[insert something here]|
 puts "key... #{[insert something here]}, value... #{[insert something here]}"
end

padawan-coding-exercises-no-03's People

Contributors

vulcansmithy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.