-- Leo's gemini proxy

-- Connecting to republic.circumlunar.space:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

My First Raspberry Pi Game – Part 02 – Saying hello


Parts: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12.


Writing your first ever computer program on the Raspberry Pi. See Part 1 for how to get and set up the Pi.


1

3

4

5

6

7

8

9

10

11

12

Part 1


Today we will find out how to write a computer program, and how to run it.


We're going to write one of the simplest programs you can write - we're going to get the computer to say hello to us.


First, we need a text editor to write down our program. Click the weird aeroplane-y thing in the bottom left - that brings up the menu (like the Start button on Windows), then choose Accessories, then Leafpad. Leafpad is the text editor we will be using.


Leafpad will start, and show you an empty page. This is where we will write our program.


Type in exactly this:


print "Hello, world!"


and then click the File menu at the top of the Leafpad window and choose Save As. Click the word "pi" on the left and then click in the empty box next to the word Name, and type the name of our program, which is:


redgreen.py

"redgreen" is the name and the ".py" means this is a program written in the language Python. We'll be finding out more about Python as we go on.


Python


Click the Save button.


Our program is finished! Now we need to run it.


Click the aeroplane-y thing again, then Accessories, then LXTerminal. A terminal is a program you use to run other programs.


When LXTerminal has started, your cursor will appear next to a $ sign. This means it is ready for you to tell it what to do.


Type exactly this:


python redgreen.py


What this means is run the program called "python", and pass the name of our program (redgreen.py) to it. This is how you run Python programs.


Now press the RETURN key.


If all goes well, our program will talk back to us, and say what we told it to say:


Hello, world!


Let's look again at our program.


It's just one "statement", a print statement. A statement is something to do.


We pass one "argument" to print, "Hello, world!". An argument is some information you give to a statement.


"print" doesn't mean print to the printer, but write to the screen. So our program did exactly what we told it to do - it wrote our message to the screen.


Next time, we'll map out the whole of our real program - a simple game.


Update: congratulations to sparkboy123 on getting this working!


Originally posted at 2012-11-06 08:45:20+00:00. Automatically generated from the original post : apologies for the errors introduced.


getting this working

original post

-- Response ended

-- Page fetched on Sun May 19 06:35:43 2024