Presentation is loading. Please wait.

Presentation is loading. Please wait.

Agenda Introduction Computer Programs Python Variables Assignment

Similar presentations


Presentation on theme: "Agenda Introduction Computer Programs Python Variables Assignment"— Presentation transcript:

0 Computer Programming Fundamentals
Introduction to Python

1 Agenda Introduction Computer Programs Python Variables Assignment
The Python shell Variables Assignment A first program

2 Computer Programs Computer Programs Programming languages Python
Web browser Spread sheet Programming languages Human-readable Converted to a form the computer can execute Compiler Interpreter Python An interpreted language

3 Python shell Python can be used as a command line interpreter
Reads ‘commands’ from the console Writes results back Can use this mode to try stuff out

4 “Hello World!”

5 Python shell as a calculator

6 Variables Little bits of the computer’s memory
We assign them an identifier so we can refer to them When we put stuff into a variable, the computer will remember it for us Later we can get that stuff back again We can retrieve the variable’s contents at any time

7 Identifiers and Keywords
Names you can make up Must begin with a letter or underscore ( _ ) Can then have letters, numbers and underscores Keywords Words that have a special meaning Cannot use them as identifiers Examples - if , while, for

8 Identifiers aName 23HighSt _special_ A name HighSt23 joe@somewhere
Examples of identifiers: aName 23HighSt _special_ A name HighSt23 while

9 Using variables aVariable = 123 X = aVariable aString = "A string"
anotherString = 'The value of y is ' a = X + 4 y = a print(anotherString+str(y)) The value of y is 127

10 Variable type Variables have an associated type
This type defines what sort of information the variable contains Examples of variable type: Numbers int, float, complex Strings of characters Boolean values True False

11 Using the console Writing to the console
print("Message ...") Reading input from the console name = input("Enter name:") name now contains the value entered

12 Writing programs Can store groups of ‘statements’ for execution later
We do not have to type them all in again Later we will learn how to control the flow through the stored statements Such a group of statements is a program

13 A first program ##################################### # First program # print("Starting first program!") enteredValue = input("Enter value:") print("Value entered was - ",end="") print(enteredValue)

14 Running our first program

15 Program design Before embarking on the coding process it is usually a good idea to design your program Designing your program means Thinking about how your program is to work Recording the decisions you have made in order to communicate your design to others Many possible ways to record your design Flowcharts Pseudo-code

16 Flow charts Terminator Input and output Start Start Print message
Finish Prompt & Get reply Confirm value Terminator Input and output Start Print message 16

17 Flow charts print("Starting first program!")
message Start Finish Prompt & Get reply Confirm value print("Starting first program!") enteredValue = input("Enter value:") print("Value entered was - ",end="") print(enteredValue) 17

18 Exercises Exercise 1 Exercise 2 Exercise 3 Exercise 4
Exploring the command line Exercise 2 The famous ‘Hello World!’ program Exercise 3 Using the console Exercise 4 Dealing with ‘types’


Download ppt "Agenda Introduction Computer Programs Python Variables Assignment"

Similar presentations


Ads by Google