Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

CS - Lesson 17

No description
by

Mr Smith

on 6 February 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of CS - Lesson 17

Lesson 17

Programming LO's

Understand procedures
Define some of the data types used pounds = float(input("Enter the amount to convert: "))
euro = pounds * 1.2406
print(euro) What is this?

Here we have a mini program that generates pounds to euros What is the float used for? What did we do here? def greeting():
print "Hello" This is another procedure we can use. Where we set the procedure we want to use later on in the program. Activity..... Produce a procedure that says hello + your name when the user enters their own name..... I WILL NOT BE GIVING YOU THE ANSWER!!! Some help.... greeting(“Laura”)
Hello Laura This might be your output? How might the parameter change? This is a setting of a variable def mySub():
for i in range(0,3):
print(“hello”)
mySub() As you can see here we have a loop with a print command To call the routine, we use this command. DO NOT USE THE PRINT COMMAND! Procedure with parameters... So, what will we need to do here?? We have to call the routine again at the bottom, but with some parameters def mySub2(word,times):
for i in range(0,times):
print(word) File Handling When we ask the python to...
open
create
read
save

Lets look at some of the syntax involved with file handling.... Watch the you tube video and complete the following...

Create a folder called programming in the root of N:\my documents
Create a note pad file called test
Write to the file " Hello, this is my first attempt at file handling"
save and write down the process in your text books Answer fob=open('c:/python/test.txt','w')
fob.write('Hey this is my first attempt at file handling')
fob.close() The FOB part could be anything, whatever it is, you must refer to later on....

Remember - to close the file when complete!! Opening files fob=open('c:/python/test.txt','r')
line1=fob.read()
print(line1)
fob.close() What do you need to change?

What will you read? Challenge Try making a calculator.
The program will ask for...
Two numbers and then give you a menu,
so you can add, subtract, multiply, divide, square
either number or find out the power.
Full transcript