diff --git a/BoardGame-CLI/snakeLadder.py b/BoardGame-CLI/snakeLadder.py index d8892ed4339..bb91e516b8f 100644 --- a/BoardGame-CLI/snakeLadder.py +++ b/BoardGame-CLI/snakeLadder.py @@ -1,12 +1,46 @@ import random +import pandas as pd # Taking players data players = {} # stores players name their locations isReady = {} current_loc = 1 # vaiable for iterating location -imp = True +# creating board +board = [ + [100, 99, 98, "S", 96, "S", 94, 93, 92, 91], + [81, 82, 83, 84, 85, 86, "L", "S", 89, 90], + [80, 79, 78, 77, 76, 75, 74, 73, 72, "L"], + [61, 62, "S", 64, 65, 66, 67, 68, 69, 70], + [60, 59, 58, 57, 56, 55, 54, 53, 52, 51], + [41, 42, 43, 44, 45, 46, 47, "S", 49, "L"], + ["L", 39, 38, 37, "S", 35, 34, 33, "S", 31], + [21, 22, 23, 24, 25, 26, 27, "L", 29, 30], + ["L", 19, 18, 17, 16, 15, 14, 13, 12, 11], + [1, 2, 3, "L", 5, 6, 7, "L", 9, 10], +] + +df = pd.DataFrame(board) + +styled_df = df.style \ + .set_properties(**{'background-color': 'lightblue', 'color': 'black'}) \ + .set_table_styles([{ + 'selector': 'td', + 'props': [ + ('padding', '20px'), + ] + }]) + +# DataFrame as HTML +html_output = styled_df.render() + +# Save the HTML output +with open('styled_df_output.html', 'w') as f: + f.write(html_output) + +print("HTML output saved to 'styled_df_output.html'") +imp = True # players input function def player_input(): @@ -42,13 +76,13 @@ def play(): global isReady global imp - while imp: - print("/"*20) - print("1 -> roll the dice (or enter)") - print("2 -> start new game") - print("3 -> exit the game") - print("/"*20) + print("/"*20) + print("1 -> roll the dice (or enter)") + print("2 -> start new game") + print("3 -> exit the game") + print("/"*20) + while imp: for i in players: n = input("{}'s turn: ".format(i)) or 1 n = int(n) @@ -86,6 +120,7 @@ def play(): return print(f"you are at position {players[i]}") + print('-'*20) elif n == 2: players = {} # stores player ans their locations @@ -155,7 +190,7 @@ def ladder(a, i): players[i] = 67 elif (a == 71): players[i] = 92 - elif (a == 88): + elif (a == 87): players[i] = 99 else: return players[i] @@ -170,4 +205,4 @@ def ladder(a, i): print("/"*40) -player_input() +player_input() \ No newline at end of file diff --git a/BoardGame-CLI/styled_df_output.html b/BoardGame-CLI/styled_df_output.html new file mode 100644 index 00000000000..68c27256bbb --- /dev/null +++ b/BoardGame-CLI/styled_df_output.html @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 0123456789
01009998S96S94939291
1818283848586LS8990
2807978777675747372L
36162S64656667686970
460595857565554535251
541424344454647S49L
6L393837S353433S31
721222324252627L2930
8L191817161514131211
9123L567L910
diff --git a/very_easy/is_number.py b/very_easy/is_number.py index 5dcd98f9eb1..29654794bbf 100644 --- a/very_easy/is_number.py +++ b/very_easy/is_number.py @@ -31,3 +31,4 @@ def check_number(input_value: Any) -> str: print(check_number(pow(10, 20))) print(check_number("Hello")) print(check_number(1 + 2j)) + diff --git a/very_easy/test_is_number.py b/very_easy/test_is_number.py new file mode 100644 index 00000000000..4a16da78794 --- /dev/null +++ b/very_easy/test_is_number.py @@ -0,0 +1,23 @@ +import pytest + +from is_number import check_number + +def test_check_number_float(): + assert check_number(3.14) == '3.14 is a number.' + assert check_number(1e-5) == '1e-05 is a number.' + +def test_check_number_negative_float(): + assert check_number(-3.14) == '-3.14 is a number.' + assert check_number(-1e-5) == '-1e-05 is a number.' + +def test_check_number_boolean(): + assert check_number(True) == 'True is a number.' + assert check_number(False) == 'False is a number.' + +def test_check_number_list(): + assert check_number([1, 2, 3]) == '[1, 2, 3] is not a number.' + assert check_number([]) == '[] is not a number.' + +def test_check_number_dict(): + assert check_number({'key': 'value'}) == "{'key': 'value'} is not a number." + assert check_number({}) == "{} is not a number."