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
Anuta_ua [19.1K]
4 years ago
10

python Write a class named Taxicab that has three **private** data members: one that holds the current x-coordinate, one that ho

lds the current y-coordinate, and one that holds the odometer reading (the actual odometer distance driven by the Taxicab, not the Euclidean distance from its starting point). The class should have an init method that takes two parameters and uses them to initialize the coordinates, and also initializes the odometer to zero. The class should have get methods for each data member: get_x_coord, get_y_coord, and get_odometer. The class does not need any set methods. It should have a method called move_x that takes a parameter that tells how far the Taxicab should shift left or right. It should have a method called move_y that takes a parameter that tells how far the Taxicab should shift up or down. For example, the Taxicab class might be used as follows:
Computers and Technology
1 answer:
Blizzard [7]4 years ago
5 0

Answer:

see explaination

Explanation:

class Taxicab():

def __init__(self, x, y):

self.x_coordinate = x

self.y_coordinate = y

self.odometer = 0

def get_x_coord(self):

return self.x_coordinate

def get_y_coord(self):

return self.y_coordinate

def get_odometer(self):

return self.odometer

def move_x(self, distance):

self.x_coordinate += distance

# add the absolute distance to odometer

self.odometer += abs(distance)

def move_y(self, distance):

self.y_coordinate += distance

# add the absolute distance to odometer

self.odometer += abs(distance)

cab = Taxicab(5,-8)

cab.move_x(3)

cab.move_y(-4)

cab.move_x(-1)

print(cab.odometer) # will print 8 3+4+1 = 8

You might be interested in
What does the regular expression [a-z0-9\-] mean?
eduard

Answer:

It means that it matches a to z in lowercase, 0 to 9 in digits and \ - in characters.

Explanation:

As In regular expressions such as [a-z] means that it will match between a to z in lower case.

In [0-9] means it will search from 0 to 9 in digits.

so

<em>[a-z0-9] means that it will match all from a to z in lowercase and 0 to 9 in digits.</em>

4 0
3 years ago
Hi. I'm a beginner in python. Can anyone tell me what I'm missing or doing wrong, because I can't figure out why my messages in
andreyandreev [35.5K]

Answer:

message = "i hate cheese and"

message += " fries"

print(message)

Explanation:

Whenever you do string concatenation, which is just combining strings, it doesn't put a space in between the items you're joining together, it does exactly what you tell it to do, so to add a space between the two pieces of text you would have to do the following:

```

message = "i hate cheese and"

message += " fries"

print(message)

```

Don't copy the ```, I just put that to indicate anything in between is code

Anyways notice the space I put before fries? That should also add a space in the message so there is a space between "and" and "fries"

4 0
2 years ago
How is your approach to solving how to order your coins different from how a computer might have to approach it?
Finger [1]

Answer: Computer solves the order of coins the way its programmed to while you solve the order of coins the way you want.

8 0
3 years ago
Select the correct answer.
irinina [24]

Answer:

A

Explanation:

6 0
3 years ago
Which topology connects all the computers in a circular pattern?
Umnica [9.8K]
It’s c that’s what I got
6 0
3 years ago
Other questions:
  • 38. Which of the following best describes why e-mail spoofing is easily executed? a. SMTP lacks an adequate authentication mecha
    15·1 answer
  • The algorithm ADDN implements N-bit fixed-width binary addition for non-negative integers and ignores overflows. For example, AD
    13·1 answer
  • How can the output of a command be redirected to a file instead of being displayed on the computer's screen?
    9·1 answer
  • What is the minimum internal temperature that the chicken must reach?
    11·1 answer
  • HTTP is the protocol that governs communications between web servers and web clients (i.e. browsers). Part of the protocol inclu
    11·1 answer
  • Write a for loop that sets each array element in bonusScores to the sum of itself and the next element, except for the last elem
    11·2 answers
  • Why is flash memory considered nonvolatile?
    5·1 answer
  • Examine the following piece of code and determine the data type of the function's return value.
    11·1 answer
  • 3. In a 32-bit CPU, the largest integer that we can store is 2147483647. Verify this with a
    12·1 answer
  • What method do phishing and spoofing scammers use
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!