Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Python program closes, help!

KripposoftKripposoft Posts: 1Member
Hi, i'm new to programming and im currently learning python cause some people has tipped me that it's a good beginner language. So i printed this tutorial but when im gonna run the program that im doing it closes before i cant see anything! here is an example of a program that i was assigned to do to see what i've learned from the chapter:




print "christoffer soderstrom"
print "1990 11 15"
print "2+2 is" 2+2
print "2*2 is" 2*2
print "2/2 is" 2/2
print "2-2 is" 2-2
print "2**2 is" 2**2
print "(32+12)*(3**8) is" (32+12)*(3**8)

Comments

  • gallinulagallinula Posts: 1Member
    : Hi, i'm new to programming and im currently learning python cause some people has tipped me that it's a good beginner language. So i printed this tutorial but when im gonna run the program that im doing it closes before i cant see anything! here is an example of a program that i was assigned to do to see what i've learned from the chapter:
    :
    :
    :
    :
    : print "christoffer soderstrom"
    : print "1990 11 15"
    : print "2+2 is" 2+2
    : print "2*2 is" 2*2
    : print "2/2 is" 2/2
    : print "2-2 is" 2-2
    : print "2**2 is" 2**2
    : print "(32+12)*(3**8) is" (32+12)*(3**8)
    :

    You could try adding [b]raw_input()[/b] as the last line of you script. This will effectively pause the program until the enter/return key is pressed.
  • MastikMastik Posts: 19Member
    : : Hi, i'm new to programming and im currently learning python cause some people has tipped me that it's a good beginner language. So i printed this tutorial but when im gonna run the program that im doing it closes before i cant see anything! here is an example of a program that i was assigned to do to see what i've learned from the chapter:
    : :
    : :
    : :
    : :
    : : print "christoffer soderstrom"
    : : print "1990 11 15"
    : : print "2+2 is" 2+2
    : : print "2*2 is" 2*2
    : : print "2/2 is" 2/2
    : : print "2-2 is" 2-2
    : : print "2**2 is" 2**2
    : : print "(32+12)*(3**8) is" (32+12)*(3**8)
    : :
    :
    : You could try adding [b]raw_input()[/b] as the last line of you script. This will effectively pause the program until the enter/return key is pressed.
    :
    you can do that or have the command line widown running. Using your example what I might do is something like. create a python file such as print_example.py
    and in the file I would put.
    #file name:print_example.py <- This line is a comment and not needed.
    print "christoffer soderstrom"
    print "1990 11 15"
    print "2+2 is" + str(2+2)
    print "2*2 is" + str(2*2)
    print "2/2 is" + str(2/2)
    print "2-2 is" + str(2-2)
    print "2**2 is" + str(2**2)
    print "(32+12)*(3**8) is" + str((32+12)*(3**8))

    Then at the command line. Example windows command line type:
    python print_example.py
    this will output the prunt statements to the command line screen. This also assumes you have the python directory included in your system path, and are located in the directory with your python file. If not you might have to manually type it in etc... example. c:pythonpython c:codeprint_example.py
    That example assumes you haven't set the path and are not in the directory that contains the python script. Undera Unix/Linux enviroment you will have to make the proper changes for the pathing in the command.

    Jeff
Sign In or Register to comment.