Search Header Logo
Intro Python Y9

Intro Python Y9

Assessment

Presentation

•

Computers

•

9th Grade

•

Medium

Created by

Shaw Williams

Used 4+ times

FREE Resource

9 Slides • 6 Questions

1

Intro Python Y9

Mr. Williams

2

​Examples of Variables

​The following are examples of ACCEPTABLE variable names:

​

  • ​apples, car, costs

  • b8, a12, z1000

​

​The following are example of NOT ACCEPTABLE variable names:

​

  • ​1, 100, 3000, 22, 14 (a variable can not start with a number)

  • ​print, input, def (these are keywords used within python)

3

​Variables

​Part of a program that can be assigned a specific value

​

  • ​Made up of two parts; an identifier, and a value.

  • ​This value CAN change while the program is running.

4

​Constant

​Part of a program that can be assigned a specific value

​

  • ​Made up of two parts; an identifier and a value.

  • ​This value can NOT change while the program is running.

5

Multiple Choice

Question image

What is the name of the 'Variable' in this example Python code

1

name

2

input

3

print

4

("What is your name")

6

​Commenting your code

​It's important to comment your code often.

​

​When commenting code, use the symbol # followed by your comment

7

Multiple Select

Question image

Why is it important that we use comments in our code?

1

They help the program run smoothly

2

So that we understand what the line of code does

3

To help other programmers understand our code

4

To fill our code with colours

8

​Variable names

​Variable names are limited to certain characters when they are defined in your code. Using incorrect Variable names will result in your code displaying the error:

​

​"Syntax Error: invalid syntax"

9

Multiple Select

Which of the following are acceptable Variable names

1

horse

2

x

3

3

4

x4

10

​Variable Types

All data in Python is represented by 'objects' or the relationship between 'objects'.

​

​Every object has three things:

  • ​An 'identity'

  • ​A 'type'

  • ​A 'Value'

​

​An objects 'identity' never changes once it has been created - it is forever saved in the Python's memory.

11

​Variable Types continued..

An object's type determines what operations that it supports, for example:

  • ​Does it have a length? which then defines the possible values for objects of that type.

​

​The type() function returns an object's type (which is an object itself)

​Just like an object's 'identity', an object's type is also unchangeable.

​

The values of some objects can change though...

12

Multiple Choice

Objects who value is unchangeable once they are created are called...

1

Immutable

2

Mutable

3

Defined

4

Undefined

13

Multiple Choice

Question image

When this Python code is run what will it display?

1

<class = 'int'>

2

<class = 'float'>

3

<class = 'int'>

<class = 'float'>

4

9

9.0

14

Type conversion​

​There are several built-in functions that let you convert one data type into another. These functions return a new object representing the converted value, such as:

​

  • ​int(x) which converts x into an integer

  • ​float(x) which converts x into a floating-point number

  • ​str(x) which converts x into a string representation

15

Multiple Choice

Question image

What would you type to covert the float number to an integer?

1

print(type(float_number)

2

print(float_number)

3

print(int(float_number)

4

print(number)

pattern-tertiary
Intro Python Y9

Mr. Williams

Show answer

Auto Play

Slide 1 / 15

SLIDE