Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

calculating expressions with sqrt signs

import re
import math

def replace(expression):
    # Replace the sqrt symbol with the sqrt funcion from the math module
    return eval(re.sub(r'√(d+)', r'math.sqrt(1)', expression))
   
print(replace("√100"))                  # 10.0
print(replace("√25 + √36"))             # 11.0
print(replace("2+346-677*78/6+√567+7")) # -8422.188238200419
Comment

calculating expressions with sqrt signs

import re
import math

def replace(expression):
    # Replace the sqrt symbol with the sqrt funcion from the math module
    return eval(re.sub(r'√(d+)', r'math.sqrt(1)', expression))
   
print(replace("√100"))                  # 10.0
print(replace("√25 + √36"))             # 11.0
print(replace("2+346-677*78/6+√567+7")) # -8422.188238200419
Comment

PREVIOUS NEXT
Code Example
Python :: mlpclassifier check weights 
Python :: python set xticks to int not float 
Python :: import knn in python jupyter 
Python :: if string contains loop pandas 
Python :: how to reassign a key py 
Python :: python iterate through lists 
Python :: Using iterable unpacking operator * With unique values 
Python :: Matrix Transpose using Nested List Comprehension 
Python :: Using CGI with Python and HTML forms 
Python :: how can i add a list in python 
Python :: Django forms I cannot save picture file 
Python :: python networkmanager tutorial 
Python :: animal quiz game in python 
Python :: cv2 put font on center 
Python :: pie chart add outline python 
Python :: when excel is loaded into python, numeric datatype changes to float 
Python :: how to write a program that interacts with the terminal 
Python :: pycharm shortcut to create methos 
Python :: removing an item from a list and adding it to another list python 
Python :: Tape Equilibrium 
Python :: Reading from a file way03 
Python :: python type conversion 
Python :: python @property decorator 
Python :: HTML automation not working on vscode with folder named templates on django 
Python :: winwin 
Python :: pairwiseclip arcpy 
Python :: pytube.exceptions.RegexMatchError: __init__: could not find match for ^w+W 
Python :: colab show all value 
Python :: how to truncate a float in jinja template 
Python :: how to count discord chat messages with python 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =