Spaces:
Sleeping
Sleeping
epochs-demos
commited on
Commit
•
e117b14
1
Parent(s):
296e585
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -72,20 +72,20 @@ def main():
|
|
72 |
st.write("Create a function sum that meets the following criteria:")
|
73 |
st.write('''sass''')
|
74 |
|
|
|
75 |
def execute_instructor_code(params):
|
76 |
# Execute the instructor's code to get the result
|
77 |
globals_dict = {}
|
78 |
exec('''def sum(a,b):
|
79 |
return a+b''', globals_dict)
|
80 |
-
instructor_function = globals_dict.get(
|
81 |
|
82 |
if not callable(instructor_function):
|
83 |
-
raise ValueError(f"{
|
84 |
|
85 |
return instructor_function(*params)
|
86 |
|
87 |
# Generate sample examples dynamically by executing the instructor's code
|
88 |
-
func = sum
|
89 |
test_cases = [(1, 2), (2, 3), (3, 4)]
|
90 |
sample_examples = "\n".join([f"{func}({', '.join(map(str, params))}) -> {execute_instructor_code(params)}" for params in {test_cases}])
|
91 |
show_solution_button = st.form_submit_button("Show Solution")
|
|
|
72 |
st.write("Create a function sum that meets the following criteria:")
|
73 |
st.write('''sass''')
|
74 |
|
75 |
+
func = sum
|
76 |
def execute_instructor_code(params):
|
77 |
# Execute the instructor's code to get the result
|
78 |
globals_dict = {}
|
79 |
exec('''def sum(a,b):
|
80 |
return a+b''', globals_dict)
|
81 |
+
instructor_function = globals_dict.get(func)
|
82 |
|
83 |
if not callable(instructor_function):
|
84 |
+
raise ValueError(f"{func} is not a callable function.")
|
85 |
|
86 |
return instructor_function(*params)
|
87 |
|
88 |
# Generate sample examples dynamically by executing the instructor's code
|
|
|
89 |
test_cases = [(1, 2), (2, 3), (3, 4)]
|
90 |
sample_examples = "\n".join([f"{func}({', '.join(map(str, params))}) -> {execute_instructor_code(params)}" for params in {test_cases}])
|
91 |
show_solution_button = st.form_submit_button("Show Solution")
|