Sina Media Lab
commited on
Commit
Β·
31d5315
1
Parent(s):
14697cf
Updates
Browse files- app.py +3 -3
- modules/{numbering_system β number_system}/__init__.py +0 -0
- modules/{numbering_system β number_system}/addition_bases.py +0 -0
- modules/{numbering_system β number_system}/config.py +1 -1
- modules/{numbering_system β number_system}/conversion_bases.py +0 -0
- modules/{numbering_system β number_system}/grouping_techniques.py +0 -0
- modules/{numbering_system β number_system}/negative_binary.py +0 -0
- modules/{numbering_system β number_system}/presentation_bases.py +0 -0
- modules/{numbering_system β number_system}/subtraction_bases.py +0 -0
- modules/{numbering_system β number_system}/twos_complement.py +0 -0
- modules/{numbering_system β number_system}/valid_invalid_numbers.py +21 -8
app.py
CHANGED
@@ -38,11 +38,11 @@ def generate_pdf_report():
|
|
38 |
pdf.set_font("Arial", style='B', size=18)
|
39 |
|
40 |
# Title of the report
|
41 |
-
pdf.cell(0, 10, txt="Magic Math Quiz", ln=True, align="C")
|
42 |
pdf.ln(5)
|
43 |
|
44 |
# Load the image from the URL, scaled down and centered
|
45 |
-
pdf.image("
|
46 |
pdf.ln(10)
|
47 |
|
48 |
for i, entry in enumerate(st.session_state.questions):
|
@@ -151,7 +151,7 @@ modules = load_modules()
|
|
151 |
st.sidebar.markdown(
|
152 |
"""
|
153 |
<div style='background-color: white; padding: 10px; border-radius: 10px; text-align: center; color: black;'>
|
154 |
-
<h1 style='margin: 0;'>πͺ Magic Math Quiz
|
155 |
<a href="https://ghassem.com" target="_blank">
|
156 |
<img src="https://huggingface.co/spaces/tofighi/math/resolve/main/assets/gt.png" alt="Logo" style="width:50%; margin-top: 10px;">
|
157 |
</a>
|
|
|
38 |
pdf.set_font("Arial", style='B', size=18)
|
39 |
|
40 |
# Title of the report
|
41 |
+
pdf.cell(0, 10, txt="Magic Math Quiz!", ln=True, align="C")
|
42 |
pdf.ln(5)
|
43 |
|
44 |
# Load the image from the URL, scaled down and centered
|
45 |
+
pdf.image("assets/gt.png", x=(210 - 25) / 2, w=25, link="https://ghassem.com") # Centered horizontally and scaled down
|
46 |
pdf.ln(10)
|
47 |
|
48 |
for i, entry in enumerate(st.session_state.questions):
|
|
|
151 |
st.sidebar.markdown(
|
152 |
"""
|
153 |
<div style='background-color: white; padding: 10px; border-radius: 10px; text-align: center; color: black;'>
|
154 |
+
<h1 style='margin: 0;'>πͺ Magic Math Quiz!<sup>Beta</sup></h1>
|
155 |
<a href="https://ghassem.com" target="_blank">
|
156 |
<img src="https://huggingface.co/spaces/tofighi/math/resolve/main/assets/gt.png" alt="Logo" style="width:50%; margin-top: 10px;">
|
157 |
</a>
|
modules/{numbering_system β number_system}/__init__.py
RENAMED
File without changes
|
modules/{numbering_system β number_system}/addition_bases.py
RENAMED
File without changes
|
modules/{numbering_system β number_system}/config.py
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
-
title = "
|
2 |
description = "This category covers various operations and concepts in different numbering systems, including binary, octal, decimal, and hexadecimal."
|
3 |
order=10
|
|
|
1 |
+
title = "Number System"
|
2 |
description = "This category covers various operations and concepts in different numbering systems, including binary, octal, decimal, and hexadecimal."
|
3 |
order=10
|
modules/{numbering_system β number_system}/conversion_bases.py
RENAMED
File without changes
|
modules/{numbering_system β number_system}/grouping_techniques.py
RENAMED
File without changes
|
modules/{numbering_system β number_system}/negative_binary.py
RENAMED
File without changes
|
modules/{numbering_system β number_system}/presentation_bases.py
RENAMED
File without changes
|
modules/{numbering_system β number_system}/subtraction_bases.py
RENAMED
File without changes
|
modules/{numbering_system β number_system}/twos_complement.py
RENAMED
File without changes
|
modules/{numbering_system β number_system}/valid_invalid_numbers.py
RENAMED
@@ -1,4 +1,4 @@
|
|
1 |
-
# modules/valid_invalid_numbers.py
|
2 |
|
3 |
title = "Validity of Numbers in Bases"
|
4 |
description = "This module helps determine the validity of numbers in different bases like binary, octal, decimal, and hexadecimal."
|
@@ -10,15 +10,28 @@ def generate_question():
|
|
10 |
length = random.randint(3, 5)
|
11 |
|
12 |
def generate_valid_number():
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
|
15 |
def generate_invalid_number():
|
16 |
-
|
17 |
-
|
18 |
-
invalid_digit =
|
19 |
else:
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
correct_answer = generate_invalid_number()
|
24 |
options = [correct_answer]
|
@@ -32,7 +45,7 @@ def generate_question():
|
|
32 |
random.shuffle(options)
|
33 |
|
34 |
question = f"Which of the following is an invalid number in base {base}?"
|
35 |
-
explanation = f"The number {correct_answer} is invalid in base {base} because it contains a digit outside the range
|
36 |
step_by_step_solution = [
|
37 |
"Step 1: Identify the valid digits for the base.",
|
38 |
"Step 2: Check each option to see if it contains any invalid digits.",
|
|
|
1 |
+
# modules/number_system/valid_invalid_numbers.py
|
2 |
|
3 |
title = "Validity of Numbers in Bases"
|
4 |
description = "This module helps determine the validity of numbers in different bases like binary, octal, decimal, and hexadecimal."
|
|
|
10 |
length = random.randint(3, 5)
|
11 |
|
12 |
def generate_valid_number():
|
13 |
+
if base == 16:
|
14 |
+
valid_digits = '0123456789ABCDEF'
|
15 |
+
else:
|
16 |
+
valid_digits = ''.join([str(i) for i in range(base)])
|
17 |
+
return ''.join([random.choice(valid_digits) for _ in range(length)])
|
18 |
|
19 |
def generate_invalid_number():
|
20 |
+
if base == 16:
|
21 |
+
valid_digits = '0123456789ABCDEF'
|
22 |
+
invalid_digit = random.choice('GHIJKLMNOPQRSTUVWXYZ')
|
23 |
else:
|
24 |
+
valid_digits = ''.join([str(i) for i in range(base)])
|
25 |
+
if base < 10:
|
26 |
+
invalid_digit = str(random.randint(base, 9)) # For bases < 10, pick an invalid digit from [base, 9]
|
27 |
+
else:
|
28 |
+
invalid_digit = random.choice('GHIJKLMNOPQRSTUVWXYZ')
|
29 |
+
|
30 |
+
# Replace a random digit in a valid number with an invalid digit
|
31 |
+
valid_number = list(generate_valid_number())
|
32 |
+
replace_index = random.randint(0, length - 1)
|
33 |
+
valid_number[replace_index] = invalid_digit
|
34 |
+
return ''.join(valid_number)
|
35 |
|
36 |
correct_answer = generate_invalid_number()
|
37 |
options = [correct_answer]
|
|
|
45 |
random.shuffle(options)
|
46 |
|
47 |
question = f"Which of the following is an invalid number in base {base}?"
|
48 |
+
explanation = f"The number {correct_answer} is invalid in base {base} because it contains a digit outside the range allowed for base {base}."
|
49 |
step_by_step_solution = [
|
50 |
"Step 1: Identify the valid digits for the base.",
|
51 |
"Step 2: Check each option to see if it contains any invalid digits.",
|