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
sweet-ann
1 month ago
15

A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output i

s the miles walked.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print('{:.2f}'.format(your_value))

Ex: If the input is:

5345
the output is:

2.67
Computers and Technology
1 answer:
ivann1987 [982]1 month ago
5 0

Response:

steps = int(input("Specify the number of steps: "))

miles = steps / 2000

print('{:.2f}'.format(miles))

Explanation:

Prompt the user to input the number of steps and convert the input to an integer.

Compute the corresponding miles by dividing the number of steps by 2000.

Output the miles formatted to two decimal places.

You might be interested in
In mathematics, the factorial of a positive integer n, denoted as n! , is the product of all positive integers less than or equa
oksian1 [849]
public static int factorial(int n) { if (n >= 1 && n <=12) { if (n == 1) return 1; else return n * factorial(n - 1); } else return -1; } Explanation: The factorial method takes a single integer n as input. It checks if n is within the range of 1 to 12. If it is, it further checks if n equals 1. If it is indeed 1, it returns 1 as the factorial. Otherwise, it recursively calls itself with n decreased by 1, multiplying the result by n. If n is outside this range, the method returns -1 indicating the input is invalid.
6 0
13 days ago
Read 2 more answers
The is_positive function should return True if the number received is positive, otherwise it returns None. Can you fill in the g
zubka84 [1004]

Question:

The function is_positive should yield True if the supplied number is positive; otherwise, it gives None. Can you fill in the blanks accordingly?

def is_positive(number):

       if  _____ :

           return _____

Answer:

def is_positive(number):

   if (number > 0):

       return True

  else:

       return "None"

---------------------------------------------------------------------------------

Code Test and Sample Output:

print(is_positive(6))

>> True

print(is_positive(-7))

>> None

----------------------------------------------------------------------------------

Explanation:

This segment of code is composed in Python.

To explain it further, let's break down the content of each line;

Line 1: Creates a function identified as is_positive which takes in a variable number.i.e

def is_positive(number):

Line 2: Evaluates if the given number is positive; a number qualifies as positive if it exceeds zero. i.e

if (number > 0):

Line 3: Produces a boolean result of True when the input number is positive. i.e

return True

Line 4: Initiates the else block to be executed in case the input number isn’t positive. i.e

else:

Line 5: Returns the string "None" when the number is not positive. i.e

return "None"

When combined, this results in;

===============================

def is_positive(number):

   if (number > 0):

       return True

   else:

       return "None"

================================

An instance test for the code provided an argument of 6 and -7, resulting in True and None respectively. i.e

print(is_positive(6))   = True

print(is_positive(-7))  = None

8 1
1 month ago
Read 2 more answers
A computer can successfully ping outside the local network, but cannot access any world wide web services. what is the most prob
amid [867]
<span>Port 80 is being blocked by the Windows Firewall.</span>
7 0
1 month ago
Assume the int variables i,lo, hi, and result have been declared and that lo and hi have been initialized. Assume further that r
zubka84 [1004]

Answer:

#include <iostream>

using namespace std;

int main() {

   int i, lo=12, hi=45, result=0; // initializing the required variables..

   for(i=lo;i<=hi;i++) // implementing a for loop.

   {

       result+=i; // accumulating the sum of integers..

   }

   cout<<result<<endl; // displaying the resulting total.

return 0;

}

Output:-

969

Explanation:

This program is written in C++. Initially, the variables i, lo, hi, and result are declared, with only lo, hi, and result initialized. A for loop is employed to loop through all values from lo to hi, adding each integer to the result.

5 0
1 month ago
A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
8_murik_8 [927]

Answer:

// C++ program.

#include <bits/stdc++.h>

using namespace std;

// main function

int main() {

  // variable

float n;  

cout<<"Enter the initial value:";

//User input

cin>>n;

//Variables for measurements at 6, 12, and 18 hours

float hours_6, hours_12, hours_18;  

//Set floating-point precision

cout << fixed;

    cout << setprecision(6);

 //Calculate caffeine amounts after 6, 12, 18 hours

hours_6 = n / 2.0;

hours_12 = hours_6 / 2.0;

hours_18 = hours_12 / 2.0;

//Display results

cout<<"After 6 hours: "<<hours_6<<"mg"<<endl;

cout<<"After 12 hours: "<<hours_12<<"mg"<<endl;

cout<<"After 18 hours: "<<hours_18<<" mg"<<endl;

return 0;

}

Explanation:

The program reads input from the user and sets the output precision to six decimal places. The caffeine amount after 6 hours is half the initial input. At 12 hours, it is half the 6-hour value, and after 18 hours, it is half the 12-hour value.

Output:

Enter the initial value:100

After 6 hours: 50.000000 mg

After 12 hours: 25.000000 mg

After 18 hours: 12.500000 mg

5 0
1 month ago
Other questions:
  • Susan is assisting a web designer to create a promotional web page on eco-friendly classroom designs. She uses color combination
    5·1 answer
  • To what extent are the following computer systems instances of artificial intelligence:
    14·1 answer
  • Write a class named Taxicab that has three **private** data members: one that holds the current x-coordinate, one that holds the
    9·1 answer
  • array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting o
    11·1 answer
  • The president of the company wants a list of all orders ever taken. He wants to see the customer name, the last name of the empl
    15·1 answer
  • A computer program is tested by 5 independent tests. If there is an error, these tests will discover it with probabilities 0.1,
    5·1 answer
  • You work in the educational software industry. Your boss asks you to give a brief lecture to other employees about the digital d
    7·2 answers
  • Consider a one-way authentication technique based on asymmetric encryption: A --&gt; B: IDA B --&gt; A: R1 A --&gt; B: E(PRa, R1
    13·1 answer
  • What term best describes the grammatical rules for writing proper code? paths syntax hyperlinks declarations
    7·2 answers
  • Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!