473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Build Applet

176 100+
Hello guys. I recently found a thing on my computer called Build Applet. I did a bit of research on it and found out how to use it. I dragged the code of a simple program onto it and it generated a file called Average which is the name of the source file except the source file has a .py extension. So anyways I was wondering how you can put the Average file onto a webpage. This is a bit of an HTML question but I am using a python program. Thanks :-).

If you want to see the code of the simple Averager it is this:
Expand|Select|Wrap|Line Numbers
  1. #Number Averaging Program
  2. #By Kid Programmer
  3. from time import sleep                          #Fetch The Function Sleep
  4. #Declare Vairiables
  5. number1 = 0.0
  6. number2 = 0.0
  7. number3 = 0.0
  8. average = 0.0
  9. print "This program will average 3 numbers."         #Explain The Program
  10. #Prompt The User For The Numbers
  11. sleep(.5)                                       #Delay The Program To Make It Cleaner
  12. number1 = input("Please enter the first number: ")#Promt the user for the first number
  13. sleep(.5)                                       #Delay The Program To Make It Cleaner
  14. number2 = input("Please enter the second number: ")#Prompt the user for the second number
  15. sleep(.5)                                       #Delay The Program To Make It Cleaner
  16. number3 = input("Please enter the third number: ")#Prompt the user for the third number
  17. sleep(.5)                                       #Delay The Program To Make It Cleaner
  18. average = (number1 + number2 + number3) / 3#Calculate the average
  19. #Print Out The Average
  20. print "The average of the numbers is", average, "."
  21. sleep(.5)                                       #Delay The Program To Make It Cleaner
  22. print "Would you like to average more numbers?" #Ask The User If They Want To Average More Numbers
  23. sleep(.5)                                       #Delay The Program To Make It Cleaner
  24. continue_averaging = input("1 = Yes 2 = No: ")  
  25. sleep(.5)                                       #Delay The Program To Make It Cleaner
  26. if continue_averaging == 1:                     
  27.     while continue_averaging == 1:
  28.         sleep(.5)                                       #Delay The Program To Make It Cleaner
  29.         number1 = input("Please enter the first number: ")
  30.         sleep(.5)                                       #Delay The Program To Make It Cleaner
  31.         number2 = input("Please enter the second number: ")
  32.         sleep(.5)                                       #Delay The Program To Make It Cleaner
  33.         number3 = input("Please enter the third number: ")
  34.         sleep(.5)                                       #Delay The Program To Make It Cleaner
  35.         average = (number1 + number2 + number3) / 3
  36. #Print Out The Average
  37.         print "The average of the numbers is", average, "."
  38.         sleep(.5)                                       #Delay The Program To Make It Cleaner
  39.         print "Would you like to average more numbers?" #Ask The User If They Want To Average More Numbers
  40.         sleep(.5)                                       #Delay The Program To Make It Cleaner
  41.         continue_averaging = input("1 = Yes 2 = No: ")
  42.         sleep(.5)                                       #Delay The Program To Make It Cleaner    
  43. else:
  44.     print "Program finished."
  45.  
  46.  
  47.  
May 3 '08 #1
1 6476
Smygis
126 100+
Oh... Thats some not so nice code there.

Cleaned it up a bit for fun:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/env python
  2. # coding: UTF-8
  3.  
  4. import time
  5.  
  6. def sleep():
  7.     time.sleep(.5)
  8.  
  9. print "This program will ask for three numbers then calculate the average."
  10.  
  11. while True:
  12.     numbers = []
  13.  
  14.     for num in ["first", "second", "third"]:
  15.         sleep()
  16.         numbers.append(float(raw_input("Please enter the %s number: " % num)))
  17.  
  18.     sleep()
  19.     average = (sum(numbers)) / 3.
  20.     print "The average of the numbers is %.2f." % average
  21.  
  22.     sleep()
  23.     if not "y" == raw_input \
  24.               ("Would you like to average more numbers (Yes/No)? ")[:1].lower():
  25.         break
  26.  
  27. print "Program finished."
  28.  
Now what exactly do you mean by "how you can put the Average file onto a webpage". As far as i can tell. Thats what you have done right now.

You want to display the code?
Use <pre> tags.
You want to run the program in a webpage. Taking input from a user and then display the result?
That one takes some explaning.
May 3 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: nathanlaan | last post by:
This is the stupidest thing I have ever seen. Java 1.2, 1.3, and 1.4.1, and 1.4.2 all define the Applet.getDocumentBase() method differently! How am I supposed to get the directory of the document...
0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
1
by: Charlie Kim | last post by:
Here is gnome applet source of mine. -------------------------------------------------- #!/usr/bin/env python import pydic import gtk import gnome.applet
1
by: Tormod Omholt-Jensen | last post by:
Ď need to dynamically insert an applet into a document. In IE 6.0 my code works fine, but there seems to be problems in Opera 7. The page looks like there is allocated space for an applet. ...
8
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some...
3
by: DaveF | last post by:
I need to put it in a specific place. Here is the old code switch(CAMERA_TYPE_ID) { case "0": case "7": // this is an image
0
by: ankur | last post by:
WHEN I RUN THIS WEB APPLICATION ON Tomcat5.5.9 SERVER MY HttpChatApplet sccessfully Loaded from ChatDispatch but running on some another PC HttpChatApplet not loaded my Coad ...
4
by: tudyfruity18 | last post by:
I'm suppose to write an applet that contains two buttons Investment calculator and Loan Calculator. When the Investment Calculator button is clicked, a frame appears in a new window for calculating...
1
by: sheephead86 | last post by:
Hi, I'm pretty new to java, and I have a small problem involving drawing a rectangle on a java applet.Firstly this is not a plea for someone to help me with this peice of work, I just need pointing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.