Download presentation
Presentation is loading. Please wait.
1
Week 1 Computer Programming Year 9 – Unit 9.04
Gray , Calibri 24 Dark Red RGB , Calibri 54
2
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!))
3
You can type simple commands at the prompt (>>>).
Try typing: 2+2 17-9 16/4 3*7 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!
4
Hello World in INTERACTIVE MODE
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!
5
>>> print"Hello World" >>> print("Hello World");
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" >>> print("Hello World"); >>> Print("Hello World") >>> print("Hel World") >>> prin(Hello World) Which one of these will output the following ? >>>Hello World By the way… you can use “speech marks” or ‘apostrophes’ for words (strings) Both will work!
6
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 again.py”) and then press F5 to run it. The main IDLE window should show you your output: Congratulations! You have written a Python program!
7
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… STAY CALM AND LEARN PYTON Save as ‘StayCalm.py’ Task 2: Create a program in python that outputs the following… I love Python and right now I’m learning to program! Save as ‘ILovePython.py’ Task 3: Create a program in python that outputs the following… * ** *** **** ***** Save as ‘Stars.py’
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.