car in programming python

Solutions on MaxInterview for car in programming python by the best coders in the world

showing results for - "car in programming python"
Ashley
29 Apr 2018
1import os
2logo = '''
3                         ___________
4                         \         /
5                          )_______(                           ___   
6                          |"""""""|_.-._,.---------.,_.-._   |   |
7                          |       | | |               | | ''-|    |
8                          |       |_| |_             _| |_..-|    |
9                          |_______| '-' `'---------'` '-'    |___|
10                          )"""""""(
11                         /_________\\
12                         
13                       .-------------.
14                      /_______________\\
15'''
16print(logo)
17
18bids = {}
19bidding_finished = False
20
21def find_highest_bidder(bidding_record):
22  highest_bid = 0
23  winner = ""
24  # bidding_record = {"Angela": 123, "James": 321}
25  for bidder in bidding_record:
26    bid_amount = bidding_record[bidder]
27    if bid_amount > highest_bid: 
28      highest_bid = bid_amount
29      winner = bidder
30  print(f"The winner is {winner} with a bid of ${highest_bid}")
31
32while not bidding_finished:
33  name = input("What is your name?: ")
34  price = int(input("What is your bid?: $"))
35  bids[name] = price
36  should_continue = input("Are there any other bidders? Type 'yes or 'no'.\n")
37  if should_continue == "no":
38    bidding_finished = True
39    find_highest_bidder(bids)
40  elif should_continue == "yes":
41    os.system("cls")
Jacopo
14 Apr 2017
1import mouse
2inportance = mouse.record("right")
3mouse.play(inportance)
Romina
14 Feb 2019
1import psutil
2import time
3import pyttsx3
4import os
5while True:
6    time.sleep(5)
7    battery = psutil.sensors_battery()
8    print("Battery percentage : ", battery.percent)
9    print("Power plugged in : ", battery.power_plugged)
10    print()
11    if battery.percent < 25 and battery.power_plugged == False:
12        print("Your battey is low on power")
13        pyttsx3.speak("Your battery is low on power")
14        if battery.percent <= 20 and battery.power_plugged == False:
15            pyttsx3.speak("power in fast")
16            time.sleep(5)
17            pyttsx3.speak("Turning my prosegers on")
18            time.sleep(10)
19            if battery.power_plugged == False:  os.system("shutdown /s /t 1")
20    elif battery.percent > 95 and battery.power_plugged == True:
21        pyttsx3.speak("Your laptop has charged enough")
22        print("Your laptop has charged enough")
Elisa
01 Feb 2016
1import os
2
3bids = {}
4bidding_finished = False
5
6def find_highest_bidder(bidding_record):
7  highest_bid = 0
8  winner = ""
9  # bidding_record = {"Angela": 123, "James": 321}
10  for bidder in bidding_record:
11    bid_amount = bidding_record[bidder]
12    if bid_amount > highest_bid: 
13      highest_bid = bid_amount
14      winner = bidder
15  print(f"The winner is {winner} with a bid of ${highest_bid}")
16
17while not bidding_finished:
18  name = input("What is your name?: ")
19  price = int(input("What is your bid?: $"))
20  bids[name] = price
21  should_continue = input("Are there any other bidders? Type 'yes or 'no'.\n")
22  if should_continue == "no":
23    bidding_finished = True
24    find_highest_bidder(bids)
25  elif should_continue == "yes":
26    os.system("cls")
Filippo
19 Feb 2019
1#pip install rotate-screen
2import rotatescreen
3import time
4screen = rotatescreen.get_primary_display()
5for i in range(4):
6    time.sleep(3)
7    screen.rotate_to(i*90 % 360)
8
9
Jana
01 Jun 2018
1class Car:
2    def __init__(self, year, make, speed):
3        self.__year_model = year
4        self.__make = make
5        self.__speed = 0
6
7    def set_year_model(self, year):
8        self.__year_model = year
9
10    def set_make(self, make):
11        self.__make = make
12
13    def set_speed(self, speed):
14        self.__speed = 0
15
16    def get_year_model(self):
17        return self.__year_model
18
19    def get_make(self):
20        return self.__make
21
22    def get_speed(self):
23        return self.__speed
24
25    #methods
26    def accelerate(self):
27        self.__speed +=5
28
29    def brake(self):
30        self.__speed -=5
31
32    def get_speed(self):
33        return self.__speed
34
35def main():
36
37    year = input('Enter the car year: ')
38    make = input('Enter the car make: ')
39    speed = 0
40
41    mycar = Car(year, make, speed)
42
43    #Accelerate 5 times
44    mycar.accelerate()
45    print('The current speed is: ', mycar.get_speed())
46    mycar.accelerate()
47    print('The current speed is: ', mycar.get_speed())
48    mycar.accelerate()
49    print('The current speed is: ', mycar.get_speed())
50    mycar.accelerate()
51    print('The current speed is: ', mycar.get_speed())
52    mycar.accelerate()
53    print('The current speed is: ', mycar.get_speed()) 
54
55    #Brake 5 times
56    mycar.brake()
57    print('The current speed after brake is: ', mycar.get_speed())
58    mycar.brake()
59    print('The current speed after brake is: ', mycar.get_speed())
60    mycar.brake()
61    print('The current speed after brake is: ', mycar.get_speed())
62    mycar.brake() 
63    print('The current speed after brake is: ', mycar.get_speed())
64    mycar.brake()
65    print('The current speed after brake is: ', mycar.get_speed())
66
67#Call the main function
68main()