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 :: how to find index of second largest number in array python 
Python :: read csv without index 
Python :: python exe not working on other pc 
Python :: Violin Plots in Seaborn 
Python :: how to find the multiples of a number in python 
Python :: UnavailableInvalidChannel error in conda 
Python :: huggingface default cache dir 
Python :: python dividing strings by amount of letters 
Python :: add font to the label in window tkinter 
Python :: python shuffle list with seed 
Python :: pandas to csv float format 
Python :: python check numpy arrays equal 
Python :: pandas plot histogram 
Python :: todense() 
Python :: python set a specific datetime 
Python :: python code to open windows command prompt 
Python :: how to make a window in tkinter 
Python :: how to find the text inside button in tkinter 
Python :: python slice an array 
Python :: parse list from string 
Python :: set jupyer color to dark 
Python :: csv reader python skip header 
Python :: django static media 
Python :: how to sort dictionary in python by value 
Python :: how to create a python venv 
Python :: python turtle background image 
Python :: python candlestick chart 
Python :: if in lambda function python 
Python :: python delete file with extension 
Python :: python os filename without extension 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =