1answer.
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
saw5 [17]
2 years ago
13

Complete the function to return the result of the conversiondef convert_distance(miles):km = miles * 1.6 # approximately 1.6 km

in 1 milemy_trip_miles = 55# 2) Convert my_trip_miles to kilometers by calling the function abovemy_trip_km =____# 3) Fill in the blank to print the result of the conversionprint("The distance in kilometers is " +____)# 4) Calculate the round-trip in kilometers by doubling the result,# and fill in the blank to print the resultprint("The round-trip in kilometers is " + ___)
Computers and Technology
1 answer:
AnnZ [28]2 years ago
5 0

Answer:

The complete program is as follows:

def convert_distance(miles):

   km = miles * 1.6 # approximately 1.6 km in 1 mile

   return km

my_trip_miles = 55

# 2) Convert my_trip_miles to kilometers by calling the function above

my_trip_km =convert_distance(my_trip_miles) #3) Fill in the blank to print the result of the conversion

# 4) Calculate the round-trip in kilometers by doubling the result,

print("The distance in kilometers is " +str(my_trip_km))

# and fill in the blank to print the result

print("The round-trip in kilometers is " + str(my_trip_km * 2))

Explanation:

<em>The program is self-explanatory because I used the same comments in the original question.</em>

You might be interested in
In the Happy Valley School System, children are classified by age as follows:less than 2, ineligible2, toddler3-5, early childho
Greeley [361]

Answer:

int age = 10;

switch (age){

case 0:

case 1:

System.out.println("ineligible");

break;

case 2:

System.out.println("toddler");

break;

case 3:

case 4:

case 5:

System.out.println("early childhood");

break;

case 6:

case 7:

System.out.println("young reader");

break;

case 8:

case 9:

case 10:

System.out.println("elementary");

break;

case 11:

case 12:

System.out.println("middle");

break;

case 13:

System.out.println("impossible");

break;

case 14:

case 15:

case 16:

System.out.println("high school");

break;

case 17:

case 18:

System.out.println("scholar");

break;

default:

System.out.println("ineligible");

}

Explanation:

In java and many other programming languages, a switch statement is a way of having multiple branching options in a program. This is usually considered a more efficient way than using multiple if....else if statements. and the expression variables could be byte, char int primitive data types. etc. every branch (option) in a switch statement is followed by the break statement to prevent the code from "falling through". In the question The variable age is declared as an int and initialized to 10. and tested against the conditions given in the question.

7 0
3 years ago
Which of the following is an example of physical noise?
solniwko [45]
What are the options

6 0
2 years ago
How many jobs can you get without a college degree
larisa86 [58]
The 10 highest-paying jobs you can get without a college degree all pay more than $79,000 those are Commercial pilots.
Detectives and criminal investigators. ...
Powerhouse, substation, and relay electrical and electronics repairers. ...
Elevator installers and repairers. ...
Power plant operators. ...
Media and communication equipment workers. ...
7 0
3 years ago
Read 2 more answers
Write a sentence that describes how a series circuit works.
Lorico [155]

Answer:

In a series connection, the current is the same through each component regardless of any kind of components are used or their values. The voltage drops across each component in the circuit are dependent upon the values of the components used in the circuit. Another way to view a series connection is that the positive end of each component is connected to the negative end of the previous component in a 'one after the other' arrangement. The negative end of each component is also connected to the positive end of the next component.

It is one of which every component is arranged in a series connection. Hence series circuit will have same current at all points of the circuit. The voltage drop across each component in the circuit adds up to sum of voltage source across each component and of an equivalent component value. Breaking of the series circuit will make entire circuit to stop working. Suppose consider the three bulbs are connected in series connection and if even one bulb burns out or broken then all the three bulbs will stop working as well. In series circuit components like current (I) is sum of all the element and Voltage is sum of all the voltage drops and resistance is the sum of individual resistances.

Explanation:

3 0
2 years ago
Type (dog, cat, budgie, lizard, horse, etc.) Create a class that keeps track of the attributes above for pet records at the anim
Alenkinab [10]

Answer:

If you did the exercise with two Dog objects, it was a bit boring, right? After all, we have nothing to separate the dogs from each other and no way of knowing, without looking at the source code, which dog produced which bark.

In the previous article, I mentioned that when you create objects, you call a special method called a constructor. The constructor looks like the class name written as a method. For example, for a Dog class, the constructor would be called Dog().

The special thing about constructors is that they are the path to any new object, so they are a great place to call code that initializes an object with default values. Further, the return value from a constructor method is always an object of the class itself, which is why we can assign the return value of the constructor to a variable of the type of class we create.

However, so far, we have not actually created a constructor at all, so how come we can still call that method?

In many languages, C# included, the language gives you a free and empty constructor without you having to do anything. It is implied that you want a constructor; otherwise there would be no way of using the class for anything, so the languages just assume that you have written one.

This invisible and free constructor is called the default constructor, and, in our example, it will look like this:

public Dog(){ }

Notice that this syntax is very similar to the Speak() method we created earlier, except that we do not explicitly return a value nor do we even declare the return type of the method. As I mentioned earlier, a constructor always returns an instance of the class to which it belongs.

In this case, that is the class Dog, and that is why when we write Dog myDog = new Dog(), we can assign the new object to a variable named myDog which is of type Dog.

So let’s add the default constructor to our Dog class. You can either copy the line above or, in Visual Studio, you can use a shortcut: type ctor and hit Tab twice. It should generate the default constructor for you.

The default constructor doesn’t actually give us anything new because it is now explicitly doing what was done implicitly before. However, it is a method, so we can now add content inside the brackets that will execute whenever we call this constructor. And because the constructor runs as the very first thing in an object’s construction, it is a perfect place to add initialization code.

For example, we could set the Name property of our objects to something by adding code such as this:

public Dog()

{

   this.Name = "Snoopy";

}

This example will set the Name property of any new objects to “Snoopy”.

Of course, that’s not very useful because not all dogs are called “Snoopy”, so instead, let us change the method signature of the constructor so that it accepts a parameter.

The parentheses of methods aren’t just there to look pretty; they serve to contain parameters that we can use to pass values to a method. This function applies to all methods, not just constructors, but let’s do it for a constructor first.

Change the default constructor signature to this:

public Dog(string dogName)

This addition allows us to send a string parameter into the constructor, and that when we do, we can refer to that parameter by the name dogName.

Then, add the following line to the method block:

this.Name = dogName;

This line sets this object’s property Name to the parameter we sent into the constructor.

Note that when you change the constructor’s signature, you get a case of the red squigglies in your Program.cs file.When we add our own explicit constructors, C# and .NET will not implicitly create a default constructor for us. In our Program.cs file, we are still creating the Dog objects using the default parameter-less constructor, which now no longer exists.

To fix this problem, we need to add a parameter to our constructor call in Program.cs. We can, for example, update our object construction line as such:

Dog myDog = new Dog(“Snoopy”);

Doing so will remove the red squigglies and allow you to run the code again. If you leave or set your breakpoint after the last code line, you can look at the Locals panel and verify that your object’s Name property has indeed been? Got it?

5 0
2 years ago
Other questions:
  • What were precomputed tables and why were they necessary?​
    12·2 answers
  • Which action is LEAST important to maintaining a healthy credit score?
    8·2 answers
  • Mation about which osi layers of connected cisco devices can be verified with the show cdp neighbors comm
    15·1 answer
  • Write a program that accepts three decimal numbers as input and outputs their sums?​
    5·1 answer
  • What is the part of the browser window that displays the content of the web page such as pictures and text called?
    10·1 answer
  • Which of the following best describes the 7x7 PowerPoint rule
    8·1 answer
  • give your opinion on if you would trust your accounts with an online bank. Explain why or why not. MANY people do not. MANY peop
    14·2 answers
  • Julie is trying to decide weather or not to add a color scheme to her presentation and she asks you for your advice u should adv
    9·1 answer
  • Write the definition of a function isSenior, that receives an integer parameter and returns true if the parameter's value is gre
    13·1 answer
  • Question 3 of 10<br> What was the fly in the ointment of Timmy's friendship with Rollo?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!