Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

car in programming python

import mouse
inportance = mouse.record("right")
mouse.play(inportance)
Comment

car python program

class Car:
    def __init__(self, year, make, speed):
        self.__year_model = year
        self.__make = make
        self.__speed = 0

    def set_year_model(self, year):
        self.__year_model = year

    def set_make(self, make):
        self.__make = make

    def set_speed(self, speed):
        self.__speed = 0

    def get_year_model(self):
        return self.__year_model

    def get_make(self):
        return self.__make

    def get_speed(self):
        return self.__speed

    #methods
    def accelerate(self):
        self.__speed +=5

    def brake(self):
        self.__speed -=5

    def get_speed(self):
        return self.__speed

def main():

    year = input('Enter the car year: ')
    make = input('Enter the car make: ')
    speed = 0

    mycar = Car(year, make, speed)

    #Accelerate 5 times
    mycar.accelerate()
    print('The current speed is: ', mycar.get_speed())
    mycar.accelerate()
    print('The current speed is: ', mycar.get_speed())
    mycar.accelerate()
    print('The current speed is: ', mycar.get_speed())
    mycar.accelerate()
    print('The current speed is: ', mycar.get_speed())
    mycar.accelerate()
    print('The current speed is: ', mycar.get_speed()) 

    #Brake 5 times
    mycar.brake()
    print('The current speed after brake is: ', mycar.get_speed())
    mycar.brake()
    print('The current speed after brake is: ', mycar.get_speed())
    mycar.brake()
    print('The current speed after brake is: ', mycar.get_speed())
    mycar.brake() 
    print('The current speed after brake is: ', mycar.get_speed())
    mycar.brake()
    print('The current speed after brake is: ', mycar.get_speed())

#Call the main function
main()
Comment

PREVIOUS NEXT
Code Example
Python :: typing racer 
Python :: python selenium print xpath of element 
Python :: min max python 
Python :: python ternary operators 
Python :: flatten lists python 
Python :: import libraries to Jupyter notebook 
Python :: reading a dataset in python 
Python :: np minimum of array 
Python :: rabbitmq python 
Python :: how to use multiple keys for single value in dictionary python 
Python :: arithmetic operators in python 
Python :: precedence in python 
Python :: find key by value python 
Python :: copy multiple files from one folder to another folder 
Python :: python default dictionary 
Python :: list comprehension in python 
Python :: iterating over lines in a file 
Python :: activate venv in python 
Python :: indent python 
Python :: how to create a save command in python 
Python :: ajouter dans une liste python 
Python :: # Import KNeighborsClassifier from sklearn.neighbors 
Python :: geometric progression in python 
Python :: print something python 
Python :: python infinite loop 
Python :: remove timezone from column pandas 
Python :: Reverse an string Using Reversed 
Python :: pyplot histogram labels in center 
Python :: how to give values to all users with discord api python grepper 
Python :: Convert the below Series to pandas datetime : DoB = pd.Series(["07Sep59","01Jan55","15Dec47","11Jul42"]) 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =