epochs-demos commited on
Commit
f05b7bc
·
verified ·
1 Parent(s): 97af4e1

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1,14 +1,13 @@
1
 
2
-
3
  import streamlit as st
4
  from streamlit_ace import st_ace
5
  import pandas as pd
6
 
7
  button_style = st.markdown('''
8
  <style>
9
- div.stButton > button:first-child {{
10
  background-color: #3A7EF1;
11
- }}
12
  </style>''', unsafe_allow_html=True)
13
 
14
  left_co, cent_co,last_co = st.columns(3)
@@ -26,7 +25,7 @@ def check_solution(code, func_params):
26
  function_to_test = globals_dict.get(func_params.get('function_name'))
27
 
28
  if not callable(function_to_test):
29
- raise ValueError(f"{{func_params.get('function_name')}} is not a callable function.")
30
 
31
  # Run the tests and populate the results table
32
  expected_result_list = []
@@ -53,7 +52,7 @@ def check_solution(code, func_params):
53
  return True
54
 
55
  except SyntaxError as e:
56
- st.error(f"Error: {{e}}")
57
 
58
 
59
  def main():
@@ -63,30 +62,31 @@ def main():
63
 
64
  # Description of the challenge
65
  st.write("Create a function sum that meets the following criteria:")
66
- st.write('''Sum of two values''')
67
 
68
  # Display sample example for all test cases
69
- sample_examples = "Sample"
70
  st.code(sample_examples, language="python")
71
  show_solution_button = st.form_submit_button("Show Solution")
72
  if show_solution_button:
73
  solution = '''def sum(a,b):
74
- return a+b '''
75
  if solution:
76
  st.code('''def sum(a,b):
77
- return a+b ''', language="python")
78
  else:
79
  st.error('No Solution Provided!')
80
 
81
  # Code input area
82
- code = st_ace(value='''def sum(a,b):''', language="python", key="my_editor", theme='clouds', height=200)
 
83
  # Check solution button
84
  if st.form_submit_button("Check Solution"):
85
  if code:
86
  # Check the solution
87
  check_solution(code, {
88
  "function_name": "sum",
89
- "test_cases": [((1, 2), 3), ((1, 0), 1), ((-1, -2), -3)]
90
  })
91
  else:
92
  st.error("Please provide a solution.")
@@ -95,5 +95,3 @@ def main():
95
 
96
  if __name__ == "__main__":
97
  main()
98
-
99
-
 
1
 
 
2
  import streamlit as st
3
  from streamlit_ace import st_ace
4
  import pandas as pd
5
 
6
  button_style = st.markdown('''
7
  <style>
8
+ div.stButton > button:first-child {
9
  background-color: #3A7EF1;
10
+ }
11
  </style>''', unsafe_allow_html=True)
12
 
13
  left_co, cent_co,last_co = st.columns(3)
 
25
  function_to_test = globals_dict.get(func_params.get('function_name'))
26
 
27
  if not callable(function_to_test):
28
+ raise ValueError(f"{func_params.get('function_name')} is not a callable function.")
29
 
30
  # Run the tests and populate the results table
31
  expected_result_list = []
 
52
  return True
53
 
54
  except SyntaxError as e:
55
+ st.error(f"Error: {e}")
56
 
57
 
58
  def main():
 
62
 
63
  # Description of the challenge
64
  st.write("Create a function sum that meets the following criteria:")
65
+ st.write('''assd''')
66
 
67
  # Display sample example for all test cases
68
+ sample_examples = "\n".join([f"sum({params}) -> {expected_output}" for params, expected_output in [((1, 2), 3)]])
69
  st.code(sample_examples, language="python")
70
  show_solution_button = st.form_submit_button("Show Solution")
71
  if show_solution_button:
72
  solution = '''def sum(a,b):
73
+ return a+b'''
74
  if solution:
75
  st.code('''def sum(a,b):
76
+ return a+b''', language="python")
77
  else:
78
  st.error('No Solution Provided!')
79
 
80
  # Code input area
81
+ code = st_ace(value='''def sum(a,b):
82
+ ''', language="python", key="my_editor", theme='clouds', height=200)
83
  # Check solution button
84
  if st.form_submit_button("Check Solution"):
85
  if code:
86
  # Check the solution
87
  check_solution(code, {
88
  "function_name": "sum",
89
+ "test_cases": [((1, 2), 3)]
90
  })
91
  else:
92
  st.error("Please provide a solution.")
 
95
 
96
  if __name__ == "__main__":
97
  main()