Download presentation
Presentation is loading. Please wait.
1
Task 1 Computer Programming LEVEL 6 PROGRAMMING:
Be able to use a text based language like Python and JavaScript & correctly use procedures and functions with parameters in your programs. Task 1 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
Python is more than a Calculator
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! Python is more than a Calculator This is where we use the function “print” to make something appear on the screen. Magic pixies inside the computer? - Nope just code!
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… KEEP CALM AND LEARN PYTHON Save as ‘KeepCalm.py’ 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?
8
Additional Tasks: Using the escape key \n can you make a Smiley Face?
We will be making interactive programs next lesson. How does a Chat Bot work? Click Here Who is Alan Turing? Plenary activity from:
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.