
Python is a FREE program that is 100% coding. Now, download it here.
NOTE: For those who want to test, go to Options, then Configure IDLE. Then go to "General". For the startup, click "Open Edit"
So, lets get started on the easiest thing... 'Hello World'
HELLO WORLD
So I will break up the code.
Line 1:
#This program says hello and asks for my name.
Line 2:
print('Hello world!')Line 3:
print('What is your name?')Line 4:
myName = input()
Line 5:
print('It is good to meet you, ' + myName)
USING PYTHON FOR MATH
This is very simple. Here is something EASY:
5 + 5
It would say "10".
So, next is a cool way to do math!
Here is a sample code:
Scratch = 4947284244676486189461874 MIT = 5
So, lets do a problem:
Scratch + MIT
and the result is...
4947284244676486189461879

Expect more Python coding soon! Keep looking for updates!
Our other forum post: here!
Also expect a website soon (with a wiki!)
EDIT: Expect Non support from this topic soon. This library is moving as soon as PythonLibrary is upgraded to Scratcher!
Last edited by thebuilderdd (2011-03-26 19:21:52)
Offline
bbbeb wrote:
Moving to misc is incoming
otherwise its okay
OK...
Offline
I don't get panther, can you help me? So I open it and its a black screen, I type in print('hi') and it adds hi
>>>
how do I save it? How do I open it? HELP ME PLEASE!
Offline
Pecola1 wrote:
I don't get panther, can you help me? So I open it and its a black screen, I type in print('hi') and it adds hi
>>>
how do I save it? How do I open it? HELP ME PLEASE!
This is Python. Oh, you called it Panther. Anyway, print('hi') means say Hi when the code is run. Saving it is just a breeze. You know, File save. File Open. Oh, for a key, make sure to type .py at the end.
Last edited by thebuilderdd (2011-03-26 17:48:11)
Offline
bbbeb wrote:
Moving to misc is incoming
otherwise its okay
I think this should actualy stay here, it might not be directly related to scratch, but it can communicate with it, and whats wrong with a tutorial on how to do python, which is more advanced?
@thebuilderdd
Maybe some screen shots on how to set up python?
Edit:
Tried the Helloworld program.
I get an Error:
Traceback (most recent call last):
File "J:/Programming/Python/Helloworld.py", line 4, in <module>
myName = input()
File "<string>", line 1, in <module>
NameError: name 'Mark' is not definedI'm geussing is that you didn't define what type of variable myName is.
Last edited by markyparky56 (2011-03-26 18:07:14)
Offline
Very nice tutorial
Many Scratch users feel like moving onto other programs, Python being a popular one, so it's nice that the community is helping. Although, this needs to be moved to Miscellaneous
Offline
markyparky56 wrote:
bbbeb wrote:
Moving to misc is incoming
otherwise its okayI think this should actualy stay here, it might not be directly related to scratch, but it can communicate with it, and whats wrong with a tutorial on how to do python, which is more advanced?
@thebuilderdd
Maybe some screen shots on how to set up python?
Edit:
Tried the Helloworld program.
I get an Error:Code:
Traceback (most recent call last): File "J:/Programming/Python/Helloworld.py", line 4, in <module> myName = input() File "<string>", line 1, in <module> NameError: name 'Mark' is not definedI'm geussing is that you didn't define what type of variable myName is.
Oh, that. You have Python 2.7! They list that one first.
Offline
What kind of stuff can you make with Python? Is it similar to C++?
I know a bit of C++ so I might be able to learn this if it's similar...
Offline
markyparky56 wrote:
Tried the Helloworld program.
I get an Error:Code:
Traceback (most recent call last): File "J:/Programming/Python/Helloworld.py", line 4, in <module> myName = input() File "<string>", line 1, in <module> NameError: name 'Mark' is not definedI'm geussing is that you didn't define what type of variable myName is.
The problem is that Python replaces 'input()' with whatever you type in, so it's basically the same thing as saying
myName = Mark
Python thinks that Mark is a variable, but it hasn't been defined, so it gives an error. To enter a string (a piece of text), you put 'Mark' in single or double quotes, like "Mark". The function 'raw_input()' treats what you type in as a string, so replacing 'input()' with 'raw_input()' will fix the program.
A better example would be to use
myName = raw_input('What is your name? ')Run it and see what happens!
cpumaster930 wrote:
What kind of stuff can you make with Python? Is it similar to C++?
I know a bit of C++ so I might be able to learn this if it's similar...
Python is quite different to C++. Python is a high level, object oriented programming language that is great for people learning programming. Although it is a lot different, I still suggest learning it.
Last edited by floppy_gunk (2011-03-27 02:08:41)
Offline
cpumaster930 wrote:
What kind of stuff can you make with Python? Is it similar to C++?
I know a bit of C++ so I might be able to learn this if it's similar...
Python is a dynamically typed, OOP language, it's also interpreted (and a little function programming). C++ is statically typed, also OOP, and it's compiled. Syntax wise they are pretty similar though Python has less "noise". I would say Python is easier to learn if you are just starting out, and should be easier if you already know another language.
Offline
Okay, its working now. Thanks floppy_gunk!
Working code:
#This program says hello and asks for my name.
print('Hello world!')
myName = raw_input('What is your name? \n')
print('Hello ' + myName + ' Its good it meet you!')I tossed in a newline character to make it look nise when you're reading it.
Offline
Python is so cool.
but how does python communicate with scratch?
Offline
DarthPickley wrote:
Python is so cool.
but how does python communicate with scratch?
Related
Offline
thebuilderdd wrote:
DarthPickley wrote:
Python is so cool.
but how does python communicate with scratch?Related
Related? In what way?
Offline
1st of all, you need more explanation for each statement. A good coding tutorial first tells about a certain statement and parameters, then gives an example. Also, I'm not sure that this should be on the Scratch website.
Offline
cpumaster930 wrote:
What kind of stuff can you make with Python? Is it similar to C++?
I know a bit of C++ so I might be able to learn this if it's similar...
I agree with everyone else, but what no one seems to realize is that the OOP part is OPTIONAL. I still haven't even learned enough Python to use the OOP part!
Offline
maxskywalker wrote:
1st of all, you need more explanation for each statement. A good coding tutorial first tells about a certain statement and parameters, then gives an example. Also, I'm not sure that this should be on the Scratch website.
Python allows for communication between Scratch and other programs, possibly even allowing for more advanced multiplayer. And yes, the tutorials do need more depth and explanation.
Offline
markyparky56 wrote:
maxskywalker wrote:
1st of all, you need more explanation for each statement. A good coding tutorial first tells about a certain statement and parameters, then gives an example. Also, I'm not sure that this should be on the Scratch website.
Python allows for communication between Scratch and other programs, possibly even allowing for more advanced multiplayer. And yes, the tutorials do need more depth and explanation.
I can only update on Fridays, so stay tuned!
Offline
ssss wrote:
actually, MIT + SCRATCH should actually be int(MIT) + int(SCRATCH). It lookes more proffesional, and let's you do equations like int(MIT) - 4 * int(SRATCH)
That looks like your calling a function called int() when ever you use an interger variable... Having learnt the basics of C++, I would've thought you declared a variable by stating what kinda it was (int) the name of it (Scratch) and its value ([large number])
So you'd have something:
int Scratch = 34829434838048
The value for scratch is just random. Is this done through the int() part of the code? just in brackets?
Offline
ssss wrote:
actually, MIT + SCRATCH should actually be int(MIT) + int(SCRATCH). It lookes more proffesional, and let's you do equations like int(MIT) - 4 * int(SRATCH)
You can do that without the int() functions. Python say the answer is -19789136978705944757847491
Type in:
5 ** 50000
Don't be scared, it finished fast!
Offline
Magnie Quick Guide to Python:
print "Hello World"
raw_input("Press Enter To Exit")^ Use the raw_input to keep the 'Black Window' open.
print "Text in quotation marks" - Displays whatever is in the quotation marks.
raw_input("Text in quotation marks") - Is like the Ask Block in Scratch, to save the input from the Ask Block:
variable = raw_input("Text in quotation marks")
variable = String, Integer, etc - Just like a variable in Scratch.
# Comment Here, Echo Program
running = 1
while running == 1:
cmd = raw_input("Command: ")
if cmd == 'quit': running = 0
else: print cmd^ That will print whatever you type in there, unless you type 'quit' that will exit the program. More detail:
# Comment Here, Echo Program
running = 1 # running is 1
while running == 1: # while running is 1, do below, if it is not 0 end while loop
cmd = raw_input("Command: ") # Ask for input, save it to cmd
if cmd == 'quit': running = 0 # if cmd is 'quit', set running to 0 so program will end
else: print cmd # If not 'quit' print whatever 'cmd' is.^ pretty basic and understandable. If you have any questions, feel free to ask ^.^
Last edited by Magnie (2011-04-14 17:28:39)
Offline
Magnie wrote:
Magnie Quick Guide to Python:
Code:
print "Hello World" raw_input("Press Enter To Exit")^ Use the raw_input to keep the 'Black Window' open.
![]()
print "Text in quotation marks" - Displays whatever is in the quotation marks.
raw_input("Text in quotation marks") - Is like the Ask Block in Scratch, to save the input from the Ask Block:
variable = raw_input("Text in quotation marks")
variable = String, Integer, etc - Just like a variable in Scratch.Code:
# Comment Here, Echo Program running = 1 while running == 1: cmd = raw_input("Command: ") if cmd == 'quit': running = 0 else: print cmd^ That will print whatever you type in there, unless you type 'quit' that will exit the program. More detail:
Code:
# Comment Here, Echo Program running = 1 # running is 1 while running == 1: # while running is 1, do below, if it is not 0 end while loop cmd = raw_input("Command: ") # Ask for input, save it to cmd if cmd == 'quit': running = 0 # if cmd is 'quit', set running to 0 so program will end else: print cmd # If not 'quit' print whatever 'cmd' is.^ pretty basic and understandable. If you have any questions, feel free to ask ^.^
Put this in a new topic. As I am the only one allowed on here to add extra stuff. Delete this post. Thanks
Offline