[Tutor] University student struggling!

Kent Johnson kent37 at tds.net
Tue Jul 14 17:08:11 CEST 2009


Forwarding to the list with my reply. Please use Reply All to respond
to the list.

On Tue, Jul 14, 2009 at 11:01 AM, Andrea Semenik<ams28 at sfu.ca> wrote:
> Thank you so much for your quick response. This is really the first assignment of its kind with this course, there was no warm up to get us familiar with python. the only thing we had to do was program a page that showed the current time. But that was easy because all we had to do was use time.asctime(). For this assignment this is what I have done
>
> import cgi
> form = cgi.FieldStorage()
>
> # print HTTP/HTML header stuff
> print "Content-type: text/html"
> print
> print"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
> <title>Colour Blend</title>
> <style type="text/css">
> #blend {
>  width: 10em;
>  padding: 0;
>  border: 1px solid black;
>  margin-left: 3em;
> }
> .colourblock {
>  width: 10em;
>  height: 1em;
> }
> </style>
> </head>
> <body>
> """
> print
>
> print "<p>", form["red1"].value, "</p>"
> print "<p>", form["green1"].value, "</p>"
> print "<p>", form["blue1"].value, "</p>"
> print "<p>", form["red2"].value, "</p>"
> print "<p>", form["green2"].value, "</p>"
> print "<p>", form["blue2"].value, "</p>"
> print "<p>", form["steps"].value, "</p>"
> print
>
>
> I am not sure if that is even right. My page is now showing the values that were input by the user on the previous page. But I feel like that could be the start to something. like there is another step that will then connect these values into making a color box. But I just don't know, I have been trying to read as much as I can about python, but I am overwhelmed.

This is a good start. Can you modify this program to show the actual
colors in a <div>, rather than just echoing the numbers?

Kent


More information about the Tutor mailing list