diff --git a/Part_12_Hello_World/main.py b/Part_12_Hello_World/main.py deleted file mode 100644 index bc4200d..0000000 --- a/Part_12_Hello_World/main.py +++ /dev/null @@ -1 +0,0 @@ -print('Hello, World!') \ No newline at end of file diff --git a/Part_13_Debugging_Hello_World/main.py b/Part_13_Debugging_Hello_World/main.py deleted file mode 100644 index 0e69652..0000000 --- a/Part_13_Debugging_Hello_World/main.py +++ /dev/null @@ -1,2 +0,0 @@ -import pdb;pdb.set_trace() -print('Hello, World!') \ No newline at end of file diff --git a/Part_14_IO/main.py b/Part_14_IO/main.py deleted file mode 100644 index ba6c777..0000000 --- a/Part_14_IO/main.py +++ /dev/null @@ -1,2 +0,0 @@ -name = input('Tell Me Your Name: ') -print(f'Hi {name}!') \ No newline at end of file diff --git a/Part_15_Debugging_IO/main.py b/Part_15_Debugging_IO/main.py deleted file mode 100644 index 850313a..0000000 --- a/Part_15_Debugging_IO/main.py +++ /dev/null @@ -1,3 +0,0 @@ -import pdb;pdb.set_trace() -name = input('Tell Me Your Name: ') -print(f'Hi {name}!') \ No newline at end of file diff --git a/Part_1_Basic_IO/0001_hello_world_repl.py b/Part_1_Basic_IO/0001_hello_world_repl.py new file mode 100644 index 0000000..73fb7c3 --- /dev/null +++ b/Part_1_Basic_IO/0001_hello_world_repl.py @@ -0,0 +1 @@ +print('Hello World!') diff --git a/Part_1_Basic_IO/0002_hello_world.py b/Part_1_Basic_IO/0002_hello_world.py new file mode 100644 index 0000000..25098ab --- /dev/null +++ b/Part_1_Basic_IO/0002_hello_world.py @@ -0,0 +1,3 @@ +from microbit import display + +display.scroll('Hello World!') diff --git a/Part_1_Basic_IO/0003_hello_world_talk.py b/Part_1_Basic_IO/0003_hello_world_talk.py new file mode 100644 index 0000000..2adc5e7 --- /dev/null +++ b/Part_1_Basic_IO/0003_hello_world_talk.py @@ -0,0 +1,8 @@ +from microbit import display, Image +from speech import say + +SPEED = 95 + +display.show(Image.SURPRISED) +say('Hello World!', speed=SPEED) +display.show(Image.HAPPY) diff --git a/Part_1_Basic_IO/0004_basic_io_repl.py b/Part_1_Basic_IO/0004_basic_io_repl.py new file mode 100644 index 0000000..6b76d52 --- /dev/null +++ b/Part_1_Basic_IO/0004_basic_io_repl.py @@ -0,0 +1,14 @@ +# We introduce the concept of a variable to which +# we reserve a little box in our computer's memory +# to hold the string which we are going to type +# when prompted to provide our favorite food and +# favorite drink +favorite_food = input('What is your favorite food? ') +favorite_drink = input('What is your favorite drink? ') + +# Here we use MicroPython's built-in format method +# which is part of the string module's Formatter +# class as the following line of code will provide +# a response back based to the console based on +# our two variables which we inputted above +print('I love {0} and {1} as well!'.format(favorite_food, favorite_drink)) diff --git a/Part_1_Basic_IO/p_0001_candy_name_generator.py b/Part_1_Basic_IO/p_0001_candy_name_generator.py new file mode 100644 index 0000000..e1bccbb --- /dev/null +++ b/Part_1_Basic_IO/p_0001_candy_name_generator.py @@ -0,0 +1,4 @@ +candy_title = input('What is the candy title? ') +candy_flavor = input('What is the candy flavor? ') + +print('It shall be called {0} {1}!'.format(candy_title, candy_flavor)) diff --git a/Part_1_Basic_IO/p_0001_candy_name_generator_ec.py b/Part_1_Basic_IO/p_0001_candy_name_generator_ec.py new file mode 100644 index 0000000..7c8bee3 --- /dev/null +++ b/Part_1_Basic_IO/p_0001_candy_name_generator_ec.py @@ -0,0 +1,12 @@ +from microbit import display, Image +from speech import say + +SPEED = 95 + +candy_title = input('What is the candy title? ') +candy_flavor = input('What is the candy flavor? ') + +display.show(Image.SURPRISED) +print('It shall be called {0} {1}!'.format(candy_title, candy_flavor)) +say('It shall be called {0} {1}!'.format(candy_title, candy_flavor)) +display.show(Image.HAPPY) diff --git a/Part_21_Integer_Primitive_Data_Type/main.py b/Part_21_Integer_Primitive_Data_Type/main.py deleted file mode 100644 index 07aff6b..0000000 --- a/Part_21_Integer_Primitive_Data_Type/main.py +++ /dev/null @@ -1,4 +0,0 @@ -x = 10 -y = -10 - -print(x / y) \ No newline at end of file diff --git a/Part_22_Float_Primitive_Data_Type/main.py b/Part_22_Float_Primitive_Data_Type/main.py deleted file mode 100644 index 2b9456a..0000000 --- a/Part_22_Float_Primitive_Data_Type/main.py +++ /dev/null @@ -1,4 +0,0 @@ -x = 10.1 -y = -9.5 - -print(x / y) \ No newline at end of file diff --git a/Part_23_String_Primitive_Data_Type/main.py b/Part_23_String_Primitive_Data_Type/main.py deleted file mode 100644 index 0ac0c43..0000000 --- a/Part_23_String_Primitive_Data_Type/main.py +++ /dev/null @@ -1,3 +0,0 @@ -greeting = 'Hello World!' - -print(greeting) \ No newline at end of file diff --git a/Part_24_Bool_Primitive_Data_Type/main.py b/Part_24_Bool_Primitive_Data_Type/main.py deleted file mode 100644 index 45328af..0000000 --- a/Part_24_Bool_Primitive_Data_Type/main.py +++ /dev/null @@ -1,14 +0,0 @@ -is_hungry = True - -print(type(is_hungry)) - -print(is_hungry > 0) -print(is_hungry <= 0) - -# When you compare two values, the expression is eval to either True -# or false -print(100 > 1) -print(100 < 10) -print(42 == 42) -print(42 != 42) -print(42 == 4) \ No newline at end of file diff --git a/Part_25_Bytes_Primitive_Data_Type/main.py b/Part_25_Bytes_Primitive_Data_Type/main.py deleted file mode 100644 index f497a8b..0000000 --- a/Part_25_Bytes_Primitive_Data_Type/main.py +++ /dev/null @@ -1,5 +0,0 @@ -b_str = 'Hello world!' - -b_arr = bytes(b_str, 'utf-8') - -print(b_arr) \ No newline at end of file diff --git a/Part_26_Bytearray_Primitive_Data_Type/main.py b/Part_26_Bytearray_Primitive_Data_Type/main.py deleted file mode 100644 index f12d36f..0000000 --- a/Part_26_Bytearray_Primitive_Data_Type/main.py +++ /dev/null @@ -1,35 +0,0 @@ -# Array of bytes from an int -# when an int is passed as an arg it creates an array -# of that size and init the area to null bytes -magic_number = 42 - -ba = bytearray(magic_number) - -print(ba) - - -# Array of bytes from a str -# when a str is passed we have to provide the encoding -# so we will use utf-8 -magic_str = "forty-two" - -# Provide the encoding along with string -ba = bytearray(magic_str, 'utf-8') - -print(ba) - - -# Array of bytes from a list -# when a list is passed it returns the mutable sequence of bytes -magic_list = [42, 255, 6] - -ba = bytearray(magic_list) - -print(ba) - - -# No param -# when no praram is passed it creates an array of size 0 or empty -ba = bytearray() - -print(ba) \ No newline at end of file diff --git a/Part_27_Variables/main.py b/Part_27_Variables/main.py deleted file mode 100644 index ebf318f..0000000 --- a/Part_27_Variables/main.py +++ /dev/null @@ -1,25 +0,0 @@ -name = 'Kevin' - -print(name) - - -# name[0] = 'L' -# Traceback (most recent call last): -# File "c:\users\kevin\mu_code\main.py", line 5, in -# name[0] = 'L' -#TypeError: 'str' object does not support item assignment -# >>> - - -name = 'Keith' - -print(name) - - -print(type(name)) - - -name = 42 - -print(name) -print(type(name)) \ No newline at end of file diff --git a/Part_29_Conditional_Logic/0002_heads_or_tails_game.py b/Part_29_Conditional_Logic/0002_heads_or_tails_game.py deleted file mode 100644 index c17f193..0000000 --- a/Part_29_Conditional_Logic/0002_heads_or_tails_game.py +++ /dev/null @@ -1,13 +0,0 @@ -from random import randint - -random_number = randint(1, 2) - -choice = input('Enter A - Heads OR B - Tails: ').lower() -if random_number == 1 and choice == 'a': - print('You WON!') -elif random_number == 1 and choice == 'b': - print('You Lost') -elif random_number == 2 and choice == 'b': - print('You Won!') -else: - print('You Lost') \ No newline at end of file diff --git a/Part_28_Mathematical_Operations/main.py b/Part_2_DataTypes_+_Numbers/0005_calculator_repl.py similarity index 79% rename from Part_28_Mathematical_Operations/main.py rename to Part_2_DataTypes_+_Numbers/0005_calculator_repl.py index e40fa2d..4ed9d7d 100644 --- a/Part_28_Mathematical_Operations/main.py +++ b/Part_2_DataTypes_+_Numbers/0005_calculator_repl.py @@ -1,22 +1,15 @@ -print(5 * (9 + 5) / 3 - 3) - -# First: (9 + 5) = 14 -# Second: 5 * 14 = 70 -# Third: 70 / 3 = 23.33334 -# Fourth: 23.33334 - 3 = 20.33334 - - first_number = int(input('Enter First Number: ')) second_number = int(input('Enter Second Number: ')) + my_addition = first_number + second_number my_subtraction = first_number - second_number my_multiplication = first_number * second_number my_division = first_number / second_number + print('Addition = {0}'.format(my_addition)) print('Subtraction = {0}'.format(my_subtraction)) print('Multiplication = {0}'.format(my_multiplication)) print('Division = {0}'.format(my_division)) print(type(my_division)) - diff --git a/Part_2_DataTypes_+_Numbers/0006_square_footage_repl.py b/Part_2_DataTypes_+_Numbers/0006_square_footage_repl.py new file mode 100644 index 0000000..f7a9981 --- /dev/null +++ b/Part_2_DataTypes_+_Numbers/0006_square_footage_repl.py @@ -0,0 +1,9 @@ +from microbit import display + +length = float(input('Enter length: ')) +width = float(input('Enter width: ')) + +square_footage = length * width + +print('Your room size is {0} square feet.'.format(square_footage)) +display.scroll('Your room size is {0} square feet.'.format(square_footage)) diff --git a/Part_2_DataTypes_+_Numbers/0007_final_score_talk_repl.py b/Part_2_DataTypes_+_Numbers/0007_final_score_talk_repl.py new file mode 100644 index 0000000..5f17515 --- /dev/null +++ b/Part_2_DataTypes_+_Numbers/0007_final_score_talk_repl.py @@ -0,0 +1,15 @@ +from microbit import display, Image +from speech import say + +SPEED = 95 + +player_score = int(input('Enter Player Score: ')) +player_score_bonus = int(input('Enter Player Score Bonus: ')) +player_has_golden_ticket = True + +player_final_score = player_score + player_score_bonus + +display.show(Image.SURPRISED) +print('Player final score is {0} and has golden ticket is {1}.'.format(player_final_score, player_has_golden_ticket)) +say('Player final score is {0} and has golden ticket is {1}.'.format(player_final_score, player_has_golden_ticket)) +display.show(Image.HAPPY) \ No newline at end of file diff --git a/Part_2_DataTypes_+_Numbers/p_0002_talking_madlibs.py b/Part_2_DataTypes_+_Numbers/p_0002_talking_madlibs.py new file mode 100644 index 0000000..08b7332 --- /dev/null +++ b/Part_2_DataTypes_+_Numbers/p_0002_talking_madlibs.py @@ -0,0 +1,15 @@ +from microbit import display, Image +from speech import say + +SPEED = 95 + +noun = input('Enter Noun: ') +verb = input('Enter Verb: ') +miles = int(input('Enter Miles: ')) + +display.show(Image.SURPRISED) +print('My {0} are {1}!'.format(noun, verb)) +say('My {0} are {1}!'.format(noun, verb)) +print('It traveled {0} miles!'.format(miles)) +say('It traveled {0} miles!'.format(miles)) +display.show(Image.HAPPY) diff --git a/Part_32_Classes/0007_escape_room/main.py b/Part_32_Classes/0007_escape_room/main.py deleted file mode 100644 index 5d9099e..0000000 --- a/Part_32_Classes/0007_escape_room/main.py +++ /dev/null @@ -1,70 +0,0 @@ -from time import sleep -from data import questions -from Grid import Grid -from EscapeRoomPlayer import EscapeRoomPlayer -from FileManager import FileManager -from Game import Game - -grid = Grid(5, 5) -player = EscapeRoomPlayer() -file_manager = FileManager() -game = Game() - -if __name__ == '__main__': - player_location = None - response = None - final_question = False - - while True: - # To ensure we do not generate a question if the player is hitting a wall - # or not entering a valid move - previous_player_location = player_location - clear_screen = grid.clear_screen() - update_grid = grid.update(player) - print(clear_screen) - print(update_grid) - key = input('Enter A, D, W, S: ') - if key == 'a': - player_location = player.move_west(grid) - elif key == 'd': - player_location = player.move_east(grid) - elif key == 'w': - player_location = player.move_north(grid) - elif key == 's': - player_location = player.move_south(grid) - else: - pass - random_location = (x, y) = game.generate_random_numbers(grid) - if random_location == player_location and random_location != previous_player_location: - random_question, answer_1, answer_2, answer_3, correct_answer_index, correct_answer \ - = game.ask_random_question(questions) - print(random_question) - print('Press 1 for {0}.'.format(answer_1)) - print('Press 2 for {0}.'.format(answer_2)) - print('Press 3 for {0}.'.format(answer_3)) - while True: - try: - response = int(input('ENTER: ')) - break - except ValueError: - print('Enter ONLY 1, 2 or 3!') - if response == correct_answer_index + 1: - print(game.correct_answer_response()) - inventory = player.get_inventory(file_manager) - player.inventory.append(inventory) - if 'Red Key' in player.inventory: - final_question = True - if 'Red Key' not in player.inventory and not final_question: - receive_red_key = game.generate_random_number(grid) - if receive_red_key == 2: - print(player.pick_up_red_key(file_manager)) - final_question = True - else: - print(player.without_red_key()) - elif final_question: - print(game.win(file_manager)) - sleep(3) - break - else: - print(game.incorrect_answer_response(correct_answer)) - sleep(3) diff --git a/Part_33_Unittest/0007_escape_room/.idea/workspace.xml b/Part_33_Unittest/0007_escape_room/.idea/workspace.xml deleted file mode 100644 index 47131a6..0000000 --- a/Part_33_Unittest/0007_escape_room/.idea/workspace.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1613302042689 - - - - - - - - file://$PROJECT_DIR$/main.py - 69 - - - - - \ No newline at end of file diff --git a/Part_33_Unittest/0007_escape_room/inventory b/Part_33_Unittest/0007_escape_room/inventory deleted file mode 100644 index e69de29..0000000 diff --git a/Part_33_Unittest/0007_escape_room/main.py b/Part_33_Unittest/0007_escape_room/main.py deleted file mode 100644 index 5d9099e..0000000 --- a/Part_33_Unittest/0007_escape_room/main.py +++ /dev/null @@ -1,70 +0,0 @@ -from time import sleep -from data import questions -from Grid import Grid -from EscapeRoomPlayer import EscapeRoomPlayer -from FileManager import FileManager -from Game import Game - -grid = Grid(5, 5) -player = EscapeRoomPlayer() -file_manager = FileManager() -game = Game() - -if __name__ == '__main__': - player_location = None - response = None - final_question = False - - while True: - # To ensure we do not generate a question if the player is hitting a wall - # or not entering a valid move - previous_player_location = player_location - clear_screen = grid.clear_screen() - update_grid = grid.update(player) - print(clear_screen) - print(update_grid) - key = input('Enter A, D, W, S: ') - if key == 'a': - player_location = player.move_west(grid) - elif key == 'd': - player_location = player.move_east(grid) - elif key == 'w': - player_location = player.move_north(grid) - elif key == 's': - player_location = player.move_south(grid) - else: - pass - random_location = (x, y) = game.generate_random_numbers(grid) - if random_location == player_location and random_location != previous_player_location: - random_question, answer_1, answer_2, answer_3, correct_answer_index, correct_answer \ - = game.ask_random_question(questions) - print(random_question) - print('Press 1 for {0}.'.format(answer_1)) - print('Press 2 for {0}.'.format(answer_2)) - print('Press 3 for {0}.'.format(answer_3)) - while True: - try: - response = int(input('ENTER: ')) - break - except ValueError: - print('Enter ONLY 1, 2 or 3!') - if response == correct_answer_index + 1: - print(game.correct_answer_response()) - inventory = player.get_inventory(file_manager) - player.inventory.append(inventory) - if 'Red Key' in player.inventory: - final_question = True - if 'Red Key' not in player.inventory and not final_question: - receive_red_key = game.generate_random_number(grid) - if receive_red_key == 2: - print(player.pick_up_red_key(file_manager)) - final_question = True - else: - print(player.without_red_key()) - elif final_question: - print(game.win(file_manager)) - sleep(3) - break - else: - print(game.incorrect_answer_response(correct_answer)) - sleep(3) diff --git a/Part_33_Unittest/0007_escape_room/tests/inventory b/Part_33_Unittest/0007_escape_room/tests/inventory deleted file mode 100644 index e69de29..0000000 diff --git a/Part_3_Conditional_Logic/0008_career_councelor_repl.drawio b/Part_3_Conditional_Logic/0008_career_councelor_repl.drawio new file mode 100644 index 0000000..0967e4c --- /dev/null +++ b/Part_3_Conditional_Logic/0008_career_councelor_repl.drawio @@ -0,0 +1 @@ +7VnbctowFPwaHtPxBUzyWG5J2jTTNhfaR8UWtopsUVlg6Nf3CMs3pISkDWGG8ALW0ZFl7ersytBy+/HynKNZ9IUFmLYcK1i23EHLcWzL8eBLRlZ5pHPWzgMhJ4FKqgI35A8uRqronAQ4bSQKxqggs2bQZ0mCfdGIIc5Z1kybMNqcdYZCrAVufET16JgEIsqjp063il9gEkbFzLZ3lvfEqEhWK0kjFLCsFnKHLbfPGRP5VbzsYyrBK3AZX67G9GrqnX/6lv5Gd73Pt9f3J/nNRi8ZUi6B40T8862zpZOl7hQvg8u70x8X8T0dnKsh1gLRucJLrVWsCgBxAHiqJuMiYiFLEB1W0R5n8yTAchoLWlXOFWMzCNoQ/IWFWKnNgeaCQSgSMVW9+Zxyog3OtixY5aVszn38RJ6r9h3iIX7qfl7JKpQDZjEWfAXjOKZIkEXz4ZDal2GZV2EPFwr+F7DsalSMIyTkqFTuxtV6PEbyPjdsIjIABy6HSUgSjDlJQllEEMS85Y40FiuOJOBZRAS+maE1ahkUfpOPCUuEIssGQHohRWmq6E0FZ9OylGR2WRdWSeVzmVtgLvCyhqsOftHbUVtVyVBbNbOqpu0iFtXq+dT6f7qMlWNrdB1i5XjPrBzbMrP36qVj5MI5clHL6+5TxTyNigGTVcvm8EnJVGoWnAdImOSKhWbyHGDQq4jFD/N0u1Y11EcK1wjFhEqVuMB0gQXxkUHREIUngIYP1EjBNMkaTCmf0R14Vet2vRdO2rtUOrvTUDrb06WuPF3Vpa7Uv1cntauR+h3DgtK6AR2c47StpuOUmNctxzHw8Bo0GGVOPyEcoswVMG/3HGefntM+ktFIfKSY3sZ1bP09Rrcdn2N4FOk6HoWl9B5As7xQXmX4Qb0KHr1ow4vcD92mHblGO3I+dAyG5O7KkGz99P11BcWTQGzEAd+TYRLA9QBsirLZAbpTeSoofpYx0LIzd3pCjs2c9JA/PXhKNg8Mbauz5wNDR2Pkmmmww+rEhoyt8eszykCNBglLpFVNCKUbIU24JFagcfSj6ohJEKx9zkRm0/seAfu5PD1Kitvefooz/W7g7IoT/QXp3XNiKpQ35UR/v/kJJ4H3RUqJbuHzzp4L5exIikZKZ3fqBc3qr4x1X+0PIXf4Fw== \ No newline at end of file diff --git a/Part_3_Conditional_Logic/0008_career_councelor_repl.png b/Part_3_Conditional_Logic/0008_career_councelor_repl.png new file mode 100644 index 0000000..4a29b01 Binary files /dev/null and b/Part_3_Conditional_Logic/0008_career_councelor_repl.png differ diff --git a/Part_29_Conditional_Logic/0001_career_councelor.py b/Part_3_Conditional_Logic/0008_career_councelor_repl.py.py similarity index 100% rename from Part_29_Conditional_Logic/0001_career_councelor.py rename to Part_3_Conditional_Logic/0008_career_councelor_repl.py.py diff --git a/Part_3_Conditional_Logic/0009_heads_or_tails_game.drawio b/Part_3_Conditional_Logic/0009_heads_or_tails_game.drawio new file mode 100644 index 0000000..35f1f6e --- /dev/null +++ b/Part_3_Conditional_Logic/0009_heads_or_tails_game.drawio @@ -0,0 +1 @@ +7VpdU+IwFP0t+8AjOyT9AB8F/Fpdd3dYV/FlJ9LYRtMG01TAX78JpLQlBXFnoCq8YHKTNMk995x7i9SsTjg+4WgYfGcepjXY8MY1q1uDEDSgK/8oy2RmcQ7smcHnxNOTMkOPvOB0pbYmxMNxYaJgjAoyLBoHLIrwQBRsiHM2Kk67Z7S46xD52DD0Boia1mviiWBmbcFmZj/FxA/SnYF7MBsJUTpZ3yQOkMdGOZN1VLM6nDExa4XjDqbKealfrs8m1/Ti0T359it+Qlft89+Xf+qzhx2/Zcn8ChxH4r8fHXCrI27xz2b/5mj866l19tJ+qqdXE5PUX9iT7tNdxkXAfBYhepRZ25wlkYfVUxuyl825YGwojUAaH7AQEx0LKBFMmgIRUj2Kx0Tc6OWq3Vftr47udce5oe4k7USCT26yiarbz49ly6a9dN3sfupSC+Hwii/1vJglfIBXzLN0SCPu41XPc+cBI5mGWYjlIeU6jikS5Ll4OKRD3p/Py2CVDY3sG1AGVaIMPifKI+/4of7Q+9s/77E27+Kr2wtSb2wJ5VWHfEY00TuFZMAlKod3RCiFDRiLpRTLrdWZUOSxUDaiJLzDXDbusBhhHMkWUHMiT37Cr0boZIGhkB0FRODeEE3dN5IppBgE9ywSOkKA9EzbpyiONWix4OxxLspq9lxhM0zXhfAZc4HHOQebKOhR6GjRSxOa7o6y7ABa2hbkMoPd2BA7YaUaPGdkPzfysdjprqnBoFJ6ugY9u0RRLImn7BtyHCtuigDLz0PFx0QIFtWsY5OCAQvvkvh1+hUIpbh4jEJCFS6nmD5jQQaohKSIEl/u2x1IeOTZSpkqtySRL3tu1vs9jb26vUHyOk6BuwCWkNcpIS+wNsVe24C1CjpvmmJpNf9qBgSwykKnuQcjD8ZBlXqXntIQvLKqpLQgAXvtK2hfsW6xQIn2uWXaBzalfWbF+cHptryoX4NtcFvSt+qU65UX7X15UUox262yvliu4QVcr2aIXv+4/GJC98Ffzhb8b5e9nFkl/oebcj+Ay/x/wWLx6fwPmwtJJi24twFAaY5xdiLHpLd6PclU+kWi+Q6722DYVWZ8aErTGwtsuM/+xexfZYW9IsJ2Jv3bzfeW/6EpeZ85/7ut95b/W4b/++p/GAt+l9cTC+o0dWCHUSZFphuxSKWee0LpgsnQI+UsKV30UA+ExPOmeasMzWIuW+LtdYFaisrc45OFKi2Hir1NUMyXkt0DxbHfGSglX7jtHiqLVLFL3uC3iwrYowId572hYtbOl2zHQJl7N831dtWgmN8n7xworrU1UGQ3+/HadCz3E0Dr6B8= \ No newline at end of file diff --git a/Part_3_Conditional_Logic/0009_heads_or_tails_game.png b/Part_3_Conditional_Logic/0009_heads_or_tails_game.png new file mode 100644 index 0000000..b747d51 Binary files /dev/null and b/Part_3_Conditional_Logic/0009_heads_or_tails_game.png differ diff --git a/Part_3_Conditional_Logic/0009_heads_or_tails_game.py b/Part_3_Conditional_Logic/0009_heads_or_tails_game.py new file mode 100644 index 0000000..c0b9823 --- /dev/null +++ b/Part_3_Conditional_Logic/0009_heads_or_tails_game.py @@ -0,0 +1,23 @@ +from random import randint +from microbit import display, button_a, button_b + +display.scroll('Heads = A') +display.scroll('Tails = B') +random_number = randint(1, 2) + +while True: + if button_a.is_pressed(): + if random_number == 1: + display.scroll('You WON!') + break + else: + display.scroll('You Lost') + break + + if button_b.is_pressed(): + if random_number == 2: + display.scroll('You WON!') + break + else: + display.scroll('You Lost') + break \ No newline at end of file diff --git a/Part_3_Conditional_Logic/p_0003_talking_number_guessing_game.drawio b/Part_3_Conditional_Logic/p_0003_talking_number_guessing_game.drawio new file mode 100644 index 0000000..9bc282d --- /dev/null +++ b/Part_3_Conditional_Logic/p_0003_talking_number_guessing_game.drawio @@ -0,0 +1 @@ +7Vvblto2FP0aHjML3+ER5tZJ06w2tJ3OU5ewNbaDbDmSGCBfH8mWb8gMTCbG3J6wjo9leW/tc3SjZ1xHy3sCkuAP7EHU0/vesmfc9HRd79s6/xGWVWbRNMvMLD4JPWkrDZPwO5TGvrTOQw/SmiPDGLEwqRtdHMfQZTUbIAQv6m7PGNXfmgAfKoaJC5BqfQw9FmTWge6U9t9g6Af5mzV7mN2JQO4sv4QGwMOLism47RnXBGOWXUXLa4gEejkujw+rR/RpZt9//It+A/+Mf//7878fssru3vJI8QkExuynq74f0C/eZPrx8ctoptlf777TyeyDIcmkbJUDBj2OnyxiwgLs4xig29I6Jngee1BU2+el0ucTxgk3atz4FTK2kp0BzBnmpoBFSN6Fy5D9Jx6/smTpqXLnZilrTgsrWcjaKRq3xusWUKQfxXPiwleQkCQzQHzIXvHTC+a5ZiCOICMr/hyBCLDwpd44IPuuX/iV/PALSdEb6JKNfAFonn8Lbyx/O4g9HPGLeB5NIblSSC0pEygvgpDBSQJSQBZc+HV6nnHMJHca/9axjwClkgbKCJ4VShLehSxKll4gYXD5EzypuMpaDFPjfSWtKQ9EEotFKWrNlC5BRdBGvyUuDOtYpMOBJ6vKQ6L4VL1XPpaW9iU5fUfJOV1KTlckN0kllynt/wTTkIU4PgfJOZ1Lzr5I7n2Sc3bNchv6xn405yiai0KXcFpG01BojyYQzKgYXIIIispirpG5K3RIT1CI+Yg7z3xGgw7zQWpVh2ZbOrRNhaAuhNl6fsrnK9vUYg06zVCawsZNSBMEVkWaEqicUaIqpmydZSrLUDh54rPgdeg5EqyOb4bhNUaYcEuMY6GU5xChNRNAoR/zosuR4/waY4FryKe9I3kjCj0vlVkToXXptUWMqdUDl9lAi9kQt/S2WHEGZxG3LHvHuOXYXcatvJm1uOVxw5ymEaun20ioY8oLti+uEgKpSPujnnGnEFePPvqarAKQCL9o6Yt1rqtnhBduAAi78qAbUh4XNyilLW1ow349ZA0bQla/QRyF8derY3ge6th1DOx0Ou+01EHwjuoYH786LPPg1GGro6yTVMdgR3VYwy7VYVsXNtRc2hkbaiY/bza6zRzqKLeaOTalDcTRPv7MYdj1OcchZA51LniS6hjuqI5sS7mztcULG3U8OmXDappzZBGKJiDOY9QDfW3gSyGC6eIvN4BIRJd4SrMgk7nyplVrU2toeif8Ngei/Zy5ppeSeEvtNZuIqxu8Tyrcmk17RHsOt7rSpTbsHriYEN5x3rki2h60dg1au28p0A5tFdn2Vv3VGelnrGB34kuajrG21mx0vahpqyH07GgxtIOjxXlrGOr9otM7bWFsmfVQb/VVhPcajxx1F/LsOr4aj5po2W/HV5dmLltfVsO4aK+sDAYKA/s4OlMcg+lVD8GUZ2K6Ogaz6w7Zu8/BpI+OCEk343OHBIcxo5Wa/xSGsvdodn3527SsagfY6q8b1lqHyVpQdp/iU96hc3XR7yF2CYxgfPC5TBusAWw2TFuajtS0dmBg4HSiT3m0Lb+uqHP70TbtwDR9JGfbGvb14JHIxjIOTjbqrtz5DTb0td1Ss+sh4OBy+omLZbg3Vnix/BtSlt/Lf3MZtz8A \ No newline at end of file diff --git a/Part_3_Conditional_Logic/p_0003_talking_number_guessing_game.png b/Part_3_Conditional_Logic/p_0003_talking_number_guessing_game.png new file mode 100644 index 0000000..6843de7 Binary files /dev/null and b/Part_3_Conditional_Logic/p_0003_talking_number_guessing_game.png differ diff --git a/Part_3_Conditional_Logic/p_0003_talking_number_guessing_game.py b/Part_3_Conditional_Logic/p_0003_talking_number_guessing_game.py new file mode 100644 index 0000000..23b7052 --- /dev/null +++ b/Part_3_Conditional_Logic/p_0003_talking_number_guessing_game.py @@ -0,0 +1,43 @@ +from random import randint +from microbit import display, Image, button_a, button_b, pin_logo +from speech import say + +SPEED = 95 + +random_number = randint(1, 9) + +# Create number_position and init to 1 +number_position = 1 + +display.show(Image.SURPRISED) +say('Pick a number between 1 and 9.', speed=SPEED) +display.show(Image.HAPPY) + +while True: + display.show(number_position) + + if button_a.was_pressed(): + if number_position == 9: + pass + else: + number_position += 1 + display.show(number_position) + + if button_b.was_pressed(): + if number_position == 1: + pass + else: + number_position -= 1 + display.show(number_position) + + if pin_logo.is_touched(): + if number_position == random_number: + display.show(Image.SURPRISED) + say('Correct!', speed=SPEED) + display.show(Image.HAPPY) + break + else: + display.show(Image.SURPRISED) + say('The number I chose is {0}.'.format(random_number), speed=SPEED) + display.show(Image.HAPPY) + break diff --git a/Part_3_Hello_World/main.py b/Part_3_Hello_World/main.py deleted file mode 100644 index 373e032..0000000 --- a/Part_3_Hello_World/main.py +++ /dev/null @@ -1,4 +0,0 @@ -from microbit import * - -while True: - display.scroll('Hello, World!') diff --git a/Part_4_FUN_With_Images/main_1.py b/Part_4_FUN_With_Images/main_1.py deleted file mode 100644 index 975ce74..0000000 --- a/Part_4_FUN_With_Images/main_1.py +++ /dev/null @@ -1,3 +0,0 @@ -from microbit import * - -display.show(Image.HAPPY) \ No newline at end of file diff --git a/Part_4_FUN_With_Images/main_2.py b/Part_4_FUN_With_Images/main_2.py deleted file mode 100644 index 2e051d4..0000000 --- a/Part_4_FUN_With_Images/main_2.py +++ /dev/null @@ -1,9 +0,0 @@ -from microbit import * - -house = Image("00900:" - "09090:" - "90009:" - "05550:" - "05950") - -display.show(house) \ No newline at end of file diff --git a/Part_30_Lists_Tuples_Dictionaries_Loops/0003_rock_paper_scissors_ar b/Part_4_Lists_Tuples_Dictionaries_Loops/0010_rock_paper_scissors_ar similarity index 100% rename from Part_30_Lists_Tuples_Dictionaries_Loops/0003_rock_paper_scissors_ar rename to Part_4_Lists_Tuples_Dictionaries_Loops/0010_rock_paper_scissors_ar diff --git a/Part_30_Lists_Tuples_Dictionaries_Loops/0003_rock_paper_scissors.py b/Part_4_Lists_Tuples_Dictionaries_Loops/0010_rock_paper_scissors_repl.py similarity index 100% rename from Part_30_Lists_Tuples_Dictionaries_Loops/0003_rock_paper_scissors.py rename to Part_4_Lists_Tuples_Dictionaries_Loops/0010_rock_paper_scissors_repl.py diff --git a/Part_30_Lists_Tuples_Dictionaries_Loops/0004_journal_ar b/Part_4_Lists_Tuples_Dictionaries_Loops/0011_journal_ar similarity index 100% rename from Part_30_Lists_Tuples_Dictionaries_Loops/0004_journal_ar rename to Part_4_Lists_Tuples_Dictionaries_Loops/0011_journal_ar diff --git a/Part_30_Lists_Tuples_Dictionaries_Loops/0004_journal.py b/Part_4_Lists_Tuples_Dictionaries_Loops/0011_journal_repl.py similarity index 77% rename from Part_30_Lists_Tuples_Dictionaries_Loops/0004_journal.py rename to Part_4_Lists_Tuples_Dictionaries_Loops/0011_journal_repl.py index 6dbbe64..ec2009c 100644 --- a/Part_30_Lists_Tuples_Dictionaries_Loops/0004_journal.py +++ b/Part_4_Lists_Tuples_Dictionaries_Loops/0011_journal_repl.py @@ -1,6 +1,6 @@ journal = [ { - 'entry': 'Today I started an amazing new journey with Python!', + 'entry': 'Today I started an amazing new journey with MicroPython!', 'date': '12/15/20', }, { @@ -15,4 +15,4 @@ new_journal_entry['date'] = '01/15/21' journal.append(new_journal_entry) -print(journal) +print(journal) \ No newline at end of file diff --git a/Part_30_Lists_Tuples_Dictionaries_Loops/0005_high_score_ar b/Part_4_Lists_Tuples_Dictionaries_Loops/0012_high_score_ar similarity index 100% rename from Part_30_Lists_Tuples_Dictionaries_Loops/0005_high_score_ar rename to Part_4_Lists_Tuples_Dictionaries_Loops/0012_high_score_ar diff --git a/Part_30_Lists_Tuples_Dictionaries_Loops/0005_high_score.py b/Part_4_Lists_Tuples_Dictionaries_Loops/0012_high_score_repl.py similarity index 100% rename from Part_30_Lists_Tuples_Dictionaries_Loops/0005_high_score.py rename to Part_4_Lists_Tuples_Dictionaries_Loops/0012_high_score_repl.py diff --git a/Part_4_Lists_Tuples_Dictionaries_Loops/p_0004_talking_caramel_chocolate_adventure_game.py b/Part_4_Lists_Tuples_Dictionaries_Loops/p_0004_talking_caramel_chocolate_adventure_game.py new file mode 100644 index 0000000..d46e665 --- /dev/null +++ b/Part_4_Lists_Tuples_Dictionaries_Loops/p_0004_talking_caramel_chocolate_adventure_game.py @@ -0,0 +1,79 @@ +from random import choice +from microbit import display, Image, button_a, button_b, pin_logo +from speech import say +from time import sleep + +SPEED = 95 + +chocolates = ['milk', 'white', 'dark', 'caramel', 'mint'] +rooms = {} +room_number = 1 +guesses = 2 + +for room in range(1, len(chocolates) + 1): + random_chocolate = choice(chocolates) + rooms[room] = random_chocolate + chocolates.remove(random_chocolate) + +display.show(Image.SURPRISED) +say('Welcome to the Talking Caramel Chocolate Adventure Game!', speed=SPEED) +display.show(Image.HAPPY) +sleep(1) +display.show(Image.SURPRISED) +say('Press the A and B buttons to move back and fourth through 5 ', speed=SPEED) +say('different rooms as your goal find the room with the caramel ', speed=SPEED) +say('chocolate.', speed=SPEED) +display.show(Image.HAPPY) +sleep(1) +display.show(Image.SURPRISED) +say('You get two guesses.', speed=SPEED) +display.show(Image.HAPPY) +sleep(1) +display.show(Image.SURPRISED) +say('If you press the logo and if the caramel chocolate ', speed=SPEED) +say('is in that room you win!', speed=SPEED) +display.show(Image.HAPPY) +sleep(1) +display.show(Image.SURPRISED) +say('Let the games begin!', speed=SPEED) +display.show(Image.HAPPY) +sleep(1) + +while guesses > 0: + display.show(room_number) + if button_a.was_pressed(): + if room_number == 5: + pass + else: + room_number += 1 + display.show(room_number) + if button_b.was_pressed(): + if room_number == 1: + pass + else: + room_number -= 1 + display.show(room_number) + if pin_logo.is_touched(): + if rooms[room_number] == 'caramel': + display.show(Image.SURPRISED) + say('You found the caramel chocolate! Great job!', speed=SPEED) + display.show(Image.HAPPY) + break + else: + display.show(Image.SURPRISED) + say('Sorry this room has {0} chocolate.'.format(rooms[room_number]), speed=SPEED) + display.show(Image.HAPPY) + sleep(1) + guesses -= 1 + +if guesses <= 0: + display.show(Image.SURPRISED) + say('Sorry about that. Please try again by click the reset button.', speed=SPEED) + display.show(Image.HAPPY) + sleep(1) +else: + display.show(Image.SURPRISED) + say('Click the reset button to play again.', speed=SPEED) + display.show(Image.HAPPY) + sleep(1) + diff --git a/Part_4_Lists_Tuples_Dictionaries_Loops/p_0004_talking_caramel_chocolate_adventure_game_ar b/Part_4_Lists_Tuples_Dictionaries_Loops/p_0004_talking_caramel_chocolate_adventure_game_ar new file mode 100644 index 0000000..abe53a3 --- /dev/null +++ b/Part_4_Lists_Tuples_Dictionaries_Loops/p_0004_talking_caramel_chocolate_adventure_game_ar @@ -0,0 +1,32 @@ +Talking Caramel Chocolate Adventure Game Application Requirements +----------------------------------------------------------------- +1. Define the purpose of the application. + a. Create a game where a computer randomly chooses a chocolate + from a pre-defined list and the player cycles through a series + of rooms and once they choose their selected room they press the + logo and if the chocolate in that room is caramel the player + wins otherwise gets another guess. If after that second + guess and still does not find the room the player loses. +2. Define the rules of the application. + a. Find the room with the caramel chocolate and press the logo. +3. Define the logical steps of the application. + a. Create a SPEED constant and init to 95. + b. Create a chocolates list and populate it with milk, dark, + caramel and mint strings. + c. Create an empty rooms dictionary. + d. Create a room_number variable and init to 1. + e. Create a guesses variable and init to 2. + f. Create a for loop to handle the choosing of the + winning room. + g. Create a talking sequence to intro the player to + the game. + h. Create a series of sequences with pauses to + explain or speak the rules to the player. + i. Create a while loop based on guesses. + j. Within the scope create a button_a, button_b and + pin_logo logic where button_a advances the rooms + and button_b decreases the room and add bounds and + the pin_logo locks in the player's choice and + create logic to win or lose and break out of + while loop. + k. Create logic based on win or lose to replay. diff --git a/Part_5_FUN_With_Numbers/main.py b/Part_5_FUN_With_Numbers/main.py deleted file mode 100644 index bcfec50..0000000 --- a/Part_5_FUN_With_Numbers/main.py +++ /dev/null @@ -1,11 +0,0 @@ -from microbit import * - -counter = 0 - -while True: - if button_a.was_pressed(): - counter = counter + 1 - display.scroll(str(counter)) - if button_b.was_pressed(): - counter = counter - 1 - display.scroll(str(counter)) \ No newline at end of file diff --git a/Part_31_Functions/0013_number_guessing_game_ar b/Part_5_Functions/0013_number_guessing_game_ar similarity index 100% rename from Part_31_Functions/0013_number_guessing_game_ar rename to Part_5_Functions/0013_number_guessing_game_ar diff --git a/Part_31_Functions/0013_number_guessing_game_repl.py b/Part_5_Functions/0013_number_guessing_game_repl.py similarity index 100% rename from Part_31_Functions/0013_number_guessing_game_repl.py rename to Part_5_Functions/0013_number_guessing_game_repl.py diff --git a/Part_31_Functions/0013_number_guessing_game_repl_WITH_LOGIC_ERRORS.py b/Part_5_Functions/0013_number_guessing_game_repl_WITH_LOGIC_ERRORS.py similarity index 100% rename from Part_31_Functions/0013_number_guessing_game_repl_WITH_LOGIC_ERRORS.py rename to Part_5_Functions/0013_number_guessing_game_repl_WITH_LOGIC_ERRORS.py diff --git a/Part_31_Functions/p_0005_wonka_chocolate_machine/data.py b/Part_5_Functions/p_0005_wonka_chocolate_machine/data.py similarity index 100% rename from Part_31_Functions/p_0005_wonka_chocolate_machine/data.py rename to Part_5_Functions/p_0005_wonka_chocolate_machine/data.py diff --git a/Part_31_Functions/p_0005_wonka_chocolate_machine/funcs.py b/Part_5_Functions/p_0005_wonka_chocolate_machine/funcs.py similarity index 99% rename from Part_31_Functions/p_0005_wonka_chocolate_machine/funcs.py rename to Part_5_Functions/p_0005_wonka_chocolate_machine/funcs.py index a72309c..9ff53ff 100644 --- a/Part_31_Functions/p_0005_wonka_chocolate_machine/funcs.py +++ b/Part_5_Functions/p_0005_wonka_chocolate_machine/funcs.py @@ -1,8 +1,10 @@ def has_raw_materials(f_raw_materials, d_raw_materials): """Check if there are enough raw materials in the machine + Params: f_raw_materials: dict d_raw_materials: dict + Returns: str or bool """ @@ -18,8 +20,10 @@ def has_raw_materials(f_raw_materials, d_raw_materials): def collect_money(f_max_value, f_quarters, f_dimes, f_nickels): """Collect money into the machine + Params: f_max_value: float + Returns: float or str """ @@ -37,9 +41,11 @@ def collect_money(f_max_value, f_quarters, f_dimes, f_nickels): def has_enough_money(f_money_collected, f_chocolate_price, f_total_money_collected): """Check to see if customer put in enough money into the machine + Params: f_money_collected: float f_chocolate_price: float + Returns: str, int """ @@ -54,10 +60,12 @@ def has_enough_money(f_money_collected, f_chocolate_price, f_total_money_collect def bake_chocolate_bar(f_chocolate_choice, f_raw_materials, d_raw_materials): """Bake chocolate bar from raw materials + Params: f_chocolate_choice: str f_raw_materials: dict d_raw_materials: dict + Returns: str """ @@ -69,9 +77,11 @@ def bake_chocolate_bar(f_chocolate_choice, f_raw_materials, d_raw_materials): def stats(d_raw_materials, f_total_money_collected): """ Show machine statistics + Params: d_raw_materials: dict f_money_collected: float + Returns: str """ @@ -87,3 +97,4 @@ def stats(d_raw_materials, f_total_money_collected): cm_stats += 'Reese\'s Pieces {0} tablespoons remaining\n'.format(d_raw_materials['Reese\'s Pieces']) cm_stats += 'Total Money Collected: ${0:.2f}\n'.format(f_total_money_collected) return cm_stats + diff --git a/Part_33_Unittest/p_0005_wonka_chocolate_machine/main.py b/Part_5_Functions/p_0005_wonka_chocolate_machine/main.py similarity index 99% rename from Part_33_Unittest/p_0005_wonka_chocolate_machine/main.py rename to Part_5_Functions/p_0005_wonka_chocolate_machine/main.py index 48b9844..bb95caf 100644 --- a/Part_33_Unittest/p_0005_wonka_chocolate_machine/main.py +++ b/Part_5_Functions/p_0005_wonka_chocolate_machine/main.py @@ -47,3 +47,4 @@ machine_active = False print('We are going down for maintenance...') + diff --git a/Part_31_Functions/p_0005_wonka_chocolate_machine_ar b/Part_5_Functions/p_0005_wonka_chocolate_machine_ar similarity index 100% rename from Part_31_Functions/p_0005_wonka_chocolate_machine_ar rename to Part_5_Functions/p_0005_wonka_chocolate_machine_ar diff --git a/Part_32_Classes/0007_escape_room/EscapeRoomPlayer.py b/Part_6_Classes/0014_escape_room/EscapeRoomPlayer.py similarity index 100% rename from Part_32_Classes/0007_escape_room/EscapeRoomPlayer.py rename to Part_6_Classes/0014_escape_room/EscapeRoomPlayer.py diff --git a/Part_32_Classes/0007_escape_room/FileManager.py b/Part_6_Classes/0014_escape_room/FileManager.py similarity index 100% rename from Part_32_Classes/0007_escape_room/FileManager.py rename to Part_6_Classes/0014_escape_room/FileManager.py diff --git a/Part_32_Classes/0007_escape_room/Game.py b/Part_6_Classes/0014_escape_room/Game.py similarity index 99% rename from Part_32_Classes/0007_escape_room/Game.py rename to Part_6_Classes/0014_escape_room/Game.py index a23e444..884a792 100644 --- a/Part_32_Classes/0007_escape_room/Game.py +++ b/Part_6_Classes/0014_escape_room/Game.py @@ -16,7 +16,7 @@ def generate_random_number(grid): grid: object Returns: - int, int + int """ x = randint(1, grid.available_width) return x diff --git a/Part_32_Classes/0007_escape_room/Grid.py b/Part_6_Classes/0014_escape_room/Grid.py similarity index 88% rename from Part_32_Classes/0007_escape_room/Grid.py rename to Part_6_Classes/0014_escape_room/Grid.py index cd86e17..96f1524 100644 --- a/Part_32_Classes/0007_escape_room/Grid.py +++ b/Part_6_Classes/0014_escape_room/Grid.py @@ -3,7 +3,7 @@ class Grid: Class to represent a generic grid """ - def __init__(self, led_height=0, led_width=0, led_on='*', led_off=' '): + def __init__(self, led_height=0, led_width=0, led_on='9', led_off='0'): """ Attrs: led_height: int @@ -18,16 +18,6 @@ def __init__(self, led_height=0, led_width=0, led_on='*', led_off=' '): self.available_height = led_height - 2 self.available_width = led_width - 2 - @staticmethod - def clear_screen(): - """ - Method to clear terminal - - Returns: - str - """ - return '\n' * 100 - def __create(self): """ Private method to create a grid diff --git a/Part_32_Classes/0007_escape_room/Player.py b/Part_6_Classes/0014_escape_room/Player.py similarity index 100% rename from Part_32_Classes/0007_escape_room/Player.py rename to Part_6_Classes/0014_escape_room/Player.py diff --git a/Part_32_Classes/0007_escape_room/data.py b/Part_6_Classes/0014_escape_room/data.py similarity index 84% rename from Part_32_Classes/0007_escape_room/data.py rename to Part_6_Classes/0014_escape_room/data.py index 13278b9..4dcbc8a 100644 --- a/Part_32_Classes/0007_escape_room/data.py +++ b/Part_6_Classes/0014_escape_room/data.py @@ -1,11 +1,11 @@ questions = { 'What year was the MicroBit educational foundation created?': - [ - '2016', - '2014', - '2017', - 0 - ], + [ + '2016', + '2014', + '2017', + 0 + ], 'What year was the first computer invented?': [ '1954', diff --git a/Part_6_Classes/0014_escape_room/main.py b/Part_6_Classes/0014_escape_room/main.py new file mode 100644 index 0000000..7544920 --- /dev/null +++ b/Part_6_Classes/0014_escape_room/main.py @@ -0,0 +1,89 @@ +from microbit import display, Image, button_a, button_b, pin_logo, pin2 +from Grid import Grid +from EscapeRoomPlayer import EscapeRoomPlayer +from data import questions +from FileManager import FileManager +from Game import Game +from speech import say +import music + +grid = Grid(5, 5) +player = EscapeRoomPlayer() +file_manager = FileManager() +game = Game() + +player_location = None +response = None +final_question = False +SPEED = 95 + +previous_player_location = player_location +update_grid = grid.update(player) + +while True: + # To ensure we do not generate a question if the player is hitting a wall + # or not entering a valid move + previous_player_location = player_location + display.show(Image(update_grid)) + while True: + if button_a.is_pressed(): + player_location = player.move_west(grid) + update_grid = grid.update(player) + break + elif button_b.is_pressed(): + player_location = player.move_east(grid) + update_grid = grid.update(player) + break + elif pin_logo.is_touched(): + player_location = player.move_north(grid) + update_grid = grid.update(player) + break + elif pin2.is_touched(): + player_location = player.move_south(grid) + update_grid = grid.update(player) + break + random_location = (x, y) = game.generate_random_numbers(grid) + if random_location == player_location and random_location != previous_player_location: + random_question, answer_1, answer_2, answer_3, correct_answer_index, correct_answer \ + = game.ask_random_question(questions) + display.show(Image.SURPRISED) + say(random_question, speed=SPEED) + say('Press the aay button for {0}.'.format(answer_1), speed=SPEED) + say('Press the logo for {0}.'.format(answer_2), speed=SPEED) + say('Press the bee button for {0}.'.format(answer_3), speed=SPEED) + display.show(Image.HAPPY) + while True: + if button_a.is_pressed(): + response = 1 + break + elif pin_logo.is_touched(): + response = 2 + break + elif button_b.is_pressed(): + response = 3 + break + if response == correct_answer_index + 1: + display.show(Image.SURPRISED) + say(game.correct_answer_response(), speed=SPEED) + inventory = player.get_inventory(file_manager) + player.inventory.append(inventory) + if 'Red Key' in player.inventory: + final_question = True + if 'Red Key' not in player.inventory and not final_question: + receive_red_key = game.generate_random_number(grid) + if receive_red_key == 2: + display.show(Image.SURPRISED) + say(player.pick_up_red_key(file_manager), speed=SPEED) + final_question = True + else: + display.show(Image.SURPRISED) + say(player.without_red_key(), speed=SPEED) + elif final_question: + display.show(Image.SURPRISED) + say(game.win(file_manager), speed=SPEED) + music.play(music.POWER_UP) + display.show(Image.ALL_CLOCKS, loop=False, delay=100) + break + else: + display.show(Image.SURPRISED) + say(game.incorrect_answer_response(correct_answer), speed=SPEED) diff --git a/Part_32_Classes/0007_escape_room_ar b/Part_6_Classes/0014_escape_room_ar similarity index 90% rename from Part_32_Classes/0007_escape_room_ar rename to Part_6_Classes/0014_escape_room_ar index d82e09d..ed17ecc 100644 --- a/Part_32_Classes/0007_escape_room_ar +++ b/Part_6_Classes/0014_escape_room_ar @@ -2,13 +2,13 @@ Escape Room Application Requirements ------------------------------------ 1. Define the purpose of the application. a. Create a game where we build an escape room style adventure game with - our python with questions as we are placed inside a mountain cave + our micro:bit with questions as we are placed inside a mountain cave and work our way through different places in the cave where we randomly stumble upon a question space and one of the questions spaces when answered correctly gives us a red key which we will need for the other randomly placed question. Once you answer the question which gives you the red key you can then answer the question that will let you out of the - cave or room to the outside world. The console will show an + cave or room to the outside world. The micro:bit display will show an outline of the cave and the player moving around a map. 2. Define the rules of the application. a. If the player answers a correct question and that question has the red key diff --git a/Part_32_Classes/class_person_example.py b/Part_6_Classes/class_person_example.py similarity index 100% rename from Part_32_Classes/class_person_example.py rename to Part_6_Classes/class_person_example.py diff --git a/Part_32_Classes/p_0006_wonka_chocolate_machine/ChocolateMachine.py b/Part_6_Classes/p_0006_wonka_chocolate_machine/ChocolateMachine.py similarity index 100% rename from Part_32_Classes/p_0006_wonka_chocolate_machine/ChocolateMachine.py rename to Part_6_Classes/p_0006_wonka_chocolate_machine/ChocolateMachine.py diff --git a/Part_32_Classes/p_0006_wonka_chocolate_machine/Machine.py b/Part_6_Classes/p_0006_wonka_chocolate_machine/Machine.py similarity index 100% rename from Part_32_Classes/p_0006_wonka_chocolate_machine/Machine.py rename to Part_6_Classes/p_0006_wonka_chocolate_machine/Machine.py diff --git a/Part_32_Classes/p_0006_wonka_chocolate_machine/data.py b/Part_6_Classes/p_0006_wonka_chocolate_machine/data.py similarity index 100% rename from Part_32_Classes/p_0006_wonka_chocolate_machine/data.py rename to Part_6_Classes/p_0006_wonka_chocolate_machine/data.py diff --git a/Part_32_Classes/p_0006_wonka_chocolate_machine/main.py b/Part_6_Classes/p_0006_wonka_chocolate_machine/main.py similarity index 100% rename from Part_32_Classes/p_0006_wonka_chocolate_machine/main.py rename to Part_6_Classes/p_0006_wonka_chocolate_machine/main.py diff --git a/Part_6_FUN_With_Words/main.py b/Part_6_FUN_With_Words/main.py deleted file mode 100644 index 6141bad..0000000 --- a/Part_6_FUN_With_Words/main.py +++ /dev/null @@ -1,6 +0,0 @@ -from microbit import * - -name = 'Kevin' - -while True: - display.scroll('Hi ' + name + '!') diff --git a/Part_7_FUN_With_Word_Lists/main.py b/Part_7_FUN_With_Word_Lists/main.py deleted file mode 100644 index 734306d..0000000 --- a/Part_7_FUN_With_Word_Lists/main.py +++ /dev/null @@ -1,12 +0,0 @@ -from microbit import * - -favorite_foods = ['pizza', 'ice cream', 'cookies'] - -while True: - display.scroll( - 'I love to eat ' + - favorite_foods[0] + ', ' + - favorite_foods[1] + ', ' + - 'and ' + - favorite_foods[2] + '!' - ) diff --git a/Part_33_Unittest/0013_number_guessing_game_repl/funcs.py b/Part_7_Unittest/0013_number_guessing_game_repl/funcs.py similarity index 100% rename from Part_33_Unittest/0013_number_guessing_game_repl/funcs.py rename to Part_7_Unittest/0013_number_guessing_game_repl/funcs.py diff --git a/Part_33_Unittest/0013_number_guessing_game_repl/main.py b/Part_7_Unittest/0013_number_guessing_game_repl/main.py similarity index 100% rename from Part_33_Unittest/0013_number_guessing_game_repl/main.py rename to Part_7_Unittest/0013_number_guessing_game_repl/main.py diff --git a/Part_33_Unittest/0013_number_guessing_game_repl/tests/test_funcs.py b/Part_7_Unittest/0013_number_guessing_game_repl/tests/test_funcs.py similarity index 100% rename from Part_33_Unittest/0013_number_guessing_game_repl/tests/test_funcs.py rename to Part_7_Unittest/0013_number_guessing_game_repl/tests/test_funcs.py diff --git a/Part_33_Unittest/0007_escape_room/EscapeRoomPlayer.py b/Part_7_Unittest/0014_escape_room/EscapeRoomPlayer.py similarity index 100% rename from Part_33_Unittest/0007_escape_room/EscapeRoomPlayer.py rename to Part_7_Unittest/0014_escape_room/EscapeRoomPlayer.py diff --git a/Part_33_Unittest/0007_escape_room/FileManager.py b/Part_7_Unittest/0014_escape_room/FileManager.py similarity index 100% rename from Part_33_Unittest/0007_escape_room/FileManager.py rename to Part_7_Unittest/0014_escape_room/FileManager.py diff --git a/Part_33_Unittest/0007_escape_room/Game.py b/Part_7_Unittest/0014_escape_room/Game.py similarity index 99% rename from Part_33_Unittest/0007_escape_room/Game.py rename to Part_7_Unittest/0014_escape_room/Game.py index a23e444..884a792 100644 --- a/Part_33_Unittest/0007_escape_room/Game.py +++ b/Part_7_Unittest/0014_escape_room/Game.py @@ -16,7 +16,7 @@ def generate_random_number(grid): grid: object Returns: - int, int + int """ x = randint(1, grid.available_width) return x diff --git a/Part_33_Unittest/0007_escape_room/Grid.py b/Part_7_Unittest/0014_escape_room/Grid.py similarity index 88% rename from Part_33_Unittest/0007_escape_room/Grid.py rename to Part_7_Unittest/0014_escape_room/Grid.py index cd86e17..96f1524 100644 --- a/Part_33_Unittest/0007_escape_room/Grid.py +++ b/Part_7_Unittest/0014_escape_room/Grid.py @@ -3,7 +3,7 @@ class Grid: Class to represent a generic grid """ - def __init__(self, led_height=0, led_width=0, led_on='*', led_off=' '): + def __init__(self, led_height=0, led_width=0, led_on='9', led_off='0'): """ Attrs: led_height: int @@ -18,16 +18,6 @@ def __init__(self, led_height=0, led_width=0, led_on='*', led_off=' '): self.available_height = led_height - 2 self.available_width = led_width - 2 - @staticmethod - def clear_screen(): - """ - Method to clear terminal - - Returns: - str - """ - return '\n' * 100 - def __create(self): """ Private method to create a grid diff --git a/Part_33_Unittest/0007_escape_room/Player.py b/Part_7_Unittest/0014_escape_room/Player.py similarity index 100% rename from Part_33_Unittest/0007_escape_room/Player.py rename to Part_7_Unittest/0014_escape_room/Player.py diff --git a/Part_33_Unittest/0007_escape_room/data.py b/Part_7_Unittest/0014_escape_room/data.py similarity index 84% rename from Part_33_Unittest/0007_escape_room/data.py rename to Part_7_Unittest/0014_escape_room/data.py index 13278b9..4dcbc8a 100644 --- a/Part_33_Unittest/0007_escape_room/data.py +++ b/Part_7_Unittest/0014_escape_room/data.py @@ -1,11 +1,11 @@ questions = { 'What year was the MicroBit educational foundation created?': - [ - '2016', - '2014', - '2017', - 0 - ], + [ + '2016', + '2014', + '2017', + 0 + ], 'What year was the first computer invented?': [ '1954', diff --git a/Part_7_Unittest/0014_escape_room/main.py b/Part_7_Unittest/0014_escape_room/main.py new file mode 100644 index 0000000..7544920 --- /dev/null +++ b/Part_7_Unittest/0014_escape_room/main.py @@ -0,0 +1,89 @@ +from microbit import display, Image, button_a, button_b, pin_logo, pin2 +from Grid import Grid +from EscapeRoomPlayer import EscapeRoomPlayer +from data import questions +from FileManager import FileManager +from Game import Game +from speech import say +import music + +grid = Grid(5, 5) +player = EscapeRoomPlayer() +file_manager = FileManager() +game = Game() + +player_location = None +response = None +final_question = False +SPEED = 95 + +previous_player_location = player_location +update_grid = grid.update(player) + +while True: + # To ensure we do not generate a question if the player is hitting a wall + # or not entering a valid move + previous_player_location = player_location + display.show(Image(update_grid)) + while True: + if button_a.is_pressed(): + player_location = player.move_west(grid) + update_grid = grid.update(player) + break + elif button_b.is_pressed(): + player_location = player.move_east(grid) + update_grid = grid.update(player) + break + elif pin_logo.is_touched(): + player_location = player.move_north(grid) + update_grid = grid.update(player) + break + elif pin2.is_touched(): + player_location = player.move_south(grid) + update_grid = grid.update(player) + break + random_location = (x, y) = game.generate_random_numbers(grid) + if random_location == player_location and random_location != previous_player_location: + random_question, answer_1, answer_2, answer_3, correct_answer_index, correct_answer \ + = game.ask_random_question(questions) + display.show(Image.SURPRISED) + say(random_question, speed=SPEED) + say('Press the aay button for {0}.'.format(answer_1), speed=SPEED) + say('Press the logo for {0}.'.format(answer_2), speed=SPEED) + say('Press the bee button for {0}.'.format(answer_3), speed=SPEED) + display.show(Image.HAPPY) + while True: + if button_a.is_pressed(): + response = 1 + break + elif pin_logo.is_touched(): + response = 2 + break + elif button_b.is_pressed(): + response = 3 + break + if response == correct_answer_index + 1: + display.show(Image.SURPRISED) + say(game.correct_answer_response(), speed=SPEED) + inventory = player.get_inventory(file_manager) + player.inventory.append(inventory) + if 'Red Key' in player.inventory: + final_question = True + if 'Red Key' not in player.inventory and not final_question: + receive_red_key = game.generate_random_number(grid) + if receive_red_key == 2: + display.show(Image.SURPRISED) + say(player.pick_up_red_key(file_manager), speed=SPEED) + final_question = True + else: + display.show(Image.SURPRISED) + say(player.without_red_key(), speed=SPEED) + elif final_question: + display.show(Image.SURPRISED) + say(game.win(file_manager), speed=SPEED) + music.play(music.POWER_UP) + display.show(Image.ALL_CLOCKS, loop=False, delay=100) + break + else: + display.show(Image.SURPRISED) + say(game.incorrect_answer_response(correct_answer), speed=SPEED) diff --git a/Part_32_Classes/0007_escape_room/inventory b/Part_7_Unittest/0014_escape_room/tests/inventory similarity index 100% rename from Part_32_Classes/0007_escape_room/inventory rename to Part_7_Unittest/0014_escape_room/tests/inventory diff --git a/Part_33_Unittest/0007_escape_room/tests/test_EscapeRoomPlayer.py b/Part_7_Unittest/0014_escape_room/tests/test_EscapeRoomPlayer.py similarity index 100% rename from Part_33_Unittest/0007_escape_room/tests/test_EscapeRoomPlayer.py rename to Part_7_Unittest/0014_escape_room/tests/test_EscapeRoomPlayer.py diff --git a/Part_33_Unittest/0007_escape_room/tests/test_FileManager.py b/Part_7_Unittest/0014_escape_room/tests/test_FileManager.py similarity index 100% rename from Part_33_Unittest/0007_escape_room/tests/test_FileManager.py rename to Part_7_Unittest/0014_escape_room/tests/test_FileManager.py diff --git a/Part_33_Unittest/0007_escape_room/tests/test_Game.py b/Part_7_Unittest/0014_escape_room/tests/test_Game.py similarity index 100% rename from Part_33_Unittest/0007_escape_room/tests/test_Game.py rename to Part_7_Unittest/0014_escape_room/tests/test_Game.py diff --git a/Part_33_Unittest/0007_escape_room/tests/test_Grid.py b/Part_7_Unittest/0014_escape_room/tests/test_Grid.py similarity index 100% rename from Part_33_Unittest/0007_escape_room/tests/test_Grid.py rename to Part_7_Unittest/0014_escape_room/tests/test_Grid.py diff --git a/Part_33_Unittest/0007_escape_room/tests/test_Player.py b/Part_7_Unittest/0014_escape_room/tests/test_Player.py similarity index 100% rename from Part_33_Unittest/0007_escape_room/tests/test_Player.py rename to Part_7_Unittest/0014_escape_room/tests/test_Player.py diff --git a/Part_33_Unittest/p_0005_wonka_chocolate_machine/data.py b/Part_7_Unittest/p_0005_wonka_chocolate_machine/data.py similarity index 100% rename from Part_33_Unittest/p_0005_wonka_chocolate_machine/data.py rename to Part_7_Unittest/p_0005_wonka_chocolate_machine/data.py diff --git a/Part_33_Unittest/p_0005_wonka_chocolate_machine/funcs.py b/Part_7_Unittest/p_0005_wonka_chocolate_machine/funcs.py similarity index 100% rename from Part_33_Unittest/p_0005_wonka_chocolate_machine/funcs.py rename to Part_7_Unittest/p_0005_wonka_chocolate_machine/funcs.py diff --git a/Part_31_Functions/p_0005_wonka_chocolate_machine/main.py b/Part_7_Unittest/p_0005_wonka_chocolate_machine/main.py similarity index 100% rename from Part_31_Functions/p_0005_wonka_chocolate_machine/main.py rename to Part_7_Unittest/p_0005_wonka_chocolate_machine/main.py diff --git a/Part_33_Unittest/p_0005_wonka_chocolate_machine/tests/test_funcs.py b/Part_7_Unittest/p_0005_wonka_chocolate_machine/tests/test_funcs.py similarity index 100% rename from Part_33_Unittest/p_0005_wonka_chocolate_machine/tests/test_funcs.py rename to Part_7_Unittest/p_0005_wonka_chocolate_machine/tests/test_funcs.py diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/data/__pycache__/__init__.cpython-39.pyc b/Part_7_Unittest/p_0006_wonka_chocolate_machine/data/__pycache__/__init__.cpython-39.pyc similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/data/__pycache__/__init__.cpython-39.pyc rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/data/__pycache__/__init__.cpython-39.pyc diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/data/__pycache__/data.cpython-39.pyc b/Part_7_Unittest/p_0006_wonka_chocolate_machine/data/__pycache__/data.cpython-39.pyc similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/data/__pycache__/data.cpython-39.pyc rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/data/__pycache__/data.cpython-39.pyc diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/data/data.py b/Part_7_Unittest/p_0006_wonka_chocolate_machine/data/data.py similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/data/data.py rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/data/data.py diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/lib/ChocolateMachine.py b/Part_7_Unittest/p_0006_wonka_chocolate_machine/lib/ChocolateMachine.py similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/lib/ChocolateMachine.py rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/lib/ChocolateMachine.py diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/lib/Machine.py b/Part_7_Unittest/p_0006_wonka_chocolate_machine/lib/Machine.py similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/lib/Machine.py rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/lib/Machine.py diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/lib/__pycache__/ChocolateMachine.cpython-39.pyc b/Part_7_Unittest/p_0006_wonka_chocolate_machine/lib/__pycache__/ChocolateMachine.cpython-39.pyc similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/lib/__pycache__/ChocolateMachine.cpython-39.pyc rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/lib/__pycache__/ChocolateMachine.cpython-39.pyc diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/lib/__pycache__/Machine.cpython-39.pyc b/Part_7_Unittest/p_0006_wonka_chocolate_machine/lib/__pycache__/Machine.cpython-39.pyc similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/lib/__pycache__/Machine.cpython-39.pyc rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/lib/__pycache__/Machine.cpython-39.pyc diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/main.py b/Part_7_Unittest/p_0006_wonka_chocolate_machine/main.py similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/main.py rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/main.py diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/tests/test_ChocolateMachine.py b/Part_7_Unittest/p_0006_wonka_chocolate_machine/tests/test_ChocolateMachine.py similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/tests/test_ChocolateMachine.py rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/tests/test_ChocolateMachine.py diff --git a/Part_33_Unittest/p_0006_wonka_chocolate_machine/tests/test_Machine.py b/Part_7_Unittest/p_0006_wonka_chocolate_machine/tests/test_Machine.py similarity index 100% rename from Part_33_Unittest/p_0006_wonka_chocolate_machine/tests/test_Machine.py rename to Part_7_Unittest/p_0006_wonka_chocolate_machine/tests/test_Machine.py diff --git a/Part_8_FUN_With_Music/main.py b/Part_8_FUN_With_Music/main.py deleted file mode 100644 index 9927e07..0000000 --- a/Part_8_FUN_With_Music/main.py +++ /dev/null @@ -1,3 +0,0 @@ -from music import * - -play(NYAN) \ No newline at end of file