Send the link below via email or IMCopy
Present to your audienceStart 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
CS - Lesson 17
Transcript of CS - Lesson 17
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):
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...
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')
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.