answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Black_prince
1 month ago
13

The fractional_part function divides the numerator by the denominator, and returns just the fractional part (a number between 0

and 1). Complete the body of the function so that it returns the right number. Note: Since division by 0 produces an error, if the denominator is 0, the function should return 0 instead of attempting the division.
Computers and Technology
2 answers:
Amiraneli [1K]1 month ago
5 0

Response:

import math

def fractional_part(num, den):

   if den == 0:

      return 0

   return num / den - math.floor(num / den)

print(fractional_part(5,4)) // outputs 0.25

print(fractional_part(6,4)) // outputs 0.5

print(fractional_part(12,0)) // outputs 0

Details:

  • Using Python:
  • Importing math (enables access to the math.floor method)
  • An if statement checks for a zero denominator
  • Finding the fractional part is done by subtracting the floor of the result from the complete division.
ivann1987 [1K]1 month ago
5 0

Answer:

def fractional_part(numerator, denominator):

  if denominator == 0:

      return 0

  else:

      return (numerator / denominator) % 1

Explanation:

You might be interested in
For Adults/Adolescents, you should call/activate EMS: Before providing CPR. After providing CPR for 2 minutes. After an AED has
Natasha_Volkova [981]

Answer:

Before administering CPR is the correct choice.

Explanation:

CPR stands for cardiopulmonary resuscitation, a procedure where the rescuer provides mouth-to-mouth ventilation and chest compressions. Anyone trained in administering CPR to adults or adolescents is expected to call or activate EMS prior to starting the cardiopulmonary resuscitation.

6 0
1 month ago
8. In time series, which of the following cannot be predicted? A) large increases in demand B) technological trends C) seasonal
Natasha_Volkova [981]

Answer: Random fluctuations.

Explanation: A time series consists of data points ordered chronologically, arranged in equal intervals. Typically, this data sequence is systematic and has defined intervals. However, there’s no allowance for randomness, making unpredictable variations, or random fluctuations, absent in such series. Thus, option (D) is the correct choice.

6 0
1 month ago
Java languageThe cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.1. Declare a constant named CENTS_PER_
oksian1 [905]
// Below is Java code. // Package import import java.util.*; // class definition class Main { // class main method public static void main (String[] args) throws java.lang.Exception { try{ // variables final int CENTS_PER_POUND = 25; final int FLAT_FEE_CENTS = 75; // Creating Scanner object for input Scanner sr=new Scanner(System.in); System.out.print("Enter the shipping weight:"); // input reading int shipWeightPounds=sr.nextInt(); // cost calculation int shipCostCents = (shipWeightPounds * CENTS_PER_POUND) + FLAT_FEE_CENTS; // output Weight System.out.println("shipping Weight: " + shipWeightPounds); // output flat fee System.out.println("flat fee of shipping in cents: " + FLAT_FEE_CENTS); // output cents per pound System.out.println("Cents/pound for shipping: " + CENTS_PER_POUND); // output shipping cost System.out.println("total cost of shipping in cents: " + shipCostCents); catch(Exception ex){ return;} } } // Explanation: Define two constants "CENTS_PER_POUND=25" and "FLAT_FEE_CENTS=75". Use a Scanner object to capture user input for weight. Calculate the shipping cost by multiplying the weight with cents per pound and adding the flat fee. Then, display each value.
8 0
9 days ago
Read 2 more answers
Which kind of file would be hurt most by lossy compression algorithm
oksian1 [905]

Response: a file containing audio

Clarification:

8 0
15 days ago
Read 2 more answers
Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative value
Harlamova29_29 [998]

The code relevant to the problem in question:

import java.util.Scanner;

public class Test {

   public static void main(String[] args) {

       double number;

       double squareRootOfNumber;

       String userInput = null;

       Scanner scanner = new Scanner(System.in);

       System.out.println("Please enter a number: ");

       userInput = scanner.next();

       number = Double.parseDouble(userInput);

       squareRootOfNumber = Math.sqrt(number);

       if (number < 0) {

           throw new ArithmeticException("Cannot compute the square root of a negative number");

       }

       System.out.format("The square root of the entered number is %.2f %n", squareRootOfNumber);

   }

}

The program will output:

Please enter a number:

-90

Exception in thread "main" java.lang.ArithmeticException: Cannot compute the square root of a negative number at com..ans.Test.main(Test.java:18)

Explanation:

The standard Java library function java.lang.Math.sqrt does not throw an ArithmeticException for negative arguments, hence there’s no need to enclose your code in a try/catch block.

Instead, we manually trigger ArithmeticException using the throw keyword:

throw new ArithmeticException("Cannot compute the square root of a negative number");

3 0
1 month ago
Other questions:
  • Write a sequence of statements that create a file named "greeting" and write a single line consisting of "Hello, World!" to that
    5·1 answer
  • Which is among the earliest formats of audio used in video games? A. MP3 B. wave table synthesis C. pulse code modulation D. MOD
    7·2 answers
  • What are the differences between a policy, a standard, and a practice? What are the three types of security policies? Where woul
    15·1 answer
  • According to the author, there are five hedging strategies organizations can pursue. One of them is: Select one: a. commit with
    5·1 answer
  • Choose the person responsible for each innovation.
    10·1 answer
  • U.S. industries like steel, computers, and energy need to be protected from foreign competition to ensure which of the following
    6·2 answers
  • Consider a load-balancing algorithm that ensures that each queue has approximately the same number of threads, independent of pr
    14·1 answer
  • A company decides to relocate its operations to another state in order to take advantage of some new business investment credits
    15·1 answer
  • Write measurable performance objectives.Suppose that a trainer has identified as a generalgoal for a training module,"Able to fo
    13·1 answer
  • HELP ME ON THIS PLEASE ILL GIVE BRAINLY!!!! If U GET IT RIGHT !!!
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!