-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (50 loc) · 1.26 KB
/
main.py
File metadata and controls
59 lines (50 loc) · 1.26 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Project 1
print("Hello, world!")
# Project 2
# This project fails because we need to add a float() around the inputs!
num1 = input("Enter a number: ")
num2 = input("Enter a number: ")
result = num1 + num2
print(result)
num1 = float(input("Enter a number: "))
num2 = float(input("Enter a number: "))
result = num1 + num2
print("Result:", result)
# Project 3
age = 17
if age >= 18:
print("Welcome to the club")
else:
print("You're too young!")
# Project 4
for countdown in range(10, 0, -1):
print(str(countdown) + "!")
print("Liftoff!")
countdown = 10
while countdown > 0:
print(str(countdown) + "!")
countdown -= 1
print("Liftoff!")
# Project 5
while True:
direction = input("Enter a direction [N/E/S/W]: ")
if direction == "N":
print("You fall into a trap and died! Try again!")
elif direction == "E":
print("You get lost in a forest! Try again!")
elif direction == "S":
print("You found the treasure! Congrats!")
break
elif direction == "W":
print("You run into a band of angry goblins who rob you! Try again!")
else:
print("Unknown direction!")
# Project 6
"""
Same as project 5, but they can traverse the following map:
S###T
Key:
S - start
# - movable space
T - treasure (end)
"""