Re: Moving away from BGT and learning python
Another term for it is namespace, any variables declared in a function stay in a function, unless explicitly returned to the caller to prevent conflicts with other variables outside the given space. Other than using globals, what you can also do
Re: Moving away from BGT and learning python
In Python, when you run the "my_fun" function, the variables are createdinside the function.When the function returns or when it ends, Python removes thevariables that are inside the function and restores thevariables that are declar
Re: Moving away from BGT and learning python
In Python, when you run the "my_fun" function, the variables are createdinside the function.When the function returns or when it ends, Python removes thevariables that are inside the function and restores thevariables that are declar
Re: Moving away from BGT and learning python
so, consider the following code: Note: indentation is a greater than sign:def my_fun(a):>a = a + 1>x = a>print(a)>print(x)x = 3my_fun(x)So I now have a question. If you run this, you will be printed a value of 4 4. Now, here's
Re: Moving away from BGT and learning python
or you can run it from the CMD open the command prompt in the path in which your file is, and run python filename.pypost 42:This may not work, but you can try thisimport turtleI'll use the greater sighn for indentationwn = turtle.screenwh
Re: Moving away from BGT and learning python
No. Anywhere will do.
URL: http://forum.audiogames.net/viewtopic.php?pid=353967#p353967
___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin
Re: Moving away from BGT and learning python
Does the file have to be in a certain location?
URL: http://forum.audiogames.net/viewtopic.php?pid=353960#p353960
___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin
Re: Moving away from BGT and learning python
From the Python interpreter, you import it. If the file is HelloWorld.py, you would type>import HelloWorldAnd that would do it. I'm not sure that there's an easy way to repeat this without restarting the interpreter, though, if you
Re: Moving away from BGT and learning python
Assuming your using IDLE that comes with python, the default configuration opens the python shell interpreter. If you open the File menu and select New File it will create a script window where you can write, save, load, and run scripts more
Re: Moving away from BGT and learning python
This might be a bit silly, but how do you run a file from an interpreter? Do you just paste in the file path?
URL: http://forum.audiogames.net/viewtopic.php?pid=353933#p353933
___
Audiogames
Re: Moving away from BGT and learning python
Try saving it to a file, and run that. If the results are the same, something odd is happening (maybe spaces are showing up as the wrong character or something like that?). If it works from a file, then the interpreter is having trouble with
Re: Moving away from BGT and learning python
I am using a book called how to think like a computer scientist found at the following linkhttp://openbookproject.net/thinkcs/python/english3e/If you go to chapter 3, you'll see that the book suggests you to enhance the turtle progr
Re: Moving away from BGT and learning python
alright: more problems. Yea! Who loves problems?When I pasted in the following, the python prompt returned me a big fat nothing.I will post the code below, using > again to represent a single space.>user_input = input("enter som
Re: Moving away from BGT and learning python
alright: more problems. Yea! Who loves problems?When I pasted in the following, the python prompt returned me a big fat nothing.I will post the code below, using > again to represent a single space.>user_input = input("enter som
Re: Moving away from BGT and learning python
alright: more problems. Yea! Who loves problems?so when I paste in the script it says invalid indentation on line that says print("hello"). I will post the code below, using > again to represent a single space.>user_inpu
Re: Moving away from BGT and learning python
you are missing the colons after the condition iftry putting this>user_input = input("enter something")>if user_input == "hi":>>print("hello")
URL: http://forum.audio
Re: Moving away from BGT and learning python
so this is what i'm trying to paste into my python prompt. I think if someone can point out what am I doing wrong it would clear it up for me: (Note, I'll use a > symbol to represent a single space as AG forum doesn't like py
Re: Moving away from BGT and learning python
so this is what i'm trying to paste into my python prompt. I think if someone can point out what am I doing wrong it would clear it up for me: user_input = input("enter something") if user_input == "hi" print(&quo
Re: Moving away from BGT and learning python
for example you do thisthink this is the interpreter>>> input = raw_input("enter something")>>> if input == 'hi':... print "hello"... this means after you write the code you'll have to press
Re: Moving away from BGT and learning python
You need to press enter so that Python knows you're done with the indented part.
URL: http://forum.audiogames.net/viewtopic.php?pid=353683#p353683
___
Audiogames-reflector mailing list
Audio
Re: Moving away from BGT and learning python
I'm not sure I understand? When do I paste in a blank line? If you're talking about me having code after the if statement, yes, I do.
URL: http://forum.audiogames.net/viewtopic.php?pid=3536
Re: Moving away from BGT and learning python
Another way to do it would be to save your script in notepad or similar text editor and run it from a command prompt, as python files are just plain text files with a renamed extension. For example: "python yourscript.txt", thoug
Re: Moving away from BGT and learning python
Another way to do it would be to save your script in notepad or similar text editor with a *.py extension and run it from a command prompt, as python files are just text files with a renamed extension. For example: "python yourscript.py&q
Re: Moving away from BGT and learning python
When you start something like an if, while, class, or function, Python expects an indented block to follow. The editor therefore waits until you enter an unindented line, or leave a blank line, before it tries to execute the code.If you
Re: Moving away from BGT and learning python
so now I'm getting into if statements, and just pasting the contense of the file doesn't work. I want to get input from the user then use if statements to print out different messages depending on what was entered, however, when I pas
Re: Moving away from BGT and learning python
I usually just save to a file with notepad, then run it in python by importing . IIRC, this doesn't work so well if you want to test changes, since I don't think python will update the module if you try to import it again, unless it
Re: Moving away from BGT and learning python
you can do by pressing alt plus space, edit, paste
URL: http://forum.audiogames.net/viewtopic.php?pid=353658#p353658
___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin
Re: Moving away from BGT and learning python
I have a slight issue. when ever trying to type a script in a notepad and pasting it into the python the ctrl v doesn't work. anyway I can paste?
URL: http://forum.audiogames.net/viewtopic.php?pid=353650#p3
Re: Moving away from BGT and learning python
Let me add something:I personally prefere to enclose strings in quotes, unless I have the following situation, for example, if I wanna have a message box that displays the user to click a button. I want the name of that button to be quoted, so I
Re: Moving away from BGT and learning python
You basically use triple quotes or triple ticks when you want to write multiline strings. This does not mean that string needs to be necessarily multiline, but writing single-line strings in tripple quotes makes no sense, although it's n
Re: Moving away from BGT and learning python
so one of my first many questions to come.when creating strings, why cant I just use tripple quotes or ticks all the time? is there a disadvantige in doing so?
URL: http://forum.audiogames.net/viewtopic.php?pid=353618#p353618
Re: Moving away from BGT and learning python
True. What makes .NET so nice is that you can mix managed and unmanaged code. Also, about pointers, pointers in C++ are not as scary as some people make them out to be. In fact, they're very easy to work with. You usually never have to do m
Re: Moving away from BGT and learning python
There still are pointers in c++. While it is encouraged to pass things as reference or const reference, pointers are still okay to use and perfectly acceptable in the language.
URL: http://forum.audiogames.net/viewtopic.php?pid=353106#p353106
Re: Moving away from BGT and learning python
Personally I'm very found of C# and the whole .NET environment. The language has the same learning curve as Java, though I think the ecosystem in .NET is easier to get around.With this language you are able to use lambdas and funct
Re: Moving away from BGT and learning python
Personally I'm very found of C# and the whole .NET environment. The language has the same learning curve as Java, though I think the ecosystem in .NET is easier to get around.With this language you are able to use lambdas and funct
Re: Moving away from BGT and learning python
Personally I'm very found of C# and the whole .NET environment. The language has the same learning curve as Java, though I think the ecosystem in .NET is easier to get around.With this language you are able to use lambdas and funct
Re: Moving away from BGT and learning python
You can get an equivalent to NPEs in Python, can't you? I mean, doesn't the exact same principal apply to trying to call a.f() if a is null or if a is None?Basically, you can't expect that a function or method will never be call
Re: Moving away from BGT and learning python
@Hrvoje, most of the issues you pointed out, like null pointer exceptions, can be gotten around easily. For example, in C++, you'd either use a library that *doesn't* use NULL or nullptr, or you'd do checks for t
Re: Moving away from BGT and learning python
Well, honestly. Python's indentation is may be the only thing that may frustrate beginner users. However, Python is a piece of heaven comparing to some other languages where you get frustrated with null pointer exceptions, data conversions
Re: Moving away from BGT and learning python
I'm currently writing a large application and have written everything in notepad. I haven't used an IDE at all, unless you count the VC++ command-line developer tools as an 'IDE'. Also, the smart string concatenation that peo
Re: Moving away from BGT and learning python
Yeah. I find that, while IDEs reduce some of the work, they make up for it with clutter and navigation and gah just let me write the code in a text editor, read the compilation results, and test the thing. Notepad + the command prompt is
Re: Moving away from BGT and learning python
Hi Amerikranian.Goodness, I am tired of hearing stupid stuff like this! Yes you can use notepad to write python programs no problem. I've seen this in many python tutorials, "Don't use notepad, it's very bad!" If i
Re: Moving away from BGT and learning python
Yeah, I was mainly talking about the conditional stuff like switch case statements and the ternary operator. Python's constant if/elif/else blocks feel repetative to type. In C/C++ (Which admittedly is beginning to put this language back
Re: Moving away from BGT and learning python
Yeah, I was mainly talking about the conditional stuff like switch case statements and the ternary operator. Python's constant if/elif/else blocks feel repetative to type. In C/C++ (Which admittedly is beginning to put this language back
Re: Moving away from BGT and learning python
so the book says not to use notepad. Is there any other edetors that you'd suggest? I don't want to go try a random one in case of it not being accessible.
URL: http://forum.audiogames.net/viewtopic.php?pid=3527
Re: Moving away from BGT and learning python
Hi,Actually the %s thing is still valid in python 3 as I just checked it out. IF you don't want to use it then you can use the power feature introduced in python, called f strings or formated strings. like this: name="amit"print(f
Re: Moving away from BGT and learning python
What's the V3 way of doing things?
URL: http://forum.audiogames.net/viewtopic.php?pid=352764#p352764
___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
Re: Moving away from BGT and learning python
oh I see
URL: http://forum.audiogames.net/viewtopic.php?pid=352734#p352734
___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi
Re: Moving away from BGT and learning python
that %s stuff is the old way of doing things, you don't do that in python 3
URL: http://forum.audiogames.net/viewtopic.php?pid=352727#p352727
___
Audiogames-reflector mailing list
Audio
Re: Moving away from BGT and learning python
@post 10:smart string concatenation? I think this is pretty smart name = "paul"surname = "iyobo"print "hi %s, %s" % (name, surname)or maybe I totally missunderstood what you were saying
URL: http://forum.audiogame
Re: Moving away from BGT and learning python
a= (b) ? c : d; switch (e) {case f : g(); break;case h : i(); break;}And then there are c-style macros.Python is supremely simpler overall, but I do need the terniary operation far more often than swapping.Yeah, Python eventually added its own
Re: Moving away from BGT and learning python
Hi,At post number 7,, excuse me please, but what kind of c/c++ syntax are you talking about? I know some c++ and what I've always seen that a c++ programmer is always bigger compared to a python program. And python is so simple too. To su
Re: Moving away from BGT and learning python
Hi.Both python 2 and 3 both have pip now, you just need to edit the systems variables. Pip won't respond in command prompt unless you do this. Python's syntax is very simple, especially for making small utilities and things like that.
Re: Moving away from BGT and learning python
Oh. Thank goodness. I'm getting really tired of BGT and my antivirus having a civil war on my computer, so hopefully seeing more developers migrating away from it might solve most of those issues. Probably not all of them because anti
Re: Moving away from BGT and learning python
make sure pip is in your path, and if its not, add it.go to the run dialog, type SystemPropertiesAdvanced, click environment variables, tab down to the system variables list, find path, click edit.Go to the end of this text. Now you'll ha
Re: Moving away from BGT and learning python
Hi,Open command prompt by typing cmd in the run dialogue box and pressing enter. Now type pip install pygame pyinstaller libaudioverse. That was an example... This way you can install your libraries automatically. If this is not working, use the
Re: Moving away from BGT and learning python
I'm confused on that. I tryed entiring the pip command but nothing happens. Where do I type this? Very confused on where this goes...
URL: http://forum.audiogames.net/viewtopic.php?pid=352599#p3
Re: Moving away from BGT and learning python
Python is a good choice because it's syntax is even easier than BGT. Everything is an object and everything is dynamic, so it's not required to declare data types.When I've started learning Python, which was somewhere in late 2
Re: Moving away from BGT and learning python
Well the first step would be to download Python [here]. Some good books to start off with would be [A Byte of Python] and [How to Think Like a Computer Scientist], although you can find a bunch more [here].
URL: http://forum.audiogames.net
59 matches
Mail list logo