Q1: Define a function called sign which takes a numerical argument and returns -1 if it's negative, 1 if it's positive, and e if it's zero. Given: 1 def sign(num): if num > 0: return e print(sign(10)) print(sign(-15)) print (sign(0)) 6
Q: 4. Write a value-returning function, isVowel, that returns the value true if a given character is a…
A: As question no. is not mentioned I code both questions C++.
Q: Write a function definition for a function named getFirst that does the following: 1) Accepts an…
A: In any string the first character of the string is present at index 0. In the function if the input…
Q: Write a function that implements a simple calculator. It inputs 3 values, two numbers and an integer…
A: Below I have provided Python Programming. Also, I have attached the screenshot of the code and…
Q: 3. Twin Primes A prime number is any integer greater than 1 that is divisible (without remainder) by…
A: Program: def twinPrimes(a,b):t=[]while a<=b:if a==1 or a==2:a+=1continueif isPrime(a):if…
Q: Write the prototype for the function appearing in the given statements. (Assume that there is no…
A: A function prototype lets compiler know in advance the return type, parameters type and function…
Q: Take in numbers about 4 times and create a function that adds those four numbers together. Use that…
A:
Q: Q2) (Perfect Numbers) An integer number is said to be a perfect number if its factors, including 1…
A: // C program to check if a given number is perfect// or not#include<stdio.h> // Returns true…
Q: my_func is a function as follows. What is the value of a at the end of the code beneath? function a…
A: answer is
Q: An integer number is said to be a perfect number if its factors, including 1 (but not the number…
A: Program Approach- Include the essential header files. Declare the functions needed for the program.…
Q: In coral language: One lap around a standard high-school running track is exactly 0.25 miles. Write…
A: A required program is as follows, Program: Function MilesToLaps(float userMiles) returns float…
Q: 1- Write a function that takes a word less than 25 characters long and returns the letter that word…
A: #include <stdio.h> #include <string.h> #include <ctype.h> // returns the first…
Q: 3. Write and test a function hydroxide that returns a 1 for true if its string argument ends in the…
A: As per our guidelines we are supposed to answer only one question. Kindly repost the remaining…
Q: The function below takes two arguments: a string (name) and an integer (position). Complete the…
A: To solve this problem, we need to define a function print_welcome( ) using def keywords, It takes…
Q: A number is said to be Harshad if it's exactly divisible by the sum of its digits. Create a function…
A: An integer number in base 10 which is divisible by the sum of its digits is said to be a Harshad…
Q: Python 3 • Autocomplete Ready O Given an integer, write a function to determine if it is a power of…
A: PYTHON USED TO ANSWER THIS QUESTUIN
Q: 1- Write a function that finds the max of three numbers that are passed to it.
A: Step 1: input three user input number. Step2: Add three numbers to list. Step 3: Using max()…
Q: 1. Write a function in F# that has the following function signatures: 1. string * int * int ->…
A: Write a function in F# that has string*int*int ->string 1. string *int *int -> string 2.…
Q: def can_vote(age: int) -> bool: """Return True iff age is legal voting age of at least 18 years. >»…
A: def can_vote(age:int)->bool: """return True if age is legal voting age of at least 18 years.…
Q: Complete the code that returns the value of f(x), which has the value 1 inside the range –1 < x <1…
A: The complete code for the given problem is: def function_f(x): if x in (-1,1): fval=1…
Q: C++ please. Define a function PrintColors() that takes three string parameters and outputs as…
A: Step-1: Start Step-2: Declare three variables str1, str2, str3 Step-3: Take input for str1, str2,…
Q: C++ please. Define a function PrintColors() that takes three string parameters and outputs as…
A: I have provided C++ CODE along with CODE SCREENSHOT and 2 OUTPUT…
Q: Write a function that takes a number and returns the largest digit value in the number. For example,…
A: The python program is written where it takes the input from the user and prints the largest number.…
Q: C Programming Language Define an enumerated data type Month. Write a function that takes a Month…
A: 1) Below is C Program to define enumerated data type Month and a function that takes a Month…
Q: Write a isPalindrome Function Write a function isPalindrome($str) that returns true if the parameter…
A:
Q: Write a function called even_checker that takes a number as an argument and prints whether the…
A:
Q: e) What does each function do? Hint: Write a simple description for each of the user-defined…
A: void print_stars(): This function takes no arguments and prints 25 * in a sequence on the console.…
Q: 7. A prime number is an integer greater than one that is only divisible by one and itself. Write a…
A: A prime number is a whole number greater than 1 whose only factors are 1 and itself.
Q: def can_vote(age: int) -> bool: "*"Return True iff age is legal voting age of at least 18 years. >>…
A: According to the question below the solution: Output:
Q: 1. Write a function is divisible that takes two numbers and Nas inputa, and that returns True (the…
A: Python Program: # Takes two number m and n as user inputm = int(input("Enter the value of m: "))n =…
Q: There are different ways you can determine whether a person is healthy or over weight weight measure…
A: Here let us define the function as String measureCalc() The function doesn't accept any value. Also…
Q: Q2) (Perfect Numbers) An integer number is said to be a perfect number if its factors, including 1…
A: **This program is written in PYTHON since no programming language was mentioned in the question.**…
Q: c++ question Write the definition for a value-returning function named ticketRate that has 1…
A: #include <iostream>using namespace std; //function definitionfloat ticketRate(char category){…
Q: A)Write a function that accepts a number(long) and return a boolean value, it will return true if…
A: Given: A set of rules to validate a number, The length of the number should range between 3 to 5.The…
Q: A number is said to be Harshad if it's exactly divisible by the sum of its digits. Create a function…
A: Calculate the sum of digits Check whether sum is exact divisor of input number and return whether…
Q: Write a prt() function definition that accepts an argument copied into y and return nothing
A: Use pass by reference method to update the original values
Q: Az. Write a program that uses a function myvalue to ask for a number (In the function), find the…
A: I have provided C CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOTS-------------------
Q: (Time in Seconds) Write a function that takes the time as three integer arguments (forhours,…
A: Lets see the solution.
Q: Create a function that determines whether a number is Oddish or Evenish. A number is Oddish if the…
A: function oddishOrEvenish(num) { let arr = num.toString().split(''); let sum =0; for (let i of arr){…
Q: n this small funtion, identify and define each part of the function int addition (int a, int b) {…
A: Program: A program is a set of lines code that contains instructions to perform a specific task.In…
Q: 1- Write a function that takes a word less than 25 characters long and returns the letter that word…
A: To find the capital letter of a word, we can test it against the ASCII values. We know that the…
Q: Create a function that takes two integers, num and n, and returns an integer which is divisible by n…
A: function roundNumber(num, n) { let i = num, j = num while (i % n !== 0) i++ while (j % n !== 0…
Q: Write a function flipCase that accepts a word as an argument and returns the same word but with each…
A: Create a function flipCase(str). str will be the parameter and oncalling the function user will give…
Q: Write a function tuplinator (number) that takes a number argument and returns a tuple consisting of…
A: ALGORITHM:- 1. Create an empty tuple. 2. Insert the received number, its square and its cube in the…
Q: Create a function that determines whether a number is Oddish or Evenish. A number is Oddish if the…
A: As no programming language is mentioned, it is solved using basic Python
Q: (Perfect Numbers) An integer number is said to be a perfect number if its factors, including1 (but…
A: Lets see the solution.
Q: Toll roads have different fees at different times of the day and on weekends. Write a function…
A:
Q: In the kids' game "Paper, Rock, Scissors" each player chooses one of the three and the winner is…
A: I have provided C++ CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT---------------
Q: pyhton language Q10.3 Write a function mean() with a variable number of arguments that can…
A:
Q: Define a value-returning function replaceBlanks with one string parameter. The function will replace…
A: The concept is to use the "regex" module of python called "re" and then remove all the leading and…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Mark the following statements as true or false: a. To use a predefined function in a program, you need to know only the name of the function and how to use it. (1) b. A value-returning function returns only one value. (2, 3) c. Parameters allow you to use different values each time the function is called. (2, 7, 9) d. When a return statement executes in a user-defined function, the function immediately exits. (3, 4) e. A value-returning function returns only integer values. (4) f. A variable name cannot be passed to a value parameter. (3, 6) g. If a C++ function does not use parameters, parentheses around the empty parameter list are still required. (2, 3, 6) h. In C + + , the names of the corresponding formal and actual parameters must be the same. (3, 4, 6) i. A function that changes the value of a reference parameter also changes the value of the actual parameter. (7) j. Whenever the value of a reference parameter changes, the value of the actual parameter changes. (7) k. In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. (9) l. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. (10) m. In a program, global constants are as dangerous as global variables. (10) n. The memory for a static variable remains allocated between function calls. (11)(Numerical) Heron’s formula for the area, A, of a triangle with sides of length a, b, and c is A=s(sa)(sb)(sc) where s=(a+b+c)2 Write, test, and execute a function that accepts the values of a, b, and c as parameters from a calling function, and then calculates the values of sand[s(sa)(sb)(sc)]. If this quantity is positive, the function calculates A. If the quantity is negative, a, b, and c do not form a triangle, and the function should set A=1. The value of A should be returned by the function.(Physics) Buoyancy is the upward force a liquid exerts on a submerged object, as shown in Figure 6.9. The buoyancy force is given by this formula: B=pgV Bisthebuoyancyforce( lbforN).isthefluiddensity( slug/f t 3 orkg/ m 3 ).gistheaccelerationcausedbygravity( 32.2ft/se c 2 or9.8m/ s 2 ).Vistheobjectsvolume( f t 3 or m 3 ). a. Using this formula, write a function named buoyantForce(double ro, double vol, int units) that accepts a fluid density, the volume of an object placed in the fluid, and the units to be used(1=U.S.Customaryunits,2=metricunits), and returns the buoyancy force exerted on the object. b. Include the function written for Exercise 6a in a working C++ program, and use your program to complete the following chart:
- Given person_is_old(age) which returns True or False based on the incoming age as an integer. Write a function that uses the one mentioned above so that it prints “Go to work!” if the person is not old and “You deserved to have a long vacation” otherwise. Your function must also accept the age as its argument. My code def funct2(age): flag = old_person(age) if(flag): print("You deserved to have a long vacation") else: print("Go to work!")Write a function flipCase that accepts a word as an argument and returns the same word but with each upper case letter switched to lower case and vice-versa. Example: >>> flipCase('ostrich')'OSTRICH' #note the lanuage is in pythonpyhton language Q10.3 Write a function mean() with a variable number of arguments that can return the mean average value of the arguments. If there is no input, print out an error message and return None.
- 1. Write a function called numGame that takes a number as parameter. a) if the number is divisible by 2, it should return “Its divisible by 2 ”. b) if it is divisible by 4, it should return “ Its divisible by 4”. c) if it is divisible by both 2 and 4, it should return “Its divisible by 2 and 4 both ”. d) Otherwise, it should return the same number. ((((( programming python))))def truth_value(integer): """Convert an integer into a truth value.""" # Convert 0 into False and all other integers, # including 1, into True if integer == 0: truth_value = False else: truth_value = True return truth_value Now, write a function that goes in the opposite direction of the truth_value() function. This new function should convert a truth value into an integer. In particular, True should be converted into 1 and False into 0. Name the new function integer_0_or_1(). All you need to include below is your definition of the function integer_0_or_1(). It will be tested automatically against relevant inputs. So include your function and nothing more.Define a function hypotenuse that calculates the hypotenuse of a right triangle when the other two sides are given. The function should take two double arguments and return the hypotenuse as a double. You can use the sqrt function from the cmath library. Use this function in a program to determine the hypotenuse for each of the following triangles: Triangle Side 1 Side 2 1 3.0 4.0 2 5.0 12.0 3 8.0 15.0
- (Perfect Numbers) An integer number is said to be a perfect number if its factors, including1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 =1 + 2 + 3. Write a function isPerfect that determines whether parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect.Challenge the power of your computer by testing numbers much larger than 1000.Local variables are known only to the function in which they are declared. Local variables are invisible outside the function in which they are declared. Whether True or False 11. It is possible for any function to return numerous values. Any function type may return multiple values. That's true, right?(Exponentiation) Write a function integerPower(base, exponent) that returns the value ofbaseexponentFor example, integerPower(3, 4) = 3 * 3 * 3 * 3. Assume that exponent is a positive, nonzero integer, and base is an integer. Function integerPower should use for to control the calculation. Donot use any math library functions.