Skip to content

Commit 5089036

Browse files
authored
Most of wk4 assignments
1 parent 9cc20b4 commit 5089036

21 files changed

+116
-0
lines changed

Assessment/Wk4/conditions.docx

14.6 KB
Binary file not shown.

Assessment/Wk4/even.jpg

5.55 KB
Loading

Assessment/Wk4/high_low.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Nothing for a Pair (not in this game)
2+
3+
# imports
4+
import random
5+
6+
# inits
7+
a_cards=["Card Values"]
8+
a_cards.append("Ace")
9+
for i in range(2,11): a_cards.append(i)
10+
a_cards.append("Jack")
11+
a_cards.append("Queen")
12+
a_cards.append("King")
13+
14+
a_suite=["Card Suites"]
15+
a_suite.append("Clubs")
16+
a_suite.append("Diamonds")
17+
a_suite.append("Hearts")
18+
a_suite.append("Spades")
19+
20+
s_success="Congratulations! You're a Winner!"
21+
s_failure="Better luck next time :("
22+
s_invalid="Sorry your guess wasn't understood"
23+
24+
print ( "Higher or Lower - Come on Down " )
25+
print ( "-" * 40)
26+
27+
# deal card
28+
i_card = random.randint(1,13)
29+
i_suite = random.randint(1,4)
30+
31+
print ( f'Your first card {i_card} is a {a_cards[i_card]} of {a_suite[i_suite]}')
32+
33+
your_guess = input("Please enter if you think the next card will be 'higher' or 'lower' :").lower()
34+
35+
print ( f'You guessed {your_guess} ')
36+
37+
# deal card
38+
i_card_2 = random.randint(1,13)
39+
i_suite_2 = random.randint(1,4)
40+
41+
print ( f'Your second card {i_card_2} is a {a_cards[i_card_2]} of {a_suite[i_suite_2]}')
42+
43+
if your_guess=="higher" :
44+
if i_card < i_card_2 :
45+
print ( s_success )
46+
else :
47+
print ( s_failure )
48+
elif your_guess=="lower" :
49+
if i_card > i_card_2 :
50+
print ( s_success )
51+
else :
52+
print ( s_failure )
53+
else :
54+
print ( s_invalid )
55+
print ( s_failure )

Assessment/Wk4/high_low_part1.jpg

77.4 KB
Loading

Assessment/Wk4/high_low_part2.jpg

210 KB
Loading

Assessment/Wk4/high_low_run1.jpg

16.3 KB
Loading

Assessment/Wk4/high_low_run2.jpg

15.5 KB
Loading

Assessment/Wk4/high_low_run3.jpg

17.2 KB
Loading
18.5 KB
Loading

Assessment/Wk4/magpie.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# output a line from a riddle
2+
3+
# inits
4+
a_line=["Magpie or MincePie? "]
5+
a_line.append("One for sorrow")
6+
a_line.append("Two for joy")
7+
a_line.append("Three for a girl")
8+
a_line.append("Four for a boy")
9+
a_line.append("Five for silver")
10+
a_line.append("Six for gold")
11+
a_line.append("Seven for a secret never to be told")
12+
13+
# get user selection
14+
usr_selection = int(input("Enter your chosen line from 1 to 7 : "))
15+
if usr_selection >0 and usr_selection < 8:
16+
print ( str(usr_selection) + ") " + a_line[usr_selection] )
17+
else:
18+
print ( str(usr_selection) + ") " + "Not a permitted number" )
19+

0 commit comments

Comments
 (0)