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
Anuta_ua [19.1K]
2 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]2 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
Write a program that creates a dictionary containing the U.S. states as keys and their capitals as values. (Use the Internet to
Dima020 [189]

Answer:

  1. import random  
  2. states = {
  3.    "Alabama": "Montgomery",
  4.    "California": "Sacramento",
  5.    "Florida": "Tallahassee",
  6.    "Hawaii": "Honolulu",
  7.    "Indiana": "Indianapolis",
  8.    "Michigan": "Lansing",
  9.    "New York": "Albany",
  10.    "Texas" : "Austin",
  11.    "Utah" : "Salt Lake City",
  12.    "Wisconsin": "Madison"
  13. }
  14. correct = 0
  15. wrong = 0
  16. round = 1
  17. while(round <= 5):
  18.    current_state = random.choice(list(states))
  19.    answer = input("What is the capital of " + current_state + ": ")
  20.    
  21.    if(answer == states[current_state]):
  22.        correct += 1
  23.    else:
  24.        wrong += 1
  25.    
  26.    round += 1
  27. print("Correct answer: " + str(correct))
  28. print("Wrong answer: " + str(wrong))

Explanation:

The solution code is written in Python 3.

Line 3 -14

Create a dictionary of US States with capital as each of their corresponding value. Please note only ten sample states are chosen here.

Line 16 - 18

Create variables to track the number of correct and inaccurate response and also round counter.

Line 19 - 28

Set the while condition to enable user to play the quiz for five questions and use random.choice to randomly pick a state from the dictionary and prompt user to input the capital of selected stated.

If the answer matched with the capital value of the selected state, increment the correct counter by one. Otherwise the wrong counter will be incremented by one. Increment the round counter by one before proceed to next round.

Line 30 - 31

Print the number of correct responses and wrong responses.

7 0
2 years ago
At which stage should James, a website designer, gather information about the website he wants to create, and at which stage sho
viva [34]
<h2>Answer: James should gather information in the <u><em>Learning</em></u> phase and begin the site’s coding in the <u><em>Development</em></u> phase.</h2>

8 0
2 years ago
The ______________________ are incident management personnel that the incident commander or unified command assign to directly s
postnew [5]

Answer:

The Command Staff are the incident management personnel that the incident commander or unified command assign to directly support the command function.

Explanation:

Based on the information retrieved from the ICS (Incident Command System), to handle properly incidents that occur, Command Staff are assigned by the incident commander or unified command.

8 0
2 years ago
Most injury crashes in Florida happen in __________ conditions.
ivolga24 [154]

Answer:

Most injury crashes in Florida happen in dusk conditions

Explanation:

Dusk is the time of the day when the sun is setting. At this time of the day, the visibility on the roads is less. This time of the day, the number of cars on the roads is also significantly greater. This indirectly means that the possibility of most injury crashes in Florida in dusk conditions considerably increases.

The amount of tourism happening in the state is also a condition that takes part in injury crashes due to increased traffic on the roads.

7 0
2 years ago
python Write a class named Taxicab that has three **private** data members: one that holds the current x-coordinate, one that ho
Blizzard [7]

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

5 0
2 years ago
Other questions:
  • my headphones have a mic and the mic and headset don't work at the same time what do i do to make them work together
    8·2 answers
  • The main problem with radio transmission is which of the following? Select one: a. Radio waves cannot travel through walls. b. W
    9·2 answers
  • Janis needs to select all the text in a single bullet point. Which action describes the easiest method to perform this task?
    9·1 answer
  • Write a program that first reads in the name of an input file, followed by two strings representing the lower and upper bounds o
    15·2 answers
  • Write a program to determine all pairs of positive integers, (a, b), such that a &lt; b &lt; 1000 and [a2 + b2 + 1)/(ab) is an i
    13·1 answer
  • Convert to octal. Convert to hexadecimal. Then convert both of your answers todecimal, and verify that they are the same.(a) 111
    12·1 answer
  • PC’s &amp; More has shifted to sales and service of laptops and PCs, where it has the potential to triple the number of its cust
    14·1 answer
  • An extranet is like an intranet except that it allows company employees access to corporate Web sites from the ______
    13·1 answer
  • Consider the following class declaration: public class Square { private double sideLength; public double getArea() { return side
    13·1 answer
  • OH GOD PLEASE HELP I CAN'T FIGURE THIS OUT-
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!