0% found this document useful (0 votes)
11 views3 pages

Py 12

The document describes a Django web application that calculates the area and circumference of a circle based on the radius input by the user. The views.py file contains the logic to calculate area and circumference using pi and radius. It returns the results in a message to the home.html template. The template contains the web form to input radius and displays the results message.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Py 12

The document describes a Django web application that calculates the area and circumference of a circle based on the radius input by the user. The views.py file contains the logic to calculate area and circumference using pi and radius. It returns the results in a message to the home.html template. The template contains the web form to input radius and displays the results message.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

************************************B444**********************************

views.py
from django.shortcuts import render
def home(request):
if request.GET.get("radius"):
radius = float(request.GET.get("radius"))
pi = 3.14
area = pi * radius * radius
circum = 2 * pi * radius
msg = "Area = " + str(area) + " | Circumference = " + str(circum) # Added a space and "|"
separator
return render(request, "home.html", {"msg": msg})
else:
return render(request, "home.html")
HTML Page :
<!DOCTYPE html>
<html>
<head>
<title>Area & Circumference Finder</title>
<style>
body {
background-color: cyan;
font-family: Times New Roman;
}
h1 {
background-color: black;
color: white;
width: 50%;
border-radius: 30px;
text-align: center;
padding: 10px;
margin: 20px auto;
}
form {
text-align: center;
margin: 0 auto;
}
input[type="number"] {
font-size: 20px;
padding: 5px;
margin: 5px;
border-radius: 5px;
border: 1px solid #ccc;
}
input[type="submit"] {
font-size: 20px;
padding: 10px 20px;
margin: 10px;
border-radius: 5px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
.result {
text-align: center;
margin-top: 20px;
font-size: 24px;
color: blue;
}
</style>
</head>
<body>
<h1>Area & Circumference Finder</h1>
<form>
<input type="number" step="any" name="radius" placeholder="Enter radius" required
min="0.1" />
<br><br>
<input type="submit" value="Find Area and Circumference" />
</form>
<div class="result">{{ msg }}</div>
</body>
</html>
************************************B444**********************************

Output:

You might also like