View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

Media Computation Python FAQ

How do I prompt the user for input?

Here is an example program:

import sys
import math
import SimpleInput
import SimpleOutput

def cal_volume():
  
  radius = 0.0
  height = 0.0
  volume = 0.0
  area   = 0.0
  pi     = 3.1416
 
  radius = requestNumber("Enter the radius of the cylinder")
  height = requestNumber("Enter the height of the cylinder")
  
  area = pi *radius* radius
  volume = area  * height
  
  showInformation("The volume of the cylinder is %.02f " % volume)

cal_volume()



Why does writePictureTo(pic,file) write a zero byte file or fail?

It has to do with write permissions in directories. Windows sometimes locks directories
as Read-Only that get dragged in from the CD.

I've found that writePictureTo(pic,"C:/mypicture.jpg") always works on
my computer. Then, I hunt around to unlock the directory that it
refused to work on.

If you copy a directory from the CD you have to change the
permissions on the directory to let you write to it. Do a right click on
the directory that is giving you trouble, then click on Properties, and
then uncheck the Read Only box.

Links to this Page