Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Did Module 5! #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions exercise-1/exercise.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# Exercise-1: practice with basic syntax

# Create a variable `hometown` that stores the city in which you were born

hometown <- "bangalore"

# Assign your name to the variable `my.name`

my.name <- "Thejas"

# Assign your height (in inches) to a variable `my.height`


my.height <- 135
# Create a variable `puppies` equal to the number of puppies you'd like to have

puppies <- 3

# Create a variable `puppy.price`, which is how expensive you think a puppy is

puppy.price <- 400

# Create a variable `total.cost` that has the total cost of all of your puppies

total.cost <- puppies * puppy.price

# Create a boolean variable `too.expensive`, set to TRUE if the cost is greater than $1,000

too.expensive <- total.cost > 1000

# Create a variable `max.puppies`, which is the number of puppies you can afford for $1,000.
max.puppies <- 1000 / puppy.price

print(max.puppies)

8 changes: 8 additions & 0 deletions exercise-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Exercise-2
Nearly all of our R exercises will follow the same format, requiring the following steps:

1. As you've done before, fork this repository to your own GitHub account
2. Clone the repository to your machine
3. Open the `exercise.R` file in Rstudio, and follow the instructions there.
4. When you're done, `add` and `commit` your changes
5. Push your changes back to GitHub
29 changes: 29 additions & 0 deletions exercise-2/exercise.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Exercise-2: more practice with basic syntax

# Create a variable `food` that stores your favorite kind of food
food <- "Teiyaki"

# Create a variable 'restaurant' that stores your favorite place to eat
resturant <- "Itadakimas"

# Create a variable `friends` equal to the number of friends you would like to eat with
friends <- 4

# Create a variable `meal.price`, which is how expensive you think one meal at the restaurant will be
meal.price <- 10

# Create a variable `total.cost` that has the total cost of your bill
total.cost <- friends * meal.price

# Create a variable 'total.cost.tip' to be the total cost including a 15% tip
total.cost.tip <- total.cost * 0.15

# Create a variable 'price.limit' set to your spending budget
price.limit <- 100

# Create a boolean variable `too.expensive`, set to TRUE if the cost with the tip is greater than the price limit
too.expensive <- (total.cost + total.cost.tip) > price.limit

# Create a variable `max.friends`, which is the maximum number of friends you can invite that is in range
# of your price limit
max.friends <- round(price.limit / ((total.cost + total.cost.tip)/friends))