Python Programming/Q&A

Welcome to the Python Programming questions and answers page.
Post any questions you have while learning Python. Please sign and date your entries by inserting -- ~~~~ at the end.

How to develop a GUI Python program to click on desktop at desired position ...Edit

Hello All Pythoners,

I am Raju C Padaria from India. Today whole day I read about Python programming language. I feel it very very useful in my daily office work for my users. I have been working on SAP R/3 4.6C on Windows XP since last 3 years. I need to automate some download from SAP using Python. Is it possible to open SAP screen, enter required parameters in the screen, click on an icon to download data from SAP & so on & so forth. I have gone through almost all examples / tutorials but couldn't find the answer of my question.

Best Regards,

I want a sample program on linked list

Python ProblemEdit

Given the dimensions of a rectangular grid and a sequence of robot positions and instructions, you are to write a program that determines for each sequence of robot positions and instructions the final position of the robot. A robot position consists of a grid coordinate (a pair of integers: x-coordinate followed by y-coordinate) and an orientation (N,S,E,W for north, south, east, and west). A robot instruction is a string of the letters 'L', 'R', and 'F' which represent, respectively, the instructions: • Left: the robot turns left 90 degrees and remains on the current grid point. • Right: the robot turns right 90 degrees and remains on the current grid point. • Forward: the robot moves forward one grid point in the direction of the current orientation and maintains the same orientation. The direction North corresponds to the direction from grid point (x,y) to grid point (x,y+1). Since the grid is rectangular and bounded, a robot that moves ``off an edge of the grid is lost forever. However, lost robots leave a robot ``scent that prohibits future robots from dropping off the world at the same grid point. The scent is left at the last grid position the robot occupied before disappearing over the edge. An instruction to move ``off the world from a grid point from which a robot has been previously lost is simply ignored by the current robot. INPUT SPECIFICATION The first line of input is the upper-right coordinates of the rectangular world, the lowerleft coordinates are assumed to be 0,0. The remaining input consists of a sequence of robot positions and instructions (two lines per robot). A position consists of two integers specifying the initial coordinates of the robot and an orientation (N,S,E,W), all separated by white space on one line. A robot instruction is a string of the letters 'L', 'R', and 'F' on one line. Each robot is processed sequentially, i.e., finishes executing the robot instructions before the next robot begins execution. There will be 3 robots. You may assume that all initial robot positions are within the bounds of the specified grid. The maximum value for any coordinate is 50. All instruction strings will be less than 100 characters in length. OUTPUT SPECIFICATION For each robot position/instruction in the input, the output should indicate the final grid position and orientation of the robot. If a robot falls off the edge of the grid the word ``LOST should be printed after the position and orientation. SAMPLE INPUT (from file) and OUTPUT (to file) Case 1: in.txt looks like this: 5 3 1 1 E RFRFRFRF 3 2 N FRRFLLFFRRFLL 0 3 W LLFFFLFLFL out.txt looks like this: 1 1 E 3 3 N LOST 2 3 S

Pyserial Bill AcceptorEdit

Has anyone ever tried to have python read a bill acceptor through a RS-232 serial port? If not how would one go about this? I assume using pySerial but except for the examples there isn't much information that is intuitive to me anyway. Any information would be great. Thanks.

Mike

Reinitializing Python ImportEdit

I am new to Python. I want to manipulate ready-made command line programs with scripts, and Python appears to achieve this with more control of the programs than DOS batch files.

I have written a few Python scripts to test some programs, and I have a question about reinitializing the text ~.py module when I make a change to it. After I've imported a module into Python, e.g., >>> import name.py, and I make a new change to the text file "name.py," the change will not take effect even if I again import it into Python.

How do I reinitialize the module once I've made changes to the module? I can't just import the module; the definitions remain unchanged, unless I exit Python and restart it.

Thanks, Walter Goedecke walter.goedecke@navy.mil wgoedeck@dim.com

programing in python an ATM machineEdit

i need some guidance on how to write a program in python for an ATM machine

What is my error in this function?Edit

def area (rectangle):

```   a = 0.0
for r in rectangle:
a = a * r
return a
```

rectangle = [] while True:

```   l = raw_input ("length:")
w = raw_input ("width:")
l = float (l)
w = float (w)
a = (area)
print "the area is", a
```

x%2Edit

http://www.youtube.com/watch?src_vid=QaYAOR4Jq2E&feature=iv&annotation_id=annotation_149056&v=M3g1GEkmyrw in this tutorial what does mean x%2 ? i think: i * 2% = always even number but why not 4,6 or 8? but i * 4(6,8,10,12...)% = always even number too for example: 100 * 2(4,6,8,10,12...)% = 2(4,6,8,10,12...) even numbers = {2,4,6,8,10,12...} and how pyton understanding 0(even or odd number or it is an exception?)?

Python How to ProgramEdit

function that determines whether a number is prime