How to maketh a Shakespearean fig generator in python

Slides:



Advertisements
Similar presentations
TITLE Insert a title for your stretch book project by clicking in the Title placeholder and entering text. TITLE Insert a title for your stretch book project.
Advertisements

This Week More Types boolean string Modules print statement Writing programs if statement Type boolean.
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Michael Parkes Dudley LA What can Scratch do? Make simple games, animations, presentations and stories.
Word Lesson 8 Increasing Efficiency Using Word
Introduction to TouchDevelop
Matlab tutorial course Exercises 4:. Exercises – for loops Download the scripts loops_example.m and if_else_example.m, run the code Download the function,
© by Pearson Education, Inc. All Rights Reserved.
Main task -write me a program
Word Processing Microsoft Office: Exploring Word 2011 for MAC.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Structure of program You must start with a module import# You must then encapsulate any while loop in a main function at the start of the program Then.
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
Spreadsheets in Finance and Forecasting Presentation 11 Visual Basic.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 35 – Python Outline 35.1 Introduction First Python Program Python Keywords 35.2 Basic.
Noadswood Science,  To know the basics of Python coding and decoding Monday, September 07, 2015.
South Dakota Library Network ALEPH XSL Creator © South Dakota Library Network, 2008 Modified for SDLN Version 16 Last Update: June 2008 South Dakota Library.
Spreadsheet-Based Decision Support Systems Chapter 22:
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
IE 411/511: Visual Programming for Industrial Applications
MOM! Phineas and Ferb are … Aims:
FUNCTIONS. Function call: >>> type(32) The name of the function is type. The expression in parentheses is called the argument of the function. Built-in.
PHP meets MySQL.
TECH19599 Exploring Information Technology Mobile Application Development (Control Statements)
1 CSC 221: Introduction to Programming Fall 2012 Functions & Modules  standard modules: math, random  Python documentation, help  user-defined functions,
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Introduction of Geoprocessing Topic 7a 4/10/2007.
COMP106 Assignment 2 Proposal 1. Interface Tasks My new interface design for the University library catalogue will incorporate all of the existing features,
Module 3 Fraser High School. Module 3 – Loops and Booleans import statements - random use the random.randint() function use while loop write conditional.
COMPREHENSIVE Access Tutorial 6 Using Form Tools and Creating Custom Forms.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Python Programming Graphical User Interfaces Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Computing Science 1P Lecture 17: Friday 23 rd February Simon Gay Department of Computing Science University of Glasgow 2006/07.
10.11 Data Manipulation 2 Queries. You will need… Specimen 2007 Paper 2 Task C (a PDF) q 43 Read this question carefully before you start The database.
Chapter 5: More on the Selection Structure
Graphical User Interface You will be used to using programs that have a graphical user interface (GUI). So far you have been writing programs that have.
Chapter Three The UNIX Editors.
Make a dice challenge! This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.Copy the code below in.
Lesson 3 - The Entry Box.. Last week We produced a Tkinter window with a label and a button Now we are going to create a new program that creates a Button.
Sequencing The most simple type of program uses sequencing, a set of instructions carried out one after another. Start End Display “Computer” Display “Science”
2. WRITING SIMPLE PROGRAMS Rocky K. C. Chang September 10, 2015 (Adapted from John Zelle’s slides)
Introduction to Programming and JavaScript. Programming.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Simple Clicker App WPF App using C#. App Requirement Need a ‘counter’ display, which starts at 0 Need a ‘clicker’ button ! Pressing the clicker every.
Introduction of Geoprocessing Lecture 9 3/24/2008.
Prepared by the Academic Faculty Members of IT. Tables Creating Tables. Merging Cells. Splitting Cells. Sorting Tables. Performing Calculations.
21/03/ Working with Controls Text and List Boxes.
You’ll Make a spreadsheet which will be like a Mad Libs Game. These Are The Directions.
Magic 8 ball. "Design and write a python program that emulates a Magic Eight Ball. Your program should continually prompt the user to enter a question.
Objective of the lesson Use Blockly to make a dice for Snakes and Ladders All of you will: – Make an image which displays when you press a button Most.
PYTHON PROGRAMMING Year 9. Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can.
Section 10.1 Define scripting
Recap: If, elif, else If <True condition>:
A Playful Introduction to Programming by Jason R. Briggs
Python: Experiencing IDLE, writing simple programs
Lesson 1 An Introduction
Tkinter Python User Interface
Random numbers Taken from notes by Dr. Neil Moore
Learning to Program in Python
Random Numbers In today’s lesson we will look at:
Introduction to Programming
Whatcha doin'? Aims: Begin to create GUI applications. Objectives:
Python programming exercise
Chapter 1 Introducing Small Basic
Introduction to Programming
Group Boxes, Radio buttons and Checked List Boxes
Drift and Sounder* Analytics
Presentation transcript:

How to maketh a Shakespearean fig generator in python the present day we art going to maketh a program to fig “ Thou rank milk-livered malt-worm “Thou

Objectives Reminder as to random module To understand how to use random.int and random.choice To create a dice rolling program To extend that program by using if and elif To create an shakespearean insult program using lists,two modules tkinter and random To extend the shakespearean insult program by creating a function

To start with …. Go to doddle Save the document called insult list that you have been sent Open up python and open up a new scripting area Select total of 15 Shakespearean insults Before we go onto creating our insult maker lets remind ourselves as to how th random module works

Introducing random function Before students create their Shakespearean insult generator, they need to become familiar with the random function in Python.  You are going to write an algorithm to simulate the flipping of a coin. Instruct students to type in and run the following code:

Extension task modify the code to simulate the rolling of a dice i.e. if the random function returns a 6, print the word “Six”. Hint: you might do this by using if and elif to provide choice

Code for random dice

Shakespearean insult generator (simple) what we are going to do is create a program that chooses randomly from a range of insults we have put into lists We are going to do this by reference to a module Called random and refer to it using rand.int

Step 1 Type in import random Then using the list of Shakespearean insults ,create your lists of insults in columns with [] brackets around the listed items Print “thou” is old english for “you” Referral to random module saying that choose a random insult from 1-2 in list 1 Referral to random module saying that choose a random insult from 1-2 in list 2 Referral to random module saying that choose a random insult from 1-2 in list 1

The end code should look like this And will generate a randomly selected insult from each list as above Now lets take this one step further and create a button that when you click on it generates a random insult

Extension task using tkinter module This time we are going to be using a module called tkinter that is inbuilt within python We still need to put the code in for importing it This method creates an interface and a button that when you click the button a different select of insults will appear each time We are still using the random module but this time we are referring to it using a function The function uses random.choice to select a random insult in column 1 then 2 then 3 and then display it in the interface

Create an insult giving program now we are going to use a different module called tkinter Tkinter is a module that gives you a user interface What we are going to do is 1.Import random and tkinter modules 2.create three different lists of insults 3.Then we are going to create the user interface using tkinter 4.Then the space for a button to be placed and named 5. Then using the random module we are going to generate a random insult from the three lists of insults

1.Import random and tkinter modules

2.create three different lists of Shakespearean insults From the word document that you have been given on your desks Choose 6 Shakespearean insults 2 for each column Then next to column 1- type in the first two insults then next to column 2 type in the next two insults then next to column 3 type in the next two insults So now the code for this section looks something like this

Now we need to create a function This is the start of the function def pickInsult The function is defined as pickInsult Now time to select the insults we want to combine we start with “thou” , then we add to our first random insult then our second random insult then our third random insult

3.Then we are going to create the user interface using tkinter This sets up the user interface then it names the interface then it sets a size for the interface

4.Then create the space for a button to be placed and named This code selects the label name that is being placed on the interface ,says what font to use and what size

5. Then using the random module we are going to generate a random insult from the three lists of insults

The end code should look like…

When you run it this is what it looks like