Download File

yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Structured programming wikipedia , lookup

Python syntax and semantics wikipedia , lookup

Python (programming language) wikipedia , lookup

Be able to use a text based
language like Python and
JavaScript & correctly use
procedures and functions with
parameters in your programs.
Python is a freely available programming language.
You can write Python
code in notepad, or any
other simple text editors
- but it is easier if you
use a program like IDLE
(named after Eric Idle
(Monty Python!))
You can type simple commands at the prompt (>>>).
Try typing:
Check that the answers are correct!
Quick note: you are going to be making lots of Python programs. Create a Python
folder somewhere so that you can save your files here!
function “print”
We can put simple instructions into the IDLE window, but we can’t write and save
complex programs.
Open IDLE and look for the chevrons >>>
Simply type the following (exactly):
print(“Hello, World”)
Now press Enter!
The main IDLE window should show you your output:
Well done! You’ve written your
first program!
•Save your program as MyFirstProgram in your PYTHON folder.
(Simply go to File menu….Save As….)
•TO Open the PYTHON program, find the file in your PYTHON folder.
•Right-click the file
•From the pop-up menu, select EDIT
with IDLE
Make sure you are comfortable with opening and saving a Python program.
>>> print"Hello World"
Which one of these will output the
>>> print("Hello World");
following ?
>>> Print("Hello World")
>>>Hello World
>>> print("Hel World")
>>> prin(Hello World)
By the way…
you can use “speech marks” or ‘apostrophes’ for
words (strings) Both will work!
Hello World in SCRIPT MODE
Another way we can write code in PYTHON is by using SCRIPT mode. This is useful when you
are working with many lines of code.
Open IDLE and click the FILE menu option. Select NEW WINDOW - this will give you a new
window that you can use to write and save your programs!
In this new window, type the following (exactly):
print(“Hello, World”)
Save this file in your Python folder (call it “hello world”) and then press F5 to run it.
The main IDLE window (>>>) should show you your output:
Congratulations! You have written a Python program!
If you can, do all these programs in SCRIPT mode
(i.e. go to FILE, NEW WINDOW…then press F5 to run)
Task 1: Create a program in python that outputs the following…
Save as ‘’
Task 2: Create a program in python that outputs the following…
I love Python and right now I’m learning to program!
Save File again!
Task 3: Create a program in python that outputs the following…
What does \n do?