Friday 26 September 2014

7. Input Output



Learning outcomes
You will learn to use:
The input function
The int function
String formatting
Number formatting


Activity 6.1
Input function
The input function allows the user to input a value and assign it to a variable.
Copy and run this program.
myAnswer=input("Please enter your name: ")
print(myAnswer)

Re-run the program several times, entering different names each time.

Write a program that asks the user for their name and favourite food and displays these on the screen.
Activity 6.2
Int function
Copy and run this program.
age=input("Please enter your age: ")
agePlusTen = age + 10
print("You will be",agePlusTen,"in 10 years")

Explain why it does not work.
Correct the program.
Activity 6.3
Write a program that asks you to enter a number then displays the number doubled.
Activity 6.4
String formatting
The string method .format gives you more control over the formatting of your output than printing using space-separated values. The string formatting commands are given in curly brackets {}.

Copy and run these lines of code:

>>>foodOne="fish"
>>>foodTwo="chips"
>>>print("{0} and {1}".format(foodOne,foodTwo))
fish and chips

>>>print("{1} and {0}".format(foodOne,foodTwo))
chips and fish

>>>print("{1} {1} {1}  and {0} {0} {0}".format(foodOne,foodTwo))
chipschipschips and fishfishfish

Create these variables:
one = “cheese”
two =”onion”

Use the .formatcommand to display:

My favourite crisps are cheese and onion. I love them!
cheese and onion and cheese and onion and cheese and onion
cheesecheesecheese and oniononiononion
You guessed it. The best crisps are onion and … cheese.

Try altering the flavours assigned to the variables to your favourite flavour! Enjoy.
Activity 6.5
Formatting numbers
You can use the .format method to format the number of decimal places.  

Copy and run these lines of code:

>>>number = 98.1468297645
>>>print("The answer is {0:.5f}".format(number))
The answer is 98.14683

>>>print("The answer is {0:.4f}".format(number))
The answer is 98.1468

>>>print("The answer is {0:.3f}".format(number))
The answer is 98.147

>>>print("The answer is {0:.1f}".format(number))
The answer is 98.1

>>>print("The answer is {0:.0f}".format(number))
The answer is 98

Assign the number 765.87641987 to a variable and display the number with 5, 2 and no decimal places using the .format command.
Activity 6.6
Write a program that asks how much your bill is at a restaurant and then asks you to enter the % you want to give in a tip. The program should display the amount of tip to give to the waiter.

Amend the program so that it also displays the total cost of the meal including the tip.
Activity 6.7
Write a program that displays the square of a number.
Write a program that prompts for a number and then displays the cube of a number.
Write a program to find the perimeter of a square.
Write a program to find the perimeter of a rectangle.
Write a program that finds the area of a square.
Write a program that finds the area of a cube.
Write a program to convert from pounds to euros.

Hint: All these programs should prompt for the input information and display the result appropriately.

Thursday 11 September 2014

11th September Lesson





Today we will continue to work  on numbers.

You will learn to:

Express denary as binary
Express binary as denary
Express hex as binary
Express hex as denary

First let's watch the hex counting video

https://www.youtube.com/watch?v=VsYV7H5AUeg

Now let's have a go at the Socrative quiz:

http://www.socrative.com/

ROOM: 44345580



HOMEWORK   DUE 15th September at 5.00pm

Explain how an ASCII table is used to represent text in a computer system.  Please provide a link to your answer by commenting to this post.

Tuesday 2 September 2014

INTRODUCTION TO GCSE COMPUTING




Welcome to the introductory lesson for GCSE Computing.  For 2014/16 I have decided that we will follow the course offered by Edexcel.  I feel that this will give you a far better learning experience and that you will be better equipped to tackle AS Level and beyond.

LEARNING BLOG

You will be required to set-up your own learning blog.  This is where you will record what you have learned in lessons, show links to Google docs containing your homework and receive feedback.  You can use your yellow exercise books to take notes etc.  

TASKS

1. Go to Blogger and create your blog.
2.  Reply to this post with the URL of your learning blog.

EDEXCEL GCSE COMPUTING

The specification for the course is below.

http://www.edexcel.com/migrationdocuments/GCSE%20New%20GCSE/9781446908358_GCSE_Lin_CompScie_web.pdf

TIMESCALE

This is a link to the initial plan of what we will cover over the next two years.  Depending on the progress we make this may be adjusted.

http://www.edexcel.com/migrationdocuments/GCSE%20New%20GCSE/Edexcel_GCSE_Computer_Science_Course_Planner_v2.xls

NEXT LESSON

If you haven't already make sure THAT YOU HAVE ENROLLED IN AND ARE FOLLOWING THE CODECADEMY Python course.    Python will be the language we will use for the controlled assessment - you cannot use anything else.  

HOMEWORK

Reply to this post with 5 facts about Python.