Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test file for is_number #2146

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions BoardGame-CLI/snakeLadder.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -170,4 +205,4 @@ def ladder(a, i):
print("/"*40)


player_input()
player_input()
158 changes: 158 additions & 0 deletions BoardGame-CLI/styled_df_output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<style type="text/css">
#T_b366d td {
padding: 20px;
}
#T_b366d_row0_col0, #T_b366d_row0_col1, #T_b366d_row0_col2, #T_b366d_row0_col3, #T_b366d_row0_col4, #T_b366d_row0_col5, #T_b366d_row0_col6, #T_b366d_row0_col7, #T_b366d_row0_col8, #T_b366d_row0_col9, #T_b366d_row1_col0, #T_b366d_row1_col1, #T_b366d_row1_col2, #T_b366d_row1_col3, #T_b366d_row1_col4, #T_b366d_row1_col5, #T_b366d_row1_col6, #T_b366d_row1_col7, #T_b366d_row1_col8, #T_b366d_row1_col9, #T_b366d_row2_col0, #T_b366d_row2_col1, #T_b366d_row2_col2, #T_b366d_row2_col3, #T_b366d_row2_col4, #T_b366d_row2_col5, #T_b366d_row2_col6, #T_b366d_row2_col7, #T_b366d_row2_col8, #T_b366d_row2_col9, #T_b366d_row3_col0, #T_b366d_row3_col1, #T_b366d_row3_col2, #T_b366d_row3_col3, #T_b366d_row3_col4, #T_b366d_row3_col5, #T_b366d_row3_col6, #T_b366d_row3_col7, #T_b366d_row3_col8, #T_b366d_row3_col9, #T_b366d_row4_col0, #T_b366d_row4_col1, #T_b366d_row4_col2, #T_b366d_row4_col3, #T_b366d_row4_col4, #T_b366d_row4_col5, #T_b366d_row4_col6, #T_b366d_row4_col7, #T_b366d_row4_col8, #T_b366d_row4_col9, #T_b366d_row5_col0, #T_b366d_row5_col1, #T_b366d_row5_col2, #T_b366d_row5_col3, #T_b366d_row5_col4, #T_b366d_row5_col5, #T_b366d_row5_col6, #T_b366d_row5_col7, #T_b366d_row5_col8, #T_b366d_row5_col9, #T_b366d_row6_col0, #T_b366d_row6_col1, #T_b366d_row6_col2, #T_b366d_row6_col3, #T_b366d_row6_col4, #T_b366d_row6_col5, #T_b366d_row6_col6, #T_b366d_row6_col7, #T_b366d_row6_col8, #T_b366d_row6_col9, #T_b366d_row7_col0, #T_b366d_row7_col1, #T_b366d_row7_col2, #T_b366d_row7_col3, #T_b366d_row7_col4, #T_b366d_row7_col5, #T_b366d_row7_col6, #T_b366d_row7_col7, #T_b366d_row7_col8, #T_b366d_row7_col9, #T_b366d_row8_col0, #T_b366d_row8_col1, #T_b366d_row8_col2, #T_b366d_row8_col3, #T_b366d_row8_col4, #T_b366d_row8_col5, #T_b366d_row8_col6, #T_b366d_row8_col7, #T_b366d_row8_col8, #T_b366d_row8_col9, #T_b366d_row9_col0, #T_b366d_row9_col1, #T_b366d_row9_col2, #T_b366d_row9_col3, #T_b366d_row9_col4, #T_b366d_row9_col5, #T_b366d_row9_col6, #T_b366d_row9_col7, #T_b366d_row9_col8, #T_b366d_row9_col9 {
background-color: lightblue;
color: black;
}
</style>
<table id="T_b366d">
<thead>
<tr>
<th class="blank level0" >&nbsp;</th>
<th id="T_b366d_level0_col0" class="col_heading level0 col0" >0</th>
<th id="T_b366d_level0_col1" class="col_heading level0 col1" >1</th>
<th id="T_b366d_level0_col2" class="col_heading level0 col2" >2</th>
<th id="T_b366d_level0_col3" class="col_heading level0 col3" >3</th>
<th id="T_b366d_level0_col4" class="col_heading level0 col4" >4</th>
<th id="T_b366d_level0_col5" class="col_heading level0 col5" >5</th>
<th id="T_b366d_level0_col6" class="col_heading level0 col6" >6</th>
<th id="T_b366d_level0_col7" class="col_heading level0 col7" >7</th>
<th id="T_b366d_level0_col8" class="col_heading level0 col8" >8</th>
<th id="T_b366d_level0_col9" class="col_heading level0 col9" >9</th>
</tr>
</thead>
<tbody>
<tr>
<th id="T_b366d_level0_row0" class="row_heading level0 row0" >0</th>
<td id="T_b366d_row0_col0" class="data row0 col0" >100</td>
<td id="T_b366d_row0_col1" class="data row0 col1" >99</td>
<td id="T_b366d_row0_col2" class="data row0 col2" >98</td>
<td id="T_b366d_row0_col3" class="data row0 col3" >S</td>
<td id="T_b366d_row0_col4" class="data row0 col4" >96</td>
<td id="T_b366d_row0_col5" class="data row0 col5" >S</td>
<td id="T_b366d_row0_col6" class="data row0 col6" >94</td>
<td id="T_b366d_row0_col7" class="data row0 col7" >93</td>
<td id="T_b366d_row0_col8" class="data row0 col8" >92</td>
<td id="T_b366d_row0_col9" class="data row0 col9" >91</td>
</tr>
<tr>
<th id="T_b366d_level0_row1" class="row_heading level0 row1" >1</th>
<td id="T_b366d_row1_col0" class="data row1 col0" >81</td>
<td id="T_b366d_row1_col1" class="data row1 col1" >82</td>
<td id="T_b366d_row1_col2" class="data row1 col2" >83</td>
<td id="T_b366d_row1_col3" class="data row1 col3" >84</td>
<td id="T_b366d_row1_col4" class="data row1 col4" >85</td>
<td id="T_b366d_row1_col5" class="data row1 col5" >86</td>
<td id="T_b366d_row1_col6" class="data row1 col6" >L</td>
<td id="T_b366d_row1_col7" class="data row1 col7" >S</td>
<td id="T_b366d_row1_col8" class="data row1 col8" >89</td>
<td id="T_b366d_row1_col9" class="data row1 col9" >90</td>
</tr>
<tr>
<th id="T_b366d_level0_row2" class="row_heading level0 row2" >2</th>
<td id="T_b366d_row2_col0" class="data row2 col0" >80</td>
<td id="T_b366d_row2_col1" class="data row2 col1" >79</td>
<td id="T_b366d_row2_col2" class="data row2 col2" >78</td>
<td id="T_b366d_row2_col3" class="data row2 col3" >77</td>
<td id="T_b366d_row2_col4" class="data row2 col4" >76</td>
<td id="T_b366d_row2_col5" class="data row2 col5" >75</td>
<td id="T_b366d_row2_col6" class="data row2 col6" >74</td>
<td id="T_b366d_row2_col7" class="data row2 col7" >73</td>
<td id="T_b366d_row2_col8" class="data row2 col8" >72</td>
<td id="T_b366d_row2_col9" class="data row2 col9" >L</td>
</tr>
<tr>
<th id="T_b366d_level0_row3" class="row_heading level0 row3" >3</th>
<td id="T_b366d_row3_col0" class="data row3 col0" >61</td>
<td id="T_b366d_row3_col1" class="data row3 col1" >62</td>
<td id="T_b366d_row3_col2" class="data row3 col2" >S</td>
<td id="T_b366d_row3_col3" class="data row3 col3" >64</td>
<td id="T_b366d_row3_col4" class="data row3 col4" >65</td>
<td id="T_b366d_row3_col5" class="data row3 col5" >66</td>
<td id="T_b366d_row3_col6" class="data row3 col6" >67</td>
<td id="T_b366d_row3_col7" class="data row3 col7" >68</td>
<td id="T_b366d_row3_col8" class="data row3 col8" >69</td>
<td id="T_b366d_row3_col9" class="data row3 col9" >70</td>
</tr>
<tr>
<th id="T_b366d_level0_row4" class="row_heading level0 row4" >4</th>
<td id="T_b366d_row4_col0" class="data row4 col0" >60</td>
<td id="T_b366d_row4_col1" class="data row4 col1" >59</td>
<td id="T_b366d_row4_col2" class="data row4 col2" >58</td>
<td id="T_b366d_row4_col3" class="data row4 col3" >57</td>
<td id="T_b366d_row4_col4" class="data row4 col4" >56</td>
<td id="T_b366d_row4_col5" class="data row4 col5" >55</td>
<td id="T_b366d_row4_col6" class="data row4 col6" >54</td>
<td id="T_b366d_row4_col7" class="data row4 col7" >53</td>
<td id="T_b366d_row4_col8" class="data row4 col8" >52</td>
<td id="T_b366d_row4_col9" class="data row4 col9" >51</td>
</tr>
<tr>
<th id="T_b366d_level0_row5" class="row_heading level0 row5" >5</th>
<td id="T_b366d_row5_col0" class="data row5 col0" >41</td>
<td id="T_b366d_row5_col1" class="data row5 col1" >42</td>
<td id="T_b366d_row5_col2" class="data row5 col2" >43</td>
<td id="T_b366d_row5_col3" class="data row5 col3" >44</td>
<td id="T_b366d_row5_col4" class="data row5 col4" >45</td>
<td id="T_b366d_row5_col5" class="data row5 col5" >46</td>
<td id="T_b366d_row5_col6" class="data row5 col6" >47</td>
<td id="T_b366d_row5_col7" class="data row5 col7" >S</td>
<td id="T_b366d_row5_col8" class="data row5 col8" >49</td>
<td id="T_b366d_row5_col9" class="data row5 col9" >L</td>
</tr>
<tr>
<th id="T_b366d_level0_row6" class="row_heading level0 row6" >6</th>
<td id="T_b366d_row6_col0" class="data row6 col0" >L</td>
<td id="T_b366d_row6_col1" class="data row6 col1" >39</td>
<td id="T_b366d_row6_col2" class="data row6 col2" >38</td>
<td id="T_b366d_row6_col3" class="data row6 col3" >37</td>
<td id="T_b366d_row6_col4" class="data row6 col4" >S</td>
<td id="T_b366d_row6_col5" class="data row6 col5" >35</td>
<td id="T_b366d_row6_col6" class="data row6 col6" >34</td>
<td id="T_b366d_row6_col7" class="data row6 col7" >33</td>
<td id="T_b366d_row6_col8" class="data row6 col8" >S</td>
<td id="T_b366d_row6_col9" class="data row6 col9" >31</td>
</tr>
<tr>
<th id="T_b366d_level0_row7" class="row_heading level0 row7" >7</th>
<td id="T_b366d_row7_col0" class="data row7 col0" >21</td>
<td id="T_b366d_row7_col1" class="data row7 col1" >22</td>
<td id="T_b366d_row7_col2" class="data row7 col2" >23</td>
<td id="T_b366d_row7_col3" class="data row7 col3" >24</td>
<td id="T_b366d_row7_col4" class="data row7 col4" >25</td>
<td id="T_b366d_row7_col5" class="data row7 col5" >26</td>
<td id="T_b366d_row7_col6" class="data row7 col6" >27</td>
<td id="T_b366d_row7_col7" class="data row7 col7" >L</td>
<td id="T_b366d_row7_col8" class="data row7 col8" >29</td>
<td id="T_b366d_row7_col9" class="data row7 col9" >30</td>
</tr>
<tr>
<th id="T_b366d_level0_row8" class="row_heading level0 row8" >8</th>
<td id="T_b366d_row8_col0" class="data row8 col0" >L</td>
<td id="T_b366d_row8_col1" class="data row8 col1" >19</td>
<td id="T_b366d_row8_col2" class="data row8 col2" >18</td>
<td id="T_b366d_row8_col3" class="data row8 col3" >17</td>
<td id="T_b366d_row8_col4" class="data row8 col4" >16</td>
<td id="T_b366d_row8_col5" class="data row8 col5" >15</td>
<td id="T_b366d_row8_col6" class="data row8 col6" >14</td>
<td id="T_b366d_row8_col7" class="data row8 col7" >13</td>
<td id="T_b366d_row8_col8" class="data row8 col8" >12</td>
<td id="T_b366d_row8_col9" class="data row8 col9" >11</td>
</tr>
<tr>
<th id="T_b366d_level0_row9" class="row_heading level0 row9" >9</th>
<td id="T_b366d_row9_col0" class="data row9 col0" >1</td>
<td id="T_b366d_row9_col1" class="data row9 col1" >2</td>
<td id="T_b366d_row9_col2" class="data row9 col2" >3</td>
<td id="T_b366d_row9_col3" class="data row9 col3" >L</td>
<td id="T_b366d_row9_col4" class="data row9 col4" >5</td>
<td id="T_b366d_row9_col5" class="data row9 col5" >6</td>
<td id="T_b366d_row9_col6" class="data row9 col6" >7</td>
<td id="T_b366d_row9_col7" class="data row9 col7" >L</td>
<td id="T_b366d_row9_col8" class="data row9 col8" >9</td>
<td id="T_b366d_row9_col9" class="data row9 col9" >10</td>
</tr>
</tbody>
</table>
1 change: 1 addition & 0 deletions very_easy/is_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

23 changes: 23 additions & 0 deletions very_easy/test_is_number.py
Original file line number Diff line number Diff line change
@@ -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."