Results 1 to 5 of 5

Thread: Anyone here know Python?

  1. #1

    Default Anyone here know Python?

    I need someone I can ask likely idiotic questions to.

  2. #2

    Default



    Quote Originally Posted by AEsahaettr View Post
    I need someone I can ask likely idiotic questions to.
    I've been using python almost exclusively for the last several years, so I can probably answer your questions.

  3. #3

    Default

    Awesome, thanks.

    I'm working on teaching myself as part of an independent study and I've been using codecademy. I like codecademy and I'm really blazing through the lessons- I've used C++ and SAS in the past so coding isn't new to me, just understanding the syntax is. The problem is that when I take working code from codecademy and put it into Python to try to run it and see what happens, it doesn't work. Ever. Literally every piece of code that codecademy is teaching me is being spit out by Python for syntax errors. For example:

    a = 3.14
    print a


    I get a syntax error for a problem with the a following print. On this one:

    str_1 = "diapers"
    str_2 = "comfy"
    print "I like to wear %s, they are very %s." % (str_1, str_2)


    I get a syntax error with the quotation ending the string in the print command line.

    Any idea where the problem is? Does my syntax look right? Is codecademy just giving me simplified lessons that aren't supposed to work on their own in Python? Any idea what's going on?

  4. #4

    Default

    I think the problem is that you're using python3, while the lessons are using python2. The languages are largely identical, with a few important differences - one of which is that print is a function in python3 instead of a statement as in python2. Here's what I got with your examples:

    [email protected]% python
    Python 2.7.6 (default, Mar 22 2014, 15:40:47)
    [GCC 4.8.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> a = 3.14
    >>> print a
    3.14
    >>> exit()
    [email protected]% python3
    Python 3.3.5 (default, Mar 22 2014, 13:24:53)
    [GCC 4.8.2] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> a = 3.14
    >>> print a
    File "<stdin>", line 1
    print a
    ^
    SyntaxError: invalid syntax
    >>> print(a)
    3.14
    >>> exit()


    What OS are you using? That was on debian sid. python 2 is the default almost everywhere still (except arch linux).

  5. #5

    Default



    Quote Originally Posted by AEsahaettr View Post
    Awesome, thanks.

    I'm working on teaching myself as part of an independent study and I've been using codecademy. I like codecademy and I'm really blazing through the lessons- I've used C++ and SAS in the past so coding isn't new to me, just understanding the syntax is. The problem is that when I take working code from codecademy and put it into Python to try to run it and see what happens, it doesn't work. Ever. Literally every piece of code that codecademy is teaching me is being spit out by Python for syntax errors. For example:

    a = 3.14
    print a


    I get a syntax error for a problem with the a following print. On this one:

    str_1 = "diapers"
    str_2 = "comfy"
    print "I like to wear %s, they are very %s." % (str_1, str_2)


    I get a syntax error with the quotation ending the string in the print command line.

    Any idea where the problem is? Does my syntax look right? Is codecademy just giving me simplified lessons that aren't supposed to work on their own in Python? Any idea what's going on?
    Instead of the print statement of python 2.X:
    print "hello world"

    Python 3 uses a print method:
    print ("hello world")

    The newer version of python prints the same way, just with different syntax that is much more similar to other programming languages.

Similar Threads

  1. Anyone want to learn python? Or help me learn?
    By ShippoFox in forum Computers & Gaming
    Replies: 43
    Last Post: 01-Feb-2009, 11:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
ADISC.org - the Adult Baby / Diaper Lover / Incontinence Support Community.
ADISC.org is designed to be viewed in Firefox, with a resolution of at least 1280 x 1024.