Starter:
Recap on Python - Click on the link HERE
and have a go at the questions.
Check and edit your answers.
Main:
Watch the video about Selection HERE
Red Task
Open Python 3.4 IDLE in all programs.
Open your Hello World programs.
Copy the text below underneath your program
Check your code is correct by running your program (F5)
Input your name and press enter then input yes or no and press enter.
What happens? Are there any errors?
Go to classroom.google.com
Go to your class code and find your Python Evidence Document
Take a snip of your code and program running using the snipping tool and paste into the Lesson 1: Python Syntax box.
Extension: Can you explain what the code is doing? Can you use any keywords? E.g. String, function, variable?
Amber Task
You are now going to create a simple calculator in Python.
In Python a whole number is called an INTEGER and a decimal number is called a FLOAT. We represent them as int and float in our code.
In Python a word is called a STRING (a string of characters). We represent this as str in our code.
Open a new file in Python 3.4 IDLE
Copy the text below into the window
Run the program (F5)
Save your program as Calculator
Input a number and press enter then input another number and press enter.
What happens? Are there any errors?
Green Task
You are now going to create an option for the user to choose which operator they use to make the calculation. The computer does not have a symbol for some of the operators (divide and times) so they use different symbols:
Addition = +
Minus = -
Multiply = *
Divide = /
Add to your Calculator code using the code below
Run the program (F5)
What happens? Are there any errors?
Using your knowledge from your previous codes, add more code to make the program choose multiply or divide.
Start your coding where it says #HERE (Delete this line of code)
Tips:
Use the code from the amber task to help you
Use a partner to help with any error checking
You will need 4 more lines of code
Don’t forget to test your code by running your program (F5)
Extension:
Go to codecademy.com and sign up using google
Plenary:
Add a snip of the code and the program to your evidence document
Annotate the code to explain what it is doing
Comments
Post a Comment