[Tutor] Anyone fancy giving me some tips and an expert opinion??

2008-02-07 Thread Damian Archer
I have written what i see as a pretty decent script to resolve this
question:

Write an improved version of the Chaos program from Chapter 1 that allows a
user to input two initial
values and the number of iterations and then prints a nicely formatted table
showing how the values
change over time. For example, if the starting values were .25 and .26 with
10 iterations, the table
might look like this:
index 0.25 0.26

1 0.731250 0.750360
2 0.766441 0.730547
3 0.698135 0.767707
4 0.821896 0.695499
5 0.570894 0.825942
6 0.955399 0.560671
7 0.166187 0.960644
8 0.540418 0.147447
9 0.968629 0.490255
10 0.118509 0.974630

Although it works I am sure I could have gone about this a better way, it
probably doesn't fit all the rules of best practice either. Was wondering if
anyone would mind having a look and offering a few tips??

# chaos.py
# A program to mimic the chaos theory

def main():

print "Example of Chaos"

# User inputs numbers to compare, z is for the index counter
x = input("Enter a number between 1 and 0: ")
y = input("Enter a second number between 1 and 0: ")
z = 0

# Prints the table borders and titles
print '%10s %20s %20s' % ("Index", x, y)
print "--"
tempx = x
tempy = y

# Loops calculates 'chaotic behaviour for input numbers
for i in range(10):
tempx = 3.9 * tempx * (1 - tempx)
tempy = 3.9 * tempy * (1 - tempy)
z = z + 1
# Print chaotice results into table
print '%10s %20s %20s' % (z, tempx, tempy)

raw_input("Press any key to exit")

main()

Thanks!!! And thanks for all the help you've all supplied me with so far,
you guys certainly are an extremely valuable resource!!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Ending a script

2008-02-06 Thread Damian Archer
When I am running a script in cmd the script runs but the cmd windows closes
immediately after the script has finished.

Is there anyway I can freeze the cmd window until a user actually closers
it??
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Serious N00b question.

2008-01-29 Thread Damian Archer
Guys,

Thanks for your help on my last question, got a few projects in mind now.

I usually work on Linux(Fedora) enviroment, i have no trouble with running
scripts/programs i write. But i have now got IDLE on my Windows build.

Now when i write something in Notepad, how do i then open that so it runs in
IDLE??

Sorry for the terrible question!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Projects

2008-01-22 Thread Damian Archer
Guys and Gals,

Firstly 'Hi'. So I am new to Python have been learning it for about two
months now on and off between working and playing.

Its the first language I have tried to learn, I am taking to it quite well
and enjoying it, which is always good.

The problem I am having is finding project ideas for beginners. I know I
should be looking at things I need, but quite honestly the level I am at I
think these will be beyond me. Plus I want to master the basics I've
learnt before I get ahead of myself.

So anyone have any good project ideas, perhaps projects that people have
undertaken before??

Thanks in advance!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor