Howdy, Stranger!

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

Top Posters

Who's Online (1)

Powered by Vanilla. Made with Bootstrap.
Python, The basics.
  • Flashlight
    Posts: 173
    So here are some basics that should get you started.

    1. print. print can be used in 2 ways.
    print \"hello\"


    and

    a= 123456789
    print a

    Note that "a" is not in quotations as it is a variable.

    2. raw_input("insert text here "). raw_input allows the user to input into the code a use would be.

    a=raw_input(\"Enter some text. \")
    print a

    this code would print whatever the user inputed.

    3.in(raw_input("insert number here")). this is the same as raw_input however instead of text it is specifically for numbers an example would be.

    a=int(raw_input(\" Enter a number \"))
    b=int(raw_input(\"Enter another number .\"))
    print a+b
    this allows the coder to allow the user to do something like multiply divide add or subtract a number they input.


    4. if, else and elif. if, else and elif are conditions. they are used in the following way.

    b = \"loasdaoaflksfljhsdf\"
    if b==b:
    print \"b is equal to b\"
    else:
    print \"b is not equal to be\"

    or it can be used with elif statements


    a = raw_input(\" Enter Some Text: \")
    b = len(a)
    if b==\"1\":
    print \"b is equal to 1\"
    elif b==2:
    print \"b is equal to 2\"
    elif b==3:
    print \"b is equal to 3\"
    else:
    print \"b is greater than 3\"


    5. len. len will tell you the length of the string that is in the brackets after it with it be (a) or ("1235665674576").
    it would be used as.
    a = 1234436546786785694567234623452345\"
    b = len(a)
    print b


    6. quit. this will exit the script. it can be used as.

    quit

    or
    quit()



    I hope this has helped or gave some people something to start to learn python off.
  • chroniccommand
    Posts: 1,389
    Moved to Python section.
    Eh. It's not very informative nor does it explain much. Decent though. And you may want to specify the Python version. Quit() doesn't always work, it's better to include the sys library and do sys.exit()
  • Pretty good, I guess this could help and answer a few questions for new comers to python.
  • Xin
    Posts: 3,251
    Should make it more detailed next time bro but good job otherwise :)
    Xin
  • Bursihido
    Posts: 406
    very nice tutorial thanks mate :)
  • nice tutorial
  • undead
    Posts: 822
    Nice tutorial. I'm learning python ;)
  • pusoy23
    Posts: 19
    Nice Such a Great Tutorial hope you post more tutorial about phyton..
  • C10Wn
    Posts: 16
    said:


    So here are some basics that should get you started.

    1. print. print can be used in 2 ways.

    print \"hello\"


    and

    a= 123456789
    print a

    Note that "a" is not in quotations as it is a variable.

    2. raw_input("insert text here "). raw_input allows the user to input into the code a use would be.

    a=raw_input(\"Enter some text. \")
    print a

    this code would print whatever the user inputed.

    3.in(raw_input("insert number here")). this is the same as raw_input however instead of text it is specifically for numbers an example would be.

    a=int(raw_input(\" Enter a number \"))
    b=int(raw_input(\"Enter another number .\"))
    print a+b
    this allows the coder to allow the user to do something like multiply divide add or subtract a number they input.


    4. if, else and elif. if, else and elif are conditions. they are used in the following way.

    b = \"loasdaoaflksfljhsdf\"
    if b==b:
    print \"b is equal to b\"
    else:
    print \"b is not equal to be\"

    or it can be used with elif statements


    a = raw_input(\" Enter Some Text: \")
    b = len(a)
    if b==\"1\":
    print \"b is equal to 1\"
    elif b==2:
    print \"b is equal to 2\"
    elif b==3:
    print \"b is equal to 3\"
    else:
    print \"b is greater than 3\"


    5. len. len will tell you the length of the string that is in the brackets after it with it be (a) or ("1235665674576").
    it would be used as.
    a = 1234436546786785694567234623452345\"
    b = len(a)
    print b


    6. quit. this will exit the script. it can be used as.

    quit

    or
    quit()



    I hope this has helped or gave some people something to start to learn python off.

    Thanks for these, this will help me get started!