-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignment4_exercise1-2_0911272.py
More file actions
121 lines (110 loc) · 4.25 KB
/
assignment4_exercise1-2_0911272.py
File metadata and controls
121 lines (110 loc) · 4.25 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
print("Witch exercise do u wanna see? 1, 2 or 3?")
sChoice = input("> ")
if sChoice == 1:
# a:
fahr = float(raw_input("How much Fahrenheit?"))
Celsius = round((fahr - 32) * 5.0/9.0, 2)
print(Celsius)
# b:
bValidFahr = False;
while bValidFahr == False:
Celsius = input("How much Celsius?")
if Celsius >= -273:
Kelvin = round((Celsius + 273), 2)
bValidFahr = True;
else:
Kelvin = "Please give a valid tempature"
print(Kelvin)
# c:
number = input("how much?")
if number < 0:
number = number * -1;
print(number)
elif sChoice == 2:
# a
sPlayer1choise = False
sPlayer2choise = False
sPlayer1Question = "What the choise of player 1? rock, paper, scissors, lizard or spock?"
sPlayer2Question = "What the choise of player 2? rock, paper, scissors, lizard or spock?"
sDrawMessage = "No one wins"
# sPlayer1WinMessage = "Player 1 wins"
# sPlayer2WinMessage = "Player 2 wins"
rock_paper = "Paper covers rock"
rock_scissors = "Rock crushes scissors"
rock_lizard = "Rock crushes lizard"
rock_spock = "Spock vaporizes rock"
paper_scissors = "Scissors cuts paper"
paper_lizard = "Lizard eats paper"
paper_spock = "Paper disproves spock"
scissors_lizard = "Scissors decapitates lizard"
scissors_spock = "Spock smashes scissors"
lizard_spock = "Lizard poisons spock"
sMessage = ""
while sPlayer1choise == False or sPlayer2choise == False:
sPlayer1choise = raw_input(sPlayer1Question).strip('\r')
sPlayer2choise = raw_input(sPlayer2Question).strip('\r')
if sPlayer1choise == "rock":
if sPlayer2choise == "rock":
sMessage = sDrawMessage
elif sPlayer2choise == "paper":
sMessage = rock_paper
elif sPlayer2choise == "scissors":
sMessage = rock_scissors
elif sPlayer2choise == "lizard":
sMessage = rock_lizard
elif sPlayer2choise == "spock":
sMessage = rock_spock
elif sPlayer1choise == "paper":
if sPlayer2choise == "rock":
sMessage = rock_paper
elif sPlayer2choise == "paper":
sMessage = sDrawMessage
elif sPlayer2choise == "scissors":
sMessage = paper_scissors
elif sPlayer2choise == "lizard":
sMessage = paper_lizard
elif sPlayer2choise == "spock":
sMessage = paper_spock
elif sPlayer1choise == "scissors":
if sPlayer2choise == "rock":
sMessage = rock_scissors
elif sPlayer2choise == "paper":
sMessage = paper_scissors
elif sPlayer2choise == "scissors":
sMessage = sDrawMessage
elif sPlayer2choise == "lizard":
sMessage = scissors_lizard
elif sPlayer2choise == "spock":
sMessage = scissors_spock
# b
elif sPlayer1choise == "lizard":
if sPlayer2choise == "rock":
sMessage = rock_lizard
elif sPlayer2choise == "paper":
sMessage = paper_lizard
elif sPlayer2choise == "scissors":
sMessage = scissors_lizard
elif sPlayer2choise == "lizard":
sMessage = sDrawMessage
elif sPlayer2choise == "spock":
sMessage = lizard_spock
elif sPlayer1choise == "spock":
if sPlayer2choise == "rock":
sMessage = rock_spock
elif sPlayer2choise == "paper":
sMessage = paper_spock
elif sPlayer2choise == "scissors":
sMessage = scissors_spock
elif sPlayer2choise == "lizard":
sMessage = lizard_spock
elif sPlayer2choise == "spock":
sMessage = sDrawMessage
else:
sPlayer1choise = False
sPlayer2choise = False
print("please try another input!")
print(sMessage)
elif sChoice == 3:
print("Exercise 3 could be found in folder exercise 3.")
else:
print("Not a valid exercise!")