Skip to content
Snippets Groups Projects
Commit d04e3f53 authored by RENAUX Anna's avatar RENAUX Anna
Browse files

Upload New File

parent e819fbb7
No related branches found
No related tags found
No related merge requests found
eval.py 0 → 100644
import os
import math
def volume(r):
if r <= 0:
return "The ray you have entered must be different from 0 and positive!"
return (4*math.pi*r**3)/3
def read_result(fileName="result.txt"):
script_dir = os.path.dirname(os.path.abspath(__file__))
filePath = os.path.join(script_dir, fileName)
with open(filePath, 'r') as file:
content = file.read()
return float(content)
def save_result(volume, fileName="result.txt"):
script_dir = os.path.dirname(os.path.abspath(__file__))
filePath = os.path.join(script_dir, fileName)
with open(filePath, 'w') as file:
file.write(str(volume))
def htmlPage(result):
htmlContent = f"""
<!DOCTYPE html>
<html>
<head>
<title>Sphere volume</title>
</head>
<body>
<h1>Volume : {result}</h1>
</body>
</html>
"""
with open("resultat.html", 'w') as htmlFile:
htmlFile.write(htmlContent)
def main():
r = float(input("Ray: "))
resultat = volume(r)
print("Volume: ", resultat)
# Saving the result in a txt file
save_result(resultat)
# Creating the HTML page
htmlPage(resultat)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment