Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 8 Fruitful Functions 05/02/09 Python Mini-Course: Day 2 - Lesson 8 1.
While Loops. Challenge: ● Ask the user a simple math questions ● Continue asking the question until the user gets it right.
Programming TBE 540 Farah Fisher. Objectives After viewing this presentation, the learner will be able to… Given a task, create pseudocode Given pseudocode,
 Caesar used to encrypt his messages using a very simple algorithm, which could be easily decrypted if you know the key.  He would take each letter.
Programming in python Lesson 2.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
V Avon High School Tech Club Agenda Old Business –Delete Files New Business –Week 16 Topics: Intro to HTML/CSS –Questions? Tech Club Forums.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
An Introduction to Textual Programming
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Python Programming Using Variables and input. Objectives We’re learning to make use of if statements to enable code to ask questions. Outcomes Build an.
Iteration. Adding CDs to Vic Stack In many of the programs you write, you would like to have a CD on the stack before the program runs. To do this, you.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
While Loops Indefinite Iteration. Last lesson we looked at definite loops using the ‘For’ statement. The while loop keeps going while some condition is.
 Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends.
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
A Simple Quiz: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011.
PROGRAMMING In Lesson 2. STARTER ACTIVITY Complete the starter activity in your python folder – lesson 2 Now we will see how you got on and update your.
Python Programming Using Variables and input. Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue.
I Power Higher Computing Software Development High Level Language Constructs.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Iteration. Iteration: Review  If you wanted to display all the numbers from 1 to 1000, you wouldn’t want to do this, would you? Start display 1 display.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
GCSE Computing: Programming GCSE Programming Remembering Python.
BO65: PROGRAMMING ITERATION 1. Starter  Write down what you think the code below outputs on screen: Dim intCounter as integer intCounter = 0 Do while.
Control Structures WHILE Statement Looping. S E Q C E N U E REPITITION …a step or sequence of steps that are repeated until some condition is satisfied.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
Conditionals.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
Whatcha doin'? Aims: To start using Python. To understand loops.
A Simple Quiz for Alice 3.2:
Introduction to Python
Introducing Instructions
Introduction to Python
ECS10 10/10
IF statements.
Programming 101 Programming for non-programmers.
Learning to Program in Python
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
Learning to Program in Python
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Selection CIS 40 – Introduction to Programming in Python
A Simple Quiz for Alice 3.2:
Coding Concepts (Basics)
Introduction to TouchDevelop
Module 4 Loops.
Simple Encryption- Lesson 5
A look at Python Programming Language 2018.
Programming In Lesson 4.
Beginning Python Programming
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
While Loops in Python.
Iteration – While Loops
Presentation transcript:

Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax A Simple Calculator Guess the Number Fantastic Functions Secret Messages Adventure Game Python Magic

Why should we learn to program? YouTube video to go here.

Basic Python Syntax

Understand and be able to use basic Python syntax.

VARIABLES The way we store data. String – a type of variable for storing text “strings”.

Enter the code shown here to create your first computer program.

Now let’s add to that . . .

What do you think this will do?

YOUR TASK Add to your program so you can have a conversation with the computer (stick to yes and no answers for now!)

Create an account at www.codecademy.com NEXT TASK Create an account at www.codecademy.com Complete the first Python course called ‘Python Syntax’

Understand and be able to use basic Python syntax. or

Calculator

Understand how to use selection to create a simple calculator.

VARIABLES String – remember this from last lesson? Numbers: Integer Float

What’s happening here ?

How we choose a suitable action based on a condition. SELECTION How we choose a suitable action based on a condition. IF I’m hungry Eat Something ELSE Don’t eat anything

Can you add more selection to handle multiplication and division ?

Log onto www.codecademy.com NEXT TASK Log onto www.codecademy.com and continue the Python course from where you finished last lesson.

Understand how to use selection to create a simple calculator.

Loopy Loops

Understand how to create a loop in Python and use a Boolean variable to define when to stop.

ANOTHER VARIABLE Boolean – This can store one of two values: True False

LOOPS A While loop can keep looping through events until a condition changes. WHILE hungry == True Keep eating IF I’m full up hungry == False

Have a go at this ‘Guess the Number’ game. What does each part do?

Understand how to create a loop in Python and use a Boolean variable to define when to stop. or

Fantastic Functions

Understand how to use and call functions.

WHAT IS A FUNCTION? A block of code grouped together that can be run at any point in our program.

Try creating this function to pull a rabbit from a hat Try creating this function to pull a rabbit from a hat! Don’t forget the magic word though!

Try out this function. What does that bit in brackets do?

YOUR CHALLENGE Add to your program so it tells the user whether or not their word is a palindrome. Hint: try using an if statement to compare the original word with the reversed word.

You should have added something like this to the end of your program.

Log onto www.codecademy.com NEXT TASK Log onto www.codecademy.com and continue the Python course from where you finished last lesson.

Secret Messages

Understand how to store and look up values from a list.

(Also known as an array) LIST (Also known as an array) A way of storing more than one thing under one variable name. My magic potion contains hair, knotgrass and leeches.

Here’s a list of students. What will each print statement do?

Another way to add items is using the ‘append’ command Another way to add items is using the ‘append’ command. Use this to add some more students. Make sure you print your list of students again to make sure your code has worked!

For example, a shift of 2 means “A” becomes “C”: CAESAR SHIFT A well-known cipher to encode a piece of text by replacing one letter of the alphabet with another a chosen number of places (shifts). For example, a shift of 2 means “A” becomes “C”: A B C D E F G H I K L. . .

Cut out and make your own Caesar Cipher Wheel using your worksheet. TASK Cut out and make your own Caesar Cipher Wheel using your worksheet. Use your wheel to create a secret message for the person next to you to decode.

Can you decode this secret message? s vyfo mywzedob zbyqbkwwsxq Are there any clues to help us work out the shift number? Clue – how many words have only one letter? This should narrow down the choices.

Create your own encryption program and test it out. What is happening here? Create your own encryption program and test it out. EXTENSION – new program to decode a secret message.

Text Adventures

Recognise how a class can be used to create custom objects.

A custom object that you can make that has it’s own set of attributes. CLASSES A custom object that you can make that has it’s own set of attributes.

Animal Class Giraffe Horse Lion

Open and look at the Animals.py example from SharePoint. TASK Open and look at the Animals.py example from SharePoint. Can you figure out what some of the bits of code are doing?

Underneath the class create a new ‘instance’ of an animal and give it some attributes. You can choose any animal you like.

TASK Use the design sheet to plan your own text adventure then follow the instructions to create this in Python.

Recognise how a class can be used to create custom objects.