Question

In: Computer Science

There is a package, `beepr`, with a single function, `beep()`. Write a function with an input,...

There is a package, `beepr`, with a single function, `beep()`. Write a function with an input, `x`, that will call `beep()` when `x > 0`. You may assume that the `beepr` package has been loaded. Call your function `xgt0()`.


using R studio

Solutions

Expert Solution

Here's the code feel free to ask any query related to this.

#immporting library beepr
library(beepr);


#declaring the function xgot0()

xgot0 <- function(x){
  #checking if x >0 or not
  if(x>0)
  {
    print("Beep sound is produced ");
    beep(0);#producing random sound
  }
  else
  {
    print("Beep sound is not produced");
  }
}
#taking input from user
x <- as.integer(readline("Enter the number x"));

#calling function
xgot0(x)

ScreenShot of result


Related Solutions

Write a C function called weighted_digit_sum that takes a single integer as input, and returns a...
Write a C function called weighted_digit_sum that takes a single integer as input, and returns a weighted sum of that numbers digits. The last digit of the number (the ones digit) has a weight of 1, so should be added to the sum "as is". The second from last digit (the tens digit) has a weight of 2, and so should be multiplied by 2 then added to the sum. The third from last digit should be multiplied by 1...
1.) Write a function, base2tobase10 that has a single input, a vector containing 1,s and 0...
1.) Write a function, base2tobase10 that has a single input, a vector containing 1,s and 0 's representing a binary number. For example the binary number 01101011 would be represented by the vector [ 0, 1, 1, 0, 1, 0,1, 1]. Your function should return a single output,the base 10 equivalent of the base 2 number. First, your function must check the input vector and detremine if any of the vector elemnets are not a 0 or a1. If they...
Using Python Question 1 Write an input function. Then use it to supply the input to...
Using Python Question 1 Write an input function. Then use it to supply the input to following additional functions: i) Print multiplication table of the number from 1 to 12. ii) Print the sum of all the numbers from 1 to up the number given. iii) Print if the number supplied is odd or even. Question 2 Write function that asks for input from a user. If the user types 'end', the program exits, otherwise it just keeps going.
Pythons code using idle Write an input function. Then use it to supply the input to...
Pythons code using idle Write an input function. Then use it to supply the input to following additional functions: i) Print multiplication table of the number from 1 to 12. ii) Print the sum of all the numbers from 1 to up the number given. iii) Print if the number supplied is odd or even.
In Python Write a function to read a Sudoku board from an input string. The input...
In Python Write a function to read a Sudoku board from an input string. The input string must be exactly 81 characters long (plus the terminating null that marks the end of the string) and contains digits and dots (the `.` character represents an unmarked position). The input contains all 9 rows packed together. For example, a Sudoku board that looks like this: ``` ..7 ... ... 6.4 ... ..3 ... .54 ..2 ... .4. ... 9.. ... ..5 385...
Please write the code in c++ Write a function with one input parameter that is a...
Please write the code in c++ Write a function with one input parameter that is a vector of strings. The function should count and return the number of strings in the vector that have either an 'x' or a 'z' character in them. For example, when the function is called, if the vector argument contains the 6 string values, "enter", "exit", "zebra", "tiger", "pizza", "zootaxy" the function should return a count of 4. ("exit", "zebra", "pizza", and "zootaxy" all have...
Write a function that takes a number as input, and returns the character A if the...
Write a function that takes a number as input, and returns the character A if the input is 90 and above, B if it’s 80 and above but less than 90, C if it’s at least 70 but less than 80, D if it’s at least 60 but less than 70, and F if it’s less than 60. If the input is not a number or is negative, the function should exit 1 with an error (by calling the Matlab...
In python write a function whose input is a string. This function determines the data type...
In python write a function whose input is a string. This function determines the data type of the input string. The data types can be a float, int, or string. Most pass the following assertions: assert determine_data_type('1.2') == float assert determine_data_type('4') == int assert determine_data_type('EAS503') == str
This is python: #Write a function called count_positive_evens. This function #should take as input a list...
This is python: #Write a function called count_positive_evens. This function #should take as input a list of integers, and return as #output a single integer. The number the function returns #should be the count of numbers from the list that were both #positive and even. # #For example: # # count_positive_evens([5, 7, 9, 8, -1, -2, -3]) -> 1 # count_positive_evens([2, 4, 6, 8, 10, 12, 15]) -> 6 # count_positive_evens([-2, -4, -6, -8, -10, 1]) -> 0 # #0...
1. Suppose that output q is a function of a single input, labor (L). Describe the...
1. Suppose that output q is a function of a single input, labor (L). Describe the returns to scale associated with each of the following production functions: a. q = 3L. Answer: b. q = L3. Answer:
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT