Wednesday, 1 July 2015

6. Data Types, Variables and Input



You will learn about:


  • Data types
  • Variables 
  • User Input

Activity 5.2
Data types
Use the “type” function to find out the data types for these values.
>>>type("Fred")
>>>type(198)
>>>type(88.9)
>>>type(True)
>>>type(False)

Hint: Remember that True and False must start with a capital letter.
Activity 5.3
The type function returns the data type of an expression.
For each of these expressions, first predict the data type then use the type command to see if your prediction was correct.
Expression
Predicted data type
Type command
Result
“hello world”

type("hello world")

False

type(False)

15

type(15)

35.6

type(35.6)

-999

type(-999)

“15”

type(“15”)

“False”

type(“False”)

True

type(True)

0.001

type(0.001)


Activity 5.4
The interactive shell is a useful place to explore variables.
Copy and run this code in the interactive shell.
myName="Fred Smith"
myAge=14
print(myName,myAge)

Create a variable called myName and assign it to your name.
Create a variable called myAge and assign it to your age
Create a variable called myEyes and assign it to your eye colour.
Create a variable called myHeight and assign it to your height.
Write the commands to display on the screen your name, age, eye colour and height.
Hint: Remember that a single ‘=’ is used to assign a value to a variable.  
Activity 5.5
Variable names
A programmer is trying to decide on a valid name for a variable that represents a house number.
Which of the following variable assignments are valid? Why are the others not valid?

Valid or invalid variable name?
Reason why not valid
8HouseNumber = 288


houseNumber = 288


house Number = 288


house_number = 288


import = 288



What type of error do you get when using an invalid variable name?
Activity 5.6
Copy and run this code and explain the result.
# Programmer Amy Jones 12/8/2013
# adds two numbers
numberOne=15
numberTwo=23
answer=numberOne + numberTwo
print("The answer is “,answer)

Amend the program to add another variable called numberThree. Assign the value 76 to this variable. The program should all up all three numbers and print the result.
Activity 5.7
Data types in Python
Complete this table to describe the four data types.
Data type
Python abbreviation
Explanation
Example
integer
int


string
str


float
float


boolean
bool



Hint: Quotation marks are used to show the start and end point of a string, e.g. “this is a string”.

Friday, 26 June 2015

03. Introduction to Algorithms


Learning Outcomes



You will learn to:
Describe the decomposition of a problem
Describe what an algorithm is
Describe Psuedocode
Describe flowchart and flowchart shapes

Write a simple algorithm to calculate the area of a circle.

Resource
One of the best resources is the teach-ICT.com site.  Please use the following link:
http://www.teach-ict.com/gcse_computing/ocr/216_programming/algorithms/miniweb
Definition
An algorithm is simply a set of instructions for performing a task. Some algorithms are more efficient than others and we will look at these in more detail later in the course.  The purpose of an algorithm is to find a solution to a problem of to complete a goal in the most efficient and effective way possible.  A program is a set of instructions which have been written in a lNguage the computer understands in order to make the algorithm work.

Decomposition

The reason for introducing this topic now is that in order to program well you are going to need to think like a computer - particularly when you do your controlled assessment.  You need to decompose or break tasks down into small chunks so that they are easy to follow and impossible to get wrong.

Penalty Kick Algorithm


Look at the following algorithm for taking a penalty kick.  Try to work out what is wrong with it.  Remember the objective of a penalty kick is obviously to score a goal.

1. Start
2. Place football on penalty spot
3. Kick ball
4. End

TASK 1

In pairs write an algorithm for taking a penalty kick which will result in a goal being scored.

Lift Algorithm

Look at the following algorithm and work out why this one achieves all it's objectives efficiently and effectively:
1. Start
2. Wait until doors are closed
3. Wait until the floor button is pressed
  If button pressed is > than current floor
     Move lift upwards
  If button pressed is < than current floor
     Move lift downwards
4. When current floor = button pressed
5.  Open doors
6. End

TASK 2

Write an algorithm to calculate the area of a circle.
Flowcharts

Now let's explore the teach-ICT.com pages on Flowcharts

http://www.teach-ict.com/gcse_computing/ocr/216_programming/algorithms/miniweb/pg7.htm

Homework

Select either your algorithm for calculating the area of a circle or the lift operation algorithm in recreate as a flowchart.

Monday, 15 June 2015

June 19th






STARTER

In your exercise books complete the following:

  1. Express 23 as a Hex?
  2. Express 23 as an 8 bit binary?
  3. Express 123 as a Hex?
  4. Express 123 as an 8 bit binary?
  5. Express 10100011 as a Hex?
  6. Express 11101011 as a Hex?
  7. Express 10101011 as a Hex?
  8. Express 11101011 as a Hex?
  9. Express 11100111 as a Hex?
  10. Express 11111011 as a denary?

Tip: for questions 5-9 split into two nibbles and show working.


Work through the SQL TUTORIAL –

1.       Practise each example in the simulator
2.       In your exercise books make a note of the key word syntax.

YOU SHOULD AIM TO FINISH THE WHOLE COURSE – HOWEVER IN TODAY'S 

LESSON MAKE SURE THAT YOU GET AS FAR AS CHAPTER ABOUT 'DELETE'.

Home
Intro

Syntax

Select

Distinct
Where

AND & OR

ORDER BY
INSERT
Update

Delete
http://www.w3schools.com/sql/sql_delete.asp

June 18th





HOMEWORK AJT DUE 22nd June

Ensure that you have complete the SQL course up to DELETE

DATA VALIDATION
On BBC Bite Size complete the following:

Watch the video

Complete the test
n.b. Repeat until you get all correct – note your answers.

As a reply to this post provide definitions with examples  of the following:

- Presence check
-  Range Check
Picture check 
-  Type check

ALSO, IF YOU HAVE NOT ALREADY COMPLETED THE CHALLENGES FROM TODAY'S LESSON THESE MUST BE DONE FOR HOMEWORK.

STARTER

  • Express 11001101 as DENARY
  •   Express 233 as BINARY
  •     Express 233 as HEX
  •     Express 167 as HEX

SHOW YOUR WORKING

1.       First let’s finish our notes from Teach-ICT.com

http://www.teach-ict.com/as_as_computing/ocr/H447/F453/3_3_9/sqlintro/miniweb/pg5.htm



CHALLENGE 1


The two tables Product and Supplier form a relational database used by a shoe shop.





(a)    State the primary key of the Supplier table and justify your choice.  (2) 




(b)   List the results of executing the following SQL query on the database above. (4)


SELECT Product.Name, Product.Quantity, Supplier.PostCode
FROM Product, Supplier WHERE Product.Quantity > 40 AND Supplier.Name = ‘Trainers4Us’
AND Product.SupplierCode = Supplier.SupplierCode 

(c)    Write an SQL statement to add the following data to the Product table:  (3)

444AA  Slippers  6.99  32  100  


CHALLENGE 2
(a)    Look at the Products table. Write an SQL statement that orders the products alphabetically by supplier name (3)

(b)   Look at the Products table. Write an SQL statement that orders the by the quantity with the largest first? (3)




Tuesday, 9 June 2015

Representation of Character




In your books do the following:

(1) Find an ASCII table

(2) How many bytes does an ASCII table take up?

(3) What does ACII mean?

(4) What is ASCII used for?

(3) What is 'D' as a denary in ASCII?

(4) What is 'g' as a denary in ASCII?

(5) List all the differences between ASCII and UNICODE

(6) How many bytes does Unicode take up?

(7) How many characters can UNICODE display?

(8) Why do we need UNICODE?

HOMEWORK

By a reply to this post write up some research on QUANTUM COMPUTING.  Answer the following:

What is Quantum Computing?
How does it work?
What is it used for?
What are its advantages?
What are its disadvantages?
How can it help change the world?

BIG QUESTIONS - BUT REMEMBER CUTTING AND PASTING IS A WASTE OF TIME!



SQL

SQL

STARTER COMPLETE THE QUIZ

How many did you get?

DEFINITION

Find and write down a definition of SQL.  What is it used for?

BASIC SYNTAX
Write the basic keywords in your notebook:


PRACTICSE

Now let’s practise using the w3schools site – let’s go through the first four chapters:

Monday, 8 June 2015

REVISION FOR MOCK EXAM