Www.teachingcomputing.com Mastering Programming in Python Lesson 1.

Slides:



Advertisements
Similar presentations
Module 6: Introduction to C Language ITEI102 Introduction to Programming Structure of C++ Program - Programming Terminologies - Microsoft Visual Studio.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
101.  Computers DO NOT think for themselves. For them to do anything they need to be told what to do.  Simply put computer programming is when you tell.
Some computer fundamentals and jargon Memory: Basic element is a bit – value = 0 or 1 Collection of “n” bits is a “byte” Collection of several bytes is.
Creating a Program In today’s lesson we will look at: what programming is different types of programs how we create a program installing an IDE to get.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Pseudocode and Algorithms
1 Lab Session-IV CSIT-120 Spring 2001 Lab 3 Revision and Exercises Rev: Precedence Rules Lab Exercise 4-A Machine Language Programming The “Micro” Machine.
Introduction to a Programming Environment
Chapter 3 Planning Your Solution
Lesson 3 Variables – How our Brains Work - Variables in Python.
Do Now Noticing skills What does input do?. Annotate your code to explain what happens name = input( “What is your name?\n” ) print(“Hello ”, name) Extension-Python.
Introduction to Python Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
Startup – Chapter 1.
An Introduction to Textual Programming
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Higher Grade Computing Studies 2. Languages and Environments Higher Computing Software Development S. McCrossan 1 Classification of Languages 1. Procedural.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 1: Introduction to Python Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
By the end of this session you should be able to...
Lesson 4 Using Variables in Python – Creating a Simple ChatBot Program.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
My Python Programmes NAME:.
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
ALAN….ALAN… ALAN. WHO IS ALAN TURING?
CSC 1010 Programming for All Lecture 1 Some material courtesy of Python for Informatics: Exploring Information (
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
GCSE Computing: Programming GCSE Programming Remembering Python.
Mastering Programming in Python Lesson 3(b) All you need to know about FOR LOOPS.
Chapter 1: Introduction to Computers and Programming.
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.
Getting Started With Python Brendan Routledge
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
GCSE COMPUTER SCIENCE Practical Programming using Python Lesson 4 - Selection.
Computers and Programming
Development Environment
GCSE COMPUTER SCIENCE Practical Programming using Python
what is computer programming?
Whatcha doin'? Aims: To start using Python. To understand loops.
Week 3 - Wednesday CS 113.
GCSE COMPUTER SCIENCE Practical Programming using Python
Lesson 1 - Sequencing.
Introducing Instructions
GCSE COMPUTER SCIENCE Practical Programming using Python
Lesson 02: Introduction to Python
Lesson 1 An Introduction
Variables, Expressions, and IO
Introduction to Programmng in Python
Learning to Program in Python
Learning to Program in Python
Introduction to Python
Fill the screen challenge!
Topics Introduction to File Input and Output
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
Language Basics.
Section 1 Introduction To Programming
Welcome to AP Computer Science A!
12th Computer Science – Unit 5
Introduction to Python
Topics Introduction to File Input and Output
CMPT 120 Lecture 3 - Introduction to Computing Science – Programming language, Variables, Strings, Lists and Modules.
Hardware is… Software is…
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Mastering Programming in Python Lesson 1

Lesson 1: Introduction to the language, SEQUENCE variables, create a Chat bot Lesson 2: Introduction SELECTION (if else statements) Lesson 3: Introducing ITERATION (loops) Lesson 4: Use of Functions/Modular Programming Lesson 5: Introducing Lists /Operations/List comprehension Lesson 6: Use of Dictionaries Lesson 7: String Manipulation Lesson 8: File Handling – Reading and writing to CSV Files Lesson 9: Importing and Exporting Files Lesson 10: Transversing, Enumeration, Zip Merging Lesson 11: Recursion Lesson 12: Project 1 Lesson 13 Project 2 Lesson 14: Project 3 Lesson 15: Consolidation of all your skills – useful resources Series Overview *Please note that each lesson is not bound to a specific time (so it can be taken at your own pace) Information/Theory/Discuss Task (Code provided) Challenge (DIY!) Suggested Project/HW COMING SOON

In this lesson you will …  create your very own chat bot in Python!  learn about variables, sequence, programs, Alan Turing and Artificial Intelligence  Challenge yourself to see if you can extend your code! *For this series we assume students know how to open, save and run a python module. Version: Python 3

Did you know? Guido van Rossum, the guy on the right, created python! He is a Dutch computer programmer and completed his degree in the university of Amsterdam He was employed by Google from 2005 until December 2012, where much of his time was spent developing the Python language. In 2013, Van Rossum started working for Dropbox. Python is intended to be a highly readable language. It has a relatively uncluttered visual layout, frequently using English keywords where other languages use punctuation. Guido van Rossum, the creator of Python An important goal of the Python developers is making Python fun to use. This is reflected in the origin of the name which comes from Monty Python

Getting started for the absolute beginner Skip this if you have already installed python We have downloaded Python You can read more about the difference between Python 2 and 3 on the site.

Getting started for the absolute beginner Visit the following site to download python. The version we use in these tutorials is: Python Visit the following site to download python. The version we use in these tutorials is: Python Once you’ve followed the instructions and have python on your computer, create a short cut on your desktop (if possible). Open the IDLE SHELL and create a new file (module) see screenshot on the right. You are ready to start programming in python, Remember to save all files with the ending“.py” You are ready to start programming in python, Remember to save all files with the ending“.py” Skip this if you have already installed python

What is a program anyway? Many algorithms (in our brain) are inbuilt We eat, drink, speak, respond and appear to have been pre-programmed to do so. There is ‘Free will’ too, but that’s a more philosophical discussion. DEFINITION: Algorithm = sequence of instructions which performs a meaningful task Many algorithms (in our brain) are inbuilt We eat, drink, speak, respond and appear to have been pre-programmed to do so. There is ‘Free will’ too, but that’s a more philosophical discussion. DEFINITION: Algorithm = sequence of instructions which performs a meaningful task The very simplest definition is that: a program is just a sequence of instructions. Each of your cells contains what we call the DNA CODE.

Interesting facts about DNA Code The letters of the genetic alphabet – A, T, G, and C – are meaningless on their own, but they are combined into useful instructions in genes. The DNA code in your cells is like a library of instructions. It is probably the most complex code we have ever come across. Is a programmer behind it?

The anatomy of a typical program You can think of any program or system as being comprised of these three parts: Think about your very own brain: We don’t often realize it but our brains are pretty awesome. The brain is storing values and processing data (as well as producing outputs) all the time. Ever wondered how a lump of flesh (your brain) stores data?! INPUT – PROCESSING - OUTPUT Inputs need to be stored, and that’s what we are looking at in this first lesson. In Computing, we need VARIABLES to store inputs

15 47 Number 1 Number 2 Consider the following example: By simply looking at the screen, your brain has now STORED these two values. But how do we get a programming language to ‘remember’ values? The key word you need to remember is VARIABLE (or identifier)

Variable Name: NumberToStore FirstName 47 Joe A useful analogy … Variables are like storage boxes that can hold or store values in them. In programming, we need to DECLARE Variables, also called Identifiers Numbertostore = 47 Firstname = “Joe” In programming, we need to DECLARE Variables, also called Identifiers Numbertostore = 47 Firstname = “Joe”

Task 1: Creating a Chat Bot using variables 1.Open a Python Module 2.Copy and paste the code on the right into the module 3.Run the program to see what it does 4.See if you can add additional variables to make it do more! 1.Open a Python Module 2.Copy and paste the code on the right into the module 3.Run the program to see what it does 4.See if you can add additional variables to make it do more! #This is a chatbot and this is a comment, not executed by the program #Extend it to make the computer ask for your favourite movie and respond accordingly! print('Hello this is your computer...what is your favourite number?') #Declaring our first variable below called 'computerfavnumber' and storing the value 33 computerfavnumber=33 #We now declare a variable but set the variable to hold whatever the *user* inputs into the program favnumber=input() print(favnumber + '...is a very nice number indeed. So...what is your name?') name=input() print('what a lovely name: ' + name + '...now, I will reveal what my favourite number is:') print (computerfavnumber)

Online chat bots you can check out! Try chatting with these bots. Can you tell you are not talking to a ‘real’ person. How do you know? How could the program be improved?

Artificial Intelligence and the Turing Test The Turing test is a test, developed by Alan Turing in 1950, of a machine's ability to exhibit intelligent behaviour equivalent to, or indistinguishable from, that of a human. A picture of the young Alan Turing If you were chatting with a computer would you be able to tell the difference between it and a real human being? How? What makes us different? Will computers ever truly think? If you were chatting with a computer would you be able to tell the difference between it and a real human being? How? What makes us different? Will computers ever truly think?

Recent Developments in AI You may find Wikipedia’s timeline of AI interesting reading (see link below) Google’s artificial intelligence (AI) software has been developed to the point that it is ready to go head to head with the world’s highest ranked GO player. This is seen as a pivotal moment for AI, similar to IBM’s DEEP BLUE beating Gary Kasparov at chess!

Challenge: Extend the code and get someone to try out your program! Here are some suggestions, but get creative and implement your own ideas! 1.Get the computer to ask the user what his/her favourite movie is and then respond 2.Declare a few other integer variables and carry out an addition! 3.Ask the user for their height in feet and inches and convert it into metres. 4.What else will you do!? Here are some suggestions, but get creative and implement your own ideas! 1.Get the computer to ask the user what his/her favourite movie is and then respond 2.Declare a few other integer variables and carry out an addition! 3.Ask the user for their height in feet and inches and convert it into metres. 4.What else will you do!? #This is a chatbot and this is a comment, not executed by the program #Extend it to make the computer ask for your favourite movie and respond accordingly! print('Hello this is your computer...what is your favourite number?') #Declaring our first variable below called 'computerfavnumber' and storing the value 33 computerfavnumber=33 #We now declare a variable but set the variable to hold whatever the *user* inputs into the program favnumber=input() print(favnumber + '...is a very nice number indeed. So...what is your name?') name=input() print('what a lovely name: ' + name + '...now, I will reveal what my favourite number is:') print (computerfavnumber)

More on data types/variables in Python Python has five standard data types (that can be declared)  NUMBERS  STRING  LIST  TUPLE  DICTIONARY In this lesson you can primarily focus on declaring numbers and strings. Counter = 100 ‘An integer assignment Pounds = ‘A floating point Name = “Joe Bloggs” ‘ A string Python has five standard data types (that can be declared)  NUMBERS  STRING  LIST  TUPLE  DICTIONARY In this lesson you can primarily focus on declaring numbers and strings. Counter = 100 ‘An integer assignment Pounds = ‘A floating point Name = “Joe Bloggs” ‘ A string Here are some examples of numbers Intlong floatcomplex Here are some examples of numbers Intlong floatcomplex Python has four standard data types (that can be declared)  INT (signed integers)  LONG (long integers also represented in hex or octal)  FLOAT (floating point real numbers)  COMPLEX (complex numbers) Python has four standard data types (that can be declared)  INT (signed integers)  LONG (long integers also represented in hex or octal)  FLOAT (floating point real numbers)  COMPLEX (complex numbers)

Useful Videos to watch on covered topics Exploring Artificial Intelligence today Recommended video on Python Variables

Suggested Project / HW / Research  Create a research information point on Alan Turing.  Basic facts about him  Achievements  Turing Test  His involvement in code breaking at Bletchley park  High level languages use variables as memory locations –but how does a computer, at its very lowest level (Binary 1s and 0s) store information? Write a short essay, based on your research, to explain how computers store  Numbers  Text  Images  Sound/Video  Create a research information point on Alan Turing.  Basic facts about him  Achievements  Turing Test  His involvement in code breaking at Bletchley park  High level languages use variables as memory locations –but how does a computer, at its very lowest level (Binary 1s and 0s) store information? Write a short essay, based on your research, to explain how computers store  Numbers  Text  Images  Sound/Video

Useful links and additional reading