-
Notifications
You must be signed in to change notification settings - Fork 0
/
basics1.py
34 lines (33 loc) · 877 Bytes
/
basics1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## While Loops and use of if conditions in Python
count=0
while count<3:
number = int(input("Guess the number:"))
if number == 5:
print("Correct guess")
break
count=count+1
command = ""
started = False
while True:
command = input("Enter a command: ").lower()
if command == "help":
print("Start- To start the car")
print("Stop- To stop the car")
print("Quit- To quit")
elif command == "start":
if started:
print("Car is already started")
continue
else:
started = True
print("Car started")
elif command == "stop":
if not started:
print("Car is already stopped")
else:
started = False
print("Car is stopped")
elif command == "quit":
break
else:
print("Undefined Command")