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
Answer:First one net is the answer ........
Answer:
#include <iostream>
using namespace std;
int main()
{
char str[100][20];
int n;
cout<<"Strings you want to enter"<<endl;
cin>>n;
cout<<"enter n strings"<<endl;
for(int i=0;i<n;i++)
cin>>str[i];
for(int i=0;i<n;i++)
{
if((int)str[i][0]==98) //ascii value b is 98
cout<<str[i]<<endl;
}
return 0;
}
Explanation:
The above written code is for printing the strings which starts with the letter b.
To check if the string starts with a letter b we are checking the ascii value 98 which corresponds to b and then printing those strings.
A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.