Lab 5-CHILESHE
Lab 5-CHILESHE
SIN : 22997565
LECTURER : EB
1|Page
INTRODUCTION
This assignment explores the intersection of Python and web development. We will delve into
how Python, specifically with libraries like NumPy, Matplotlib, and PyScript, can be utilized to
create dynamic and interactive web applications. Through practical examples, we will
demonstrate how to embed Python code directly into HTML pages, generate data visualizations,
and enhance user experiences.
WORKFLOW
<html>
<head>
<title>CHILESHE CHILIMA</title>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-env>
- matplotlib
</py-env>
</head>
<body>
<h1 style="text-align: center; color: white; background-color: #FA2B6D">
Chileshe Chilima </h1>
<p style="font-weight: bold;">I am a 3rd year student at Copperbelt
University, Solwezi Satellite campus, pursuing a BEng in Geomatics
Engineering.</p>
<p>I have been assigned to do a lab in Python for the web and this is
what I have done.</p>
<script>
2|Page
function isCheck(){
var num = document.getElementById('evenOdd').value;
// alert(num);
if((num%2) == 0){
document.getElementById('showMssg').innerHTML = "Wow! Number
"+num+" is an even number";
}
else{
document.getElementById('showMssg').innerHTML = "Oo No! "+num+" is
not an even number";
}
function isChecks(){
var num = document.getElementById('evenOdds').value;
// alert(num);
if((num%2) == 0){
document.getElementById('showMssgs').innerHTML = "Wow! Number
"+num+" is an even number";
}
else{
document.getElementById('showMssgs').innerHTML = "Oo No! "+num+" is
not an even number";
}
</script>
<div id="plot"></div>
<py-script output="plot">
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
3|Page
ax.plot(t, s)
fig
</py-script>
</body>
</html>
RESULT OBTAINED
4|Page
CONCLUSION
This exploration has demonstrated the power of Python in web development, particularly when
combined with libraries like NumPy, Matplotlib, and PyScript. By seamlessly integrating Python
code into HTML, we've seen how to create interactive visualizations and dynamic web
applications. This approach opens up new possibilities for data scientists, educators, and
developers alike.
PyScript, as a relatively new framework, shows immense promise. Its ability to bridge the gap
between Python and the web is a game-changer. With continued development and community
support, PyScript has the potential to revolutionize how we build web applications, making data-
driven insights more accessible and engaging. As the technology matures, we can anticipate even
more sophisticated and performant applications emerging from this powerful combination.
5|Page