Answers for "car python"

3

car in programming python

import os
logo = '''
                         ___________
                         \         /
                          )_______(                           ___   
                          |"""""""|_.-._,.---------.,_.-._   |   |
                          |       | | |               | | ''-|    |
                          |       |_| |_             _| |_..-|    |
                          |_______| '-' `'---------'` '-'    |___|
                          )"""""""(
                         /_________\\
                         
                       .-------------.
                      /_______________\\
'''
print(logo)

bids = {}
bidding_finished = False

def find_highest_bidder(bidding_record):
  highest_bid = 0
  winner = ""
  # bidding_record = {"Angela": 123, "James": 321}
  for bidder in bidding_record:
    bid_amount = bidding_record[bidder]
    if bid_amount > highest_bid: 
      highest_bid = bid_amount
      winner = bidder
  print(f"The winner is {winner} with a bid of ${highest_bid}")

while not bidding_finished:
  name = input("What is your name?: ")
  price = int(input("What is your bid?: $"))
  bids[name] = price
  should_continue = input("Are there any other bidders? Type 'yes or 'no'.\n")
  if should_continue == "no":
    bidding_finished = True
    find_highest_bidder(bids)
  elif should_continue == "yes":
    os.system("cls")
Posted by: Guest on August-18-2021
3

car in programming python

import psutil
import time
import pyttsx3
import os
while True:
    time.sleep(5)
    battery = psutil.sensors_battery()
    print("Battery percentage : ", battery.percent)
    print("Power plugged in : ", battery.power_plugged)
    print()
    if battery.percent < 25 and battery.power_plugged == False:
        print("Your battey is low on power")
        pyttsx3.speak("Your battery is low on power")
        if battery.percent <= 20 and battery.power_plugged == False:
            pyttsx3.speak("power in fast")
            time.sleep(5)
            pyttsx3.speak("Turning my prosegers on")
            time.sleep(10)
            if battery.power_plugged == False:  os.system("shutdown /s /t 1")
    elif battery.percent > 95 and battery.power_plugged == True:
        pyttsx3.speak("Your laptop has charged enough")
        print("Your laptop has charged enough")
Posted by: Guest on June-30-2021
2

car in programming python

import os

bids = {}
bidding_finished = False

def find_highest_bidder(bidding_record):
  highest_bid = 0
  winner = ""
  # bidding_record = {"Angela": 123, "James": 321}
  for bidder in bidding_record:
    bid_amount = bidding_record[bidder]
    if bid_amount > highest_bid: 
      highest_bid = bid_amount
      winner = bidder
  print(f"The winner is {winner} with a bid of ${highest_bid}")

while not bidding_finished:
  name = input("What is your name?: ")
  price = int(input("What is your bid?: $"))
  bids[name] = price
  should_continue = input("Are there any other bidders? Type 'yes or 'no'.\n")
  if should_continue == "no":
    bidding_finished = True
    find_highest_bidder(bids)
  elif should_continue == "yes":
    os.system("cls")
Posted by: Guest on July-03-2021
-1

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()
Posted by: Guest on May-15-2020

Python Answers by Framework

Browse Popular Code Answers by Language