| import streamlit as st
|
| import inspect
|
|
|
| from numpy.random.mtrand import vonmises
|
|
|
|
|
|
|
|
|
|
|
| st.set_page_config(
|
| page_title="Ranadeep Python Function Viewer",
|
| page_icon="💻",
|
| layout="wide"
|
| )
|
|
|
|
|
|
|
|
|
|
|
| st.markdown("""
|
| <style>
|
|
|
| .main {
|
| background-color: #0E1117;
|
| color: white;
|
| }
|
|
|
| section[data-testid="stSidebar"] {
|
| background-color: #161A28;
|
| }
|
|
|
| .stTextInput input {
|
| background-color: #262730;
|
| color: white;
|
| border-radius: 10px;
|
| padding: 12px;
|
| border: 2px solid red;
|
| }
|
|
|
| /* =====================================================
|
| BUTTON STYLING
|
| ===================================================== */
|
|
|
| div.stButton > button {
|
|
|
| width: 100%;
|
| background-color: #1E1E1E;
|
| color: white;
|
| border-radius: 12px;
|
| margin-bottom: 10px;
|
| border: 1px solid #333;
|
|
|
| transition: all 0.3s ease-in-out;
|
|
|
| box-shadow: 0px 0px 5px rgba(0,0,0,0.5);
|
|
|
| font-size: 16px;
|
| font-weight: bold;
|
|
|
| padding: 10px;
|
| }
|
|
|
| /* =====================================================
|
| HOVER EFFECT
|
| ===================================================== */
|
|
|
| div.stButton > button:hover {
|
|
|
| background-color: #262730;
|
|
|
| color: #ff1744;
|
|
|
| border: 1px solid #00FFAA;
|
|
|
| transform: scale(1.05);
|
|
|
| box-shadow: 0px 0px 15px #ff5555;
|
|
|
| cursor: pointer;
|
| }
|
|
|
| /* =====================================================
|
| CLICK EFFECT
|
| ===================================================== */
|
|
|
| div.stButton > button:active {
|
|
|
| transform: scale(0.97);
|
|
|
| box-shadow: 0px 0px 10px red;
|
| }
|
|
|
| /* =====================================================
|
| HEADINGS
|
| ===================================================== */
|
|
|
| h1, h2, h3 {
|
| color: white;
|
| }
|
|
|
| /* =====================================================
|
| SIDEBAR CATEGORY HOVER
|
| ===================================================== */
|
|
|
| section[data-testid="stSidebar"] h2:hover {
|
|
|
| color: #00FFFF;
|
| transition: 0.3s;
|
| }
|
|
|
| /* =====================================================
|
| SCROLLBAR
|
| ===================================================== */
|
|
|
| ::-webkit-scrollbar {
|
| width: 10px;
|
| }
|
|
|
| ::-webkit-scrollbar-track {
|
| background: #1E1E1E;
|
| }
|
|
|
| ::-webkit-scrollbar-thumb {
|
| background: #00FFAA;
|
| border-radius: 10px;
|
| }
|
|
|
| ::-webkit-scrollbar-thumb:hover {
|
| background: red;
|
| }
|
|
|
| </style>
|
| """, unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
| class Operations:
|
|
|
|
|
|
|
| def add(self, x, y):
|
| """Adds two numbers"""
|
| return x + y
|
|
|
| def subtract(self, x, y):
|
| """Subtracts second number from first number"""
|
| return x - y
|
|
|
| def multiply(self, a, b):
|
| """Multiplies two numbers"""
|
| return a * b
|
|
|
| def divide(self, x, y):
|
| """Divides two numbers"""
|
| if y == 0:
|
| return "Cannot divide by zero"
|
| return x / y
|
|
|
|
|
|
|
| def square(self, numbers):
|
| """Returns square of numbers"""
|
| result = []
|
|
|
| for i in numbers:
|
| result.append(i * i)
|
|
|
| return result
|
|
|
| def cube(self, numbers):
|
| """Returns cube of numbers"""
|
| result = []
|
|
|
| for i in numbers:
|
| result.append(i * i * i)
|
|
|
| return result
|
|
|
| def power(self, numbers, p):
|
| """Returns power of numbers"""
|
| result = []
|
|
|
| for i in numbers:
|
| result.append(i ** p)
|
|
|
| return result
|
|
|
| def sqrt(self, numbers):
|
| """Returns square root of numbers"""
|
| result = []
|
|
|
| for i in numbers:
|
| result.append(i ** 0.5)
|
|
|
| return result
|
|
|
|
|
|
|
| def maximum(self, numbers):
|
| """Returns maximum number"""
|
| return max(numbers)
|
|
|
| def minimum(self, numbers):
|
| """Returns minimum number"""
|
| return min(numbers)
|
|
|
| def sort(self, numbers):
|
| """Sorts array"""
|
|
|
| n = len(numbers)
|
|
|
| for i in range(n):
|
|
|
| for j in range(0, n - i - 1):
|
|
|
| if numbers[j] > numbers[j + 1]:
|
|
|
| numbers[j], numbers[j + 1] = numbers[j + 1], numbers[j]
|
|
|
| return numbers
|
|
|
| def unique(self, numbers):
|
| """Removes duplicate values"""
|
| result = []
|
|
|
| for i in numbers:
|
|
|
| if i not in result:
|
| result.append(i)
|
|
|
| return result
|
|
|
| def reverse_array(self, numbers):
|
| """Reverses list"""
|
| result = []
|
|
|
| for i in range(len(numbers)-1, -1, -1):
|
| result.append(numbers[i])
|
|
|
| return result
|
|
|
| def even(self, numbers):
|
| """Returns even numbers"""
|
| result = []
|
|
|
| for i in numbers:
|
|
|
| if i % 2 == 0:
|
| result.append(i)
|
|
|
| return result
|
|
|
| def odd(self, numbers):
|
| """Returns odd numbers"""
|
| result = []
|
|
|
| for i in numbers:
|
|
|
| if i % 2 != 0:
|
| result.append(i)
|
|
|
| return result
|
|
|
| def count(self,numbers):
|
| """
|
| This function returns the number of numbers
|
| """
|
| total = 0
|
| for i in numbers:
|
| total += 1
|
| return total
|
|
|
| def remove_duplicates(self,numbers):
|
| """
|
| This function removes duplicate numbers
|
| """
|
| result = []
|
| for i in numbers:
|
| if i not in result:
|
| result.append(i)
|
| return result
|
|
|
| def frequency(self,numbers):
|
| """
|
| This function returns the frequency of numbers
|
| """
|
| result = {}
|
| for i in numbers:
|
| if i in result:
|
| result[i] += 1
|
| else:
|
| result[i] = 1
|
| return result
|
|
|
| def remove_negative(self,numbers):
|
| """
|
| This function removes negative numbers
|
| """
|
| result = []
|
| for i in numbers:
|
| if i >= 0:
|
| result.append(i)
|
| return result
|
|
|
| def find_index(self,numbers, value):
|
| """
|
| This function returns the index of a number
|
| """
|
| for i in range(len(numbers)):
|
| if numbers[i] == value:
|
| return i
|
| return -1
|
|
|
| def concatenate(self,a, b):
|
| """
|
| This function concatenates a list of numbers
|
| """
|
| result = []
|
| for i in a:
|
| result.append(i)
|
| for j in b:
|
| result.append(j)
|
| return result
|
|
|
| def repeat(self,numbers, times):
|
| """
|
| This function repeats a list of numbers
|
| """
|
| result = []
|
| for i in numbers:
|
| for j in range(int(times)):
|
| result.append(i)
|
| return result
|
|
|
| def equal(self,a, b):
|
| """
|
| This function returns the equal arrays
|
| """
|
| if len(a) != len(b):
|
| return False
|
| for i in range(len(a)):
|
| if a[i] != b[i]:
|
| return False
|
| return True
|
|
|
| def bubble_sort(self,numbers):
|
| """
|
| This function returns the bubble sort
|
| """
|
| n = len(numbers)
|
| for i in range(n):
|
| for j in range(0, n - i - 1):
|
| if numbers[j] > numbers[j + 1]:
|
| numbers[j], numbers[j + 1] = numbers[j + 1], numbers[j]
|
| return numbers
|
|
|
| def linear_search(self,numbers, target):
|
| """
|
| This function returns the linear search
|
| """
|
| for i in range(len(numbers)):
|
| if numbers[i] == target:
|
| return i
|
| return -1
|
|
|
| def zeros(self,size):
|
| """
|
| Returns a list of zeros
|
| """
|
| result = []
|
| size = int(size)
|
|
|
| for i in range(size):
|
| result.append(0)
|
|
|
| return result
|
|
|
| def standardize(self,numbers):
|
| """
|
| Standardizes array values
|
| """
|
| mean_value = sum(numbers) / len(numbers)
|
|
|
| variance = 0
|
|
|
| for i in numbers:
|
| variance += (i - mean_value) ** 2
|
|
|
| variance /= len(numbers)
|
|
|
| std = variance ** 0.5
|
|
|
| result = []
|
|
|
| for i in numbers:
|
| result.append((i - mean_value) / std)
|
|
|
| return result
|
|
|
| def slice(self,numbers, start, end):
|
| """
|
| Returns sliced array
|
| """
|
| start = int(start)
|
| end = int(end)
|
| result = []
|
|
|
| for i in range(start, end):
|
| result.append(numbers[i])
|
|
|
| return result
|
|
|
| def sorted(self,numbers):
|
| """
|
| Checks if array is sorted
|
| """
|
| for i in range(len(numbers) - 1):
|
| if numbers[i] > numbers[i + 1]:
|
| return False
|
|
|
| return True
|
|
|
| def padding(self,numbers, size, value):
|
| """
|
| Pads array with a value
|
| """
|
|
|
| numbers = list(numbers)
|
| size = int(size)
|
| result = numbers[:]
|
|
|
| while len(result) < size:
|
| result.append(value)
|
|
|
| return result
|
|
|
|
|
|
|
| def factorial(self, number):
|
| """Returns factorial"""
|
|
|
| number = int(number)
|
|
|
| result = 1
|
|
|
| for i in range(1, number + 1):
|
| result *= i
|
|
|
| return result
|
|
|
| def fibonacci(self, limit):
|
| """Returns fibonacci series"""
|
| limit = int(limit)
|
|
|
| a = 0
|
| b = 1
|
|
|
| result = []
|
|
|
| for i in range(limit):
|
|
|
| result.append(a)
|
|
|
| c = a + b
|
|
|
| a = b
|
| b = c
|
|
|
| return result
|
|
|
| def prime(self, number):
|
| """Checks prime number"""
|
| number = int(number)
|
|
|
| if number <= 1:
|
| return False
|
|
|
| for i in range(2, number):
|
|
|
| if number % i == 0:
|
| return False
|
|
|
| return True
|
|
|
| def armstrong(self, number):
|
| """Checks armstrong number"""
|
|
|
| total = 0
|
|
|
| temp = number
|
|
|
| digits = len(str(number))
|
|
|
| while temp > 0:
|
|
|
| digit = temp % 10
|
|
|
| total += digit ** digits
|
|
|
| temp = temp // 10
|
|
|
| return total == number
|
|
|
|
|
|
|
| def palindrome(self, value):
|
| """Checks palindrome"""
|
|
|
| text = str(value)
|
|
|
| return text == text[::-1]
|
|
|
| def reverse_string(self, text):
|
| """Reverses string"""
|
|
|
| result = ""
|
|
|
| for i in text:
|
| result = i + result
|
|
|
| return result
|
|
|
| def vowels(self, text):
|
| """Counts vowels"""
|
|
|
| count = 0
|
|
|
| for i in text.lower():
|
|
|
| if i in "aeiou":
|
| count += 1
|
|
|
| return count
|
|
|
|
|
|
|
| def matrix_addition(self, a, b):
|
| """Adds matrices"""
|
|
|
| result = []
|
|
|
| for i in range(len(a)):
|
|
|
| row = []
|
|
|
| for j in range(len(a[0])):
|
| row.append(a[i][j] + b[i][j])
|
|
|
| result.append(row)
|
|
|
| return result
|
|
|
| def matrix_subtract(self, a, b):
|
| """Subtracts matrices"""
|
|
|
| result = []
|
|
|
| for i in range(len(a)):
|
|
|
| row = []
|
|
|
| for j in range(len(a[0])):
|
| row.append(a[i][j] - b[i][j])
|
|
|
| result.append(row)
|
|
|
| return result
|
|
|
| def transpose(self, matrix):
|
| """Returns transpose matrix"""
|
|
|
| result = []
|
|
|
| rows = len(matrix)
|
| cols = len(matrix[0])
|
|
|
| for i in range(cols):
|
|
|
| row = []
|
|
|
| for j in range(rows):
|
| row.append(matrix[j][i])
|
|
|
| result.append(row)
|
|
|
| return result
|
|
|
| def matrix_multiplication(self,a, b):
|
| """
|
| This function multiplies two matrices
|
| """
|
| result = [[0 for j in range(len(b[0]))]
|
| for i in range(len(a))]
|
| for i in range(len(a)):
|
| for j in range(len(b[0])):
|
| for k in range(len(b)):
|
| result[i][j] += a[i][k] * b[k][j]
|
| return result
|
|
|
| def shape(self,matrix):
|
| """
|
| This function returns the shape of a matrix
|
| """
|
| rows = len(matrix)
|
| cols = len(matrix[0])
|
| return (rows, cols)
|
|
|
| def flatten(self,matrix):
|
| """
|
| Converts matrix into single list
|
| """
|
| result = []
|
|
|
| for row in matrix:
|
| for item in row:
|
| result.append(item)
|
|
|
| return result
|
|
|
| def trace(self,matrix):
|
| """
|
| This function returns the trace
|
| """
|
| total = 0
|
| for i in range(len(matrix)):
|
| total += matrix[i][i]
|
| return total
|
|
|
| def scalar_multiply(self,matrix, scalar):
|
| """
|
| This function returns the scalar multiplication
|
| """
|
| result = []
|
| for row in matrix:
|
| new_row = []
|
| for value in row:
|
| new_row.append(value * scalar)
|
| result.append(new_row)
|
| return result
|
|
|
| def reverse_rows(self,matrix):
|
| """
|
| This function returns the reverse rows
|
| """
|
| result = []
|
| for row in matrix:
|
| result.append(row[::-1])
|
| return result
|
|
|
| def reshape(self,numbers, rows, cols):
|
| """
|
| Reshapes a list into matrix form
|
| """
|
| result = []
|
| index = 0
|
|
|
| for i in range(rows):
|
| row = []
|
|
|
| for j in range(cols):
|
| row.append(numbers[index])
|
| index += 1
|
|
|
| result.append(row)
|
|
|
| return result
|
|
|
| def row_sum(self,matrix):
|
| """
|
| Returns sum of each row
|
| """
|
| result = []
|
|
|
| for row in matrix:
|
| total = 0
|
|
|
| for value in row:
|
| total += value
|
|
|
| result.append(total)
|
|
|
| return result
|
|
|
| def column_sum(self,matrix):
|
| """
|
| Returns sum of each column
|
| """
|
| result = []
|
|
|
| cols = len(matrix[0])
|
|
|
| for i in range(cols):
|
| total = 0
|
|
|
| for j in range(len(matrix)):
|
| total += matrix[j][i]
|
|
|
| result.append(total)
|
|
|
| return result
|
|
|
|
|
|
|
| def mean(self,numbers):
|
| """
|
| This function returns the mean of a list of numbers
|
| """
|
| total = sum(numbers)
|
|
|
| count = len(numbers)
|
|
|
| result = total / count
|
|
|
| return result
|
|
|
| def median(self,numbers):
|
| """
|
| This function returns the median of a list of numbers
|
| """
|
| numbers = sorted(numbers)
|
| n = len(numbers)
|
| middle = n // 2
|
| if n % 2 == 0:
|
| return (numbers[middle - 1] + numbers[middle]) / 2
|
| else:
|
| return numbers[middle]
|
|
|
| def mode(self,numbers):
|
| """
|
| This function returns the mode of a list of numbers
|
| """
|
| frequency = {}
|
| for i in numbers:
|
| if i in frequency:
|
| frequency[i] += 1
|
| else:
|
| frequency[i] = 1
|
| max_count = 0
|
| mode_value = None
|
| for key in frequency:
|
| if frequency[key] > max_count:
|
| max_count = frequency[key]
|
| mode_value = key
|
| return mode_value
|
|
|
| def variance(self,numbers):
|
| """
|
| This function returns the variance
|
| """
|
| mean = sum(numbers) / len(numbers)
|
| total = 0
|
|
|
| for i in numbers:
|
| total += (i - mean) ** 2
|
|
|
| return total / len(numbers)
|
|
|
| def standard_deviation(self,numbers):
|
| """
|
| This function returns the standard deviation
|
| """
|
| mean = sum(numbers) / len(numbers)
|
| total = 0
|
|
|
| for i in numbers:
|
| total += (i - mean) ** 2
|
|
|
| variance = total / len(numbers)
|
|
|
| return variance ** 0.5
|
|
|
| def mean_absolute_difference(self,numbers):
|
| """
|
| This function returns the mean absolute difference
|
| """
|
| avg = sum(numbers) / len(numbers)
|
| total = 0
|
|
|
| for i in numbers:
|
| total += abs(i - avg)
|
|
|
| return total / len(numbers)
|
|
|
| def normalize(self,numbers):
|
| """
|
| This function normalizes a list of numbers
|
| """
|
| min_value = min(numbers)
|
| max_value = max(numbers)
|
|
|
| result = []
|
|
|
| for i in numbers:
|
| value = (i - min_value) / (max_value - min_value)
|
| result.append(value)
|
|
|
| return result
|
|
|
|
|
|
|
| def dot_product(self,a, b):
|
| """
|
| This function returns the dot product
|
| """
|
| result = 0
|
| for i in range(len(a)):
|
| result += a[i] * b[i]
|
| return result
|
|
|
| def add_arrays(self,a, b):
|
| """
|
| This function adds two arrays
|
| """
|
| result = []
|
| for i in range(len(a)):
|
| result.append(a[i] + b[i])
|
| return result
|
|
|
| def multiply_arrays(self,a, b):
|
| """
|
| This function multiply two arrays
|
| """
|
| result = []
|
| for i in range(len(a)):
|
| result.append(a[i] * b[i])
|
| return result
|
|
|
|
|
|
|
|
|
|
|
|
|
| obj = Operations()
|
|
|
|
|
|
|
|
|
|
|
| categories = {
|
|
|
| "➕ Basic Functions": [
|
| ("➕ add", "add"),
|
| ("➖ subtract", "subtract"),
|
| ("✖ multiply", "multiply"),
|
| ("➗ divide", "divide")
|
| ],
|
|
|
| "⚡ Power Functions": [
|
| ("⬛ square", "square"),
|
| ("🧊 cube", "cube"),
|
| ("⚡ power", "power"),
|
| ("√ sqrt", "sqrt")
|
| ],
|
|
|
| "📊 Array Functions": [
|
| ("📈 maximum", "maximum"),
|
| ("📉 minimum", "minimum"),
|
| ("🔃 sort", "sort"),
|
| ("♻ unique", "unique"),
|
| ("🔁 reverse_array", "reverse_array"),
|
| ("2️⃣ even", "even"),
|
| ("1️⃣ odd", "odd"),
|
| ("🔢 count", "count"),
|
| ("♻ remove_duplicates", "remove_duplicates"),
|
| ("📊 frequency", "frequency"),
|
| ("🚫 remove_negative", "remove_negative"),
|
| ("🔍 find_index", "find_index"),
|
| ("🔗 concatenate", "concatenate"),
|
| ("🔁 repeat", "repeat"),
|
| ("⚖ equal", "equal"),
|
| ("🫧 bubble_sort", "bubble_sort"),
|
| ("🔍 linear_search", "linear_search"),
|
| ("0️⃣ zeros", "zeros"),
|
| ("⚖️ standardize", "standardize"),
|
| ("✂️ slice", "slice"),
|
| ("✅ sorted", "sorted"),
|
| ("🧩 padding", "padding"),
|
| ],
|
|
|
| "🔢 Number Functions": [
|
| ("❗ factorial", "factorial"),
|
| ("🌀 fibonacci", "fibonacci"),
|
| ("🔍 prime", "prime"),
|
| ("💪 armstrong", "armstrong")
|
| ],
|
|
|
| "🔤 String Functions": [
|
| ("🪞 palindrome", "palindrome"),
|
| ("🔄 reverse_string", "reverse_string"),
|
| ("🅰 vowels", "vowels")
|
| ],
|
|
|
| "🧮 Matrix Functions": [
|
| ("➕ matrix_addition", "matrix_addition"),
|
| ("➖ matrix_subtract", "matrix_subtract"),
|
| ("🔀 transpose", "transpose"),
|
| ("✖ matrix_multiplication", "matrix_multiplication"),
|
| ("📐 shape", "shape"),
|
| ("🧾 flatten", "flatten"),
|
| ("🔺 trace", "trace"),
|
| ("🔢 scalar_multiply", "scalar_multiply"),
|
| ("🔄 reverse_rows", "reverse_rows"),
|
| ("🔄 reshape", "reshape"),
|
| ("📋 row_sum", "row_sum"),
|
| ("📑 column_sum", "column_sum"),
|
| ],
|
|
|
| "📊 Statistics": [
|
| ("📊 mean", "mean"),
|
| ("📈 median", "median"),
|
| ("📉 mode", "mode"),
|
| ("📐 variance", "variance"),
|
| ("📏 standard_deviation", "standard_deviation"),
|
| ("➖ mean_absolute_difference", "mean_absolute_difference"),
|
| ("⚖ normalize", "normalize"),
|
| ],
|
|
|
| "🧮 Linear/Vector Algebra Functions": [
|
| ("🧲 dot_product", "dot_product"),
|
| ("➕ add_arrays", "add_arrays"),
|
| ("✖ multiply_arrays", "multiply_arrays"),
|
| ]
|
| }
|
|
|
|
|
|
|
|
|
|
|
| functions = {
|
| name: getattr(obj, name)
|
| for name in dir(obj)
|
| if callable(getattr(obj, name))
|
| and not name.startswith("__")
|
| }
|
|
|
|
|
|
|
|
|
|
|
| st.markdown("""
|
| <div style="
|
| background: linear-gradient(90deg, #00FFAA, #0066FF);
|
| padding: 25px;
|
| border-radius: 15px;
|
| text-align: center;
|
| margin-bottom: 25px;
|
| box-shadow: 0px 0px 20px rgba(0,255,170,0.5);
|
| ">
|
|
|
| <h1 style="
|
| color: white;
|
| font-size: 45px;
|
| margin: 0;
|
| ">
|
| 💻 Ranadeep Python Function Viewer
|
| </h1>
|
|
|
| <p style="
|
| color: white;
|
| font-size: 20px;
|
| margin-top: 10px;
|
| ">
|
|
|
| </p>
|
|
|
| </div>
|
| """, unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
| st.markdown("""
|
| <marquee behavior="alternate" direction="left">
|
| 🔥 Welcome to Ranadeep Python Function Viewer 🔥
|
| All Python Functions Available Here
|
| </marquee>
|
| """, unsafe_allow_html=True)
|
|
|
| st.markdown("---")
|
|
|
|
|
|
|
|
|
|
|
| st.sidebar.title("⚙ Function Categories")
|
|
|
| search = st.sidebar.text_input(
|
| "🔍 Search Function",
|
| placeholder="Type function..."
|
| )
|
|
|
|
|
|
|
|
|
|
|
| for category, funcs in categories.items():
|
|
|
| st.sidebar.markdown(f"## {category}")
|
|
|
| for display_name, actual_name in funcs:
|
|
|
| if search.strip() == "" or search.lower() in actual_name.lower():
|
|
|
| if st.sidebar.button(display_name):
|
|
|
| st.session_state.selected_function = actual_name
|
|
|
|
|
|
|
|
|
|
|
| if "selected_function" not in st.session_state:
|
|
|
| st.session_state.selected_function = "add"
|
|
|
| function_name = st.session_state.selected_function
|
|
|
|
|
|
|
|
|
|
|
| func = functions[function_name]
|
|
|
|
|
|
|
|
|
|
|
| st.subheader(f"📄 {function_name} Function")
|
|
|
|
|
|
|
|
|
|
|
| st.subheader("💻 Function Code")
|
|
|
| code = inspect.getsource(func)
|
|
|
| st.code(code, language="python")
|
|
|
|
|
|
|
|
|
|
|
| st.markdown("---")
|
| st.markdown("### 🚀 Developed by Ranadeep")
|
|
|
|
|
|
|
|
|
|
|
| st.subheader("📥 Input")
|
|
|
| try:
|
| sig = inspect.signature(func)
|
| inputs = {}
|
|
|
| for param in sig.parameters:
|
| inputs[param] = st.text_input(
|
| f"Enter {param}",
|
| key=f"{function_name}_{param}"
|
| )
|
|
|
| if st.button("▶ Run Function"):
|
|
|
| converted_inputs = []
|
|
|
| import ast
|
|
|
| for value in inputs.values():
|
|
|
| try:
|
| converted_inputs.append(ast.literal_eval(value))
|
| except:
|
| converted_inputs.append(value)
|
|
|
| result = func(*converted_inputs)
|
|
|
| st.subheader("📤 Output")
|
| st.success(result)
|
|
|
| except Exception as e:
|
| st.error(f"Error: {e}")
|
|
|
| import ast
|
| converted_inputs.append(ast.literal_eval(value))
|
|
|
| import ast
|
| for value in inputs.values():
|
| try:
|
| converted_inputs.append(
|
| ast.literal_eval(value)
|
| )
|
| except:
|
| converted_inputs.append(value)
|
|
|
| import ast
|
| for value in inputs.values():
|
| try:
|
| parsed = ast.literal_eval(value)
|
|
|
| if isinstance(parsed, tuple):
|
| parsed = list(parsed)
|
|
|
| converted_inputs.append(parsed)
|
| except:
|
| converted_inputs.append(value) |