GCSE Computing Lesson 6.

Slides:



Advertisements
Similar presentations
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Advertisements

Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 7: Program flow control.
Introduction to Python and programming Michael Ernst UW CSE 190p Summer 2012.
An Introduction to Textual Programming
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Java Data Types. Primitive Data Types Java has 8 primitive data types: – char: used to store a single character eg. G – boolean: used to store true or.
Logical or Boolean Data stored in Boolean form can only be one of two available values. Think of a light switch – it’s on or off. Examples include: YES.
Module 3 Fraser High School. Module 3 – Loops and Booleans import statements - random use the random.randint() function use while loop write conditional.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Variables and Functions. Open your Encoder program Let’s begin by opening the “Labyrinth Auto Straight” code. Save this file as Labyrinth with variables.
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Python Programming Using Variables and input. Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue.
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Basic Java Syntax Comments Basic data types Operators and assignment.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
GCSE Computing: Programming GCSE Programming Remembering Python.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 3: Built-in functions.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
Input, Output and Variables GCSE Computer Science – Python.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Trace Tables In today’s lesson we will look at:
Numbers and arithmetic
Unit 2 Technology Systems
Lesson 03: Variables and Types
Week 2 - Wednesday CS 121.
Numbers and Arithmetic
Whatcha doin'? Aims: To start using Python. To understand loops.
Chapter 2 Basic Computation
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
A basic tutorial for fundamental concepts
Introduction to Python
Data Types and Conversions, Input from the Keyboard
ECS10 10/10
Variables and Primative Types
Computer Science 3 Hobart College
Introduction to C++ October 2, 2017.
Variables, Printing and if-statements
Type Conversion, Constants, and the String Object
Computational Thinking
Computational Thinking
Thinking about programming
Chapter 2.
Lesson 1 Learning Objectives
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Lesson 2: Building Blocks of Programming
Using variables, for..loop and functions to help organize your code
Winter 2018 CISC101 11/22/2018 CISC101 Reminders
Functions and Procedures
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Variables Title slide variables.
Margaret Derrington KCL Easter 2014
Coding Concepts (Data- Types)
Feedback Pace Different ideas for delivery Debugging strategies
Lesson 03: Variables and Types
Variables In today’s lesson we will look at: what a variable is
Thinking about programming
Thinking about 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.
Class code for pythonroom.com cchsp2cs
More Basics of Python Common types of data we will work with
Variables and Constants
Presentation transcript:

GCSE Computing Lesson 6

Python 3.3 Objectives. In this lesson students will learn more about the data types that variables can be. Students will also learn the important distinction between them and where they should be used.

Python 3.3 Comments Try this program: #This is a comment print("This is not a comment.") What happened?

Python 3.3 Inline Comments You can include a comment at the end of a line of code. But not the start: #This is a comment #This is also a comment. It won't print(“anything”) print("This is not a comment.") #although this is...

Python 3.3 Block Comments Sometimes you might want to have a large block for a comment. This is often the case at the start of programs where programmers put useful information such as who wrote it, when and what it is supposed to do. Try to guess what the output will look like: #This is a comment #This is also a comment. It won't print(anything) print("This is not a comment.") #although this is... """ These are all comments print("But the comments are finished now.")

Python 3.3 Strings Adding Strings A string is a block of text. It could be a single word, a sentence or an entire paragraph. In Python we use the term “str” to mean a string. Try out the following code: start = "Hello, " name = input("What is your name? ") end = ". How are you today?" sentence = start + name + end print(sentence)

Python 3.3 Strings Line Breaks / New Lines You can also write your string over several lines by using “\n”. Like this: firstLine = "I got a feeling,\nThat tonight's gonna be a good night.\n" secondLine = "That tonight's gonna be a good, good night." print(firstLine + secondLine)

Python 3.3 Numbers Integers There are two main types of numbers in Python. We’ll start with Integers (whole numbers). We can force Python to make something a whole number by saying int(number). Like this: number = 3.7 newNumber = int(number) print(newNumber)

Python 3.3 Numbers Floats The second main type is a floating point, or just “float” for short (a decimal). We can force Python to make something a float by saying float(number). Like this: number = 3 print(number) newNumber = float(number) print(newNumber)

Python 3.3 Numbers Casting Casting is the technical term for changing the type of data you are working with. You’ve already been casting by saying int(), float() and str() to change the data type. But now you know what it’s called! 2.3d - Automatic Casting Python will automatically change the data type for you a lot of the time: x = int(22) y = int(7) z = x/y print(z) Here, the two integers have provided a floating point answer and Python has changed the data type of z for you.

Python 3.3 Numbers Long Another number type you might need occasionally is long, or a long integer. Integers in Python can only hold numbers from -2billion to +2billion (actually from -2,147,483,646 to +2,147,483,647). If your number is going to be outside that range then you will have to use a long to keep count.

Python 3.3 2.4 Boolean True or False? A boolean (bool for short) can store one of only two possible values - True or False. (NB: Note the capital letters!) This is useful for logical tests (e.g. is 22/7 bigger than 3?) or to check if something has been completed useful in section 3). Here is an example: bigger = False print(bigger) if (22/7 > 3): bigger = True

Python 3.3 Task Answer the questions on Python Worksheet 2