#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    Exclamation Newb - Installed python, no idle !


    Hi everyone. I am pretty much a complete beginner to python and I did a small bit on my mac.

    I just got a pc with windows 8 however and once I have installed python 3.3 there is no idle! Any help would be much appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    39
    Rep Power
    3

    Manually launching IDLE


    I've not yet taken the leap to Windows 8 but it may just be the new start screen that is cause the confusion.

    Check if you launch Python from a command line and then launch IDLE from there? Open up a command prompt and enter

    Code:
    cd c:\python33
    python
    After python starts, you will see the prompt change to >>>, enter the following

    Code:
    import idlelib.idle
    After a short delay this should start IDLE if all the components are installed correctly.
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    You might need to install idle separately. I'm pretty sure idle and python are distributed as different packages on my linux distribution. Why would you want idle?
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    Smile


    thanks quack, got it now
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0
    Originally Posted by b49P23TIvg
    You might need to install idle separately. I'm pretty sure idle and python are distributed as different packages on my linux distribution. Why would you want idle?
    its good for testing out your code. isn't that whats it is for?


    I also have a question regarding some code I've just done:

    (wont let me paste url to code???)



    Whether I type in force/mass/acceleration the program ends up printing just the force

    Also if I want it to print like for example -

    print("Force is", (mass*accel) + "N")

    i get a syntax error. i am wanting the N straight after the number if you get what i mean?


    Hope I've been clear enough.. thanks in advance.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    2
    IDLE is just a fairly lame IDE. Not the evil incarnate that some make it out to be, but still bad. You could give pyscripter a try. It has occasionally instability issues, but it is miles ahead of IDLE and it is very friendly for computers with multiple python versions installed.

    As for your code, there is a code tag button in the toolbar. This will preserve your code indentation and just all around make it more readable.

    -Mek
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0
    Code:
    # fma calc 1.0 
    
    print("\t\t\t~Welcome to the f=ma calc~") 
    
    force = int(input("\n\nEnter the force ")) 
    
    mass = int(input("\nEnter the mass ")) 
    
    accel = int(input("\nEnter the acceleration ")) 
    
    
    
    answer = input("\n\nWould you like to know the force,mass or acceleration? ") 
    
    
    if answer == "force" or "f": 
       print("\nForce is", (mass * accel), "Newtons") 
    
    elif answer == "mass" or "m": 
       print("\nMass is", (force/accel), "Kilograms") 
    
    elif answer == "acceleration" or "a" or "accel": 
       print("\nAcceleration is", (force/mass), "ms^-2") 
    
    else: 
       print("Invalid input!") 
    
    
    
    input("\n\n\n\t\t\tPress the Enter key to exit...")
    it only gives out values for the force now... SO confused
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    2
    Your conditionals are wrong. They always return True.

    This:
    Code:
    if answer == "force" or "f":
    is not doing what you think it should. It is first evaluating bool(answer == "force") then it is evaluating bool("f") which is always true. You want
    Code:
    if answer == "force" or answer == "f":
    or better yet:
    Code:
    if answer in ("force","f"):
    -Mek
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0
    Brilliant - thanks very much.

    If I could ask one last question it would be how to insert the units straight after the calculated number. I can only have a space after them.

    if I try something like:

    Code:
    print("Force is", m*a + "Newtons")
    I get a syntax error.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    2
    Well you could do this:
    Code:
    print("Force is "+str(m*a)+" Newtons")
    or this:
    Code:
    print("Force is",m*a,"Newtons")
    But I would much rather see this:
    Code:
    print("Force is {} Newtons".format(m*a))
    -Mek
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0
    if I do this -

    Code:
    print("force is",m*a,"Newtons")
    there is still a space between the number and newtons
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    2
    Oh? You want no space?
    python Code:
    print("Force is "+str(m*a)+"Newtons")
    print("Force is ",m*a,"Newtons",sep="")
    print("Force is {}Newtons".format(m*a))
    Code:
    Force is 156Newtons
    Force is 156Newtons
    Force is 156Newtons
    -Mek
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0
    sorry wasn't meaning to be rude, was just trying to use the one that made the most sense to me.
  26. #14
  27. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    Yes yes yes! Do run the interpreter often. Do test your code. Use idle if you can't find something better.

    A:> python myprogram.py

    followed by editing with F1 through F6 (or was it F8?) might be better than idle.

    I use emacs. python mode is great for editing python code, and I test code in a shell buffer.


    print("Force is", m*a + "Newtons")
    Is probably a type error. You'd have to work hard to make it a syntax error. This is important! The message tells you adding numbers to strings won't work.

    # number and unit are adjacent
    print("Force is",str(m*a)+'N')

    and following Mekire's preference (mine also)

    print("Force is {}{}".format(m*a, dimensions['Force']))
    [code]Code tags[/code] are essential for python code and Makefiles!
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    2
    No worries. There is an actual reason for favoring one over the other however. String concatenation is a very slow process compared to string formatting. This won't be noticeable to you when printing single lines, but if you say, had to generate 100,000 lines and write them to a file, you would notice.

    -Mek

IMN logo majestic logo threadwatch logo seochat tools logo