Search Header Logo
Higher SDD - Pre-defined functions

Higher SDD - Pre-defined functions

Assessment

Presentation

Computers

8th Grade

Practice Problem

Easy

Created by

G Alexander-Doyle

Used 4+ times

FREE Resource

16 Slides • 6 Questions

1

media

2

media

​Aims

  • We are learning how to use pre-defined functions with parameters in Python. Specifically, to know how to use the ORD, CHR, INT and MODULUS functions.

  • We are learning how to isolate parts of a string in Python.

Achievements (practical)

  • I can use a pre-defined function to isolate part of a string.

  • I can use the ORD pre-defined function to convert a character to its corresponding ASCII code.

  • I can use the CHR pre-defined function to convert an ASCII code into its corresponding character.

  • I can use the INT function to convert a floating-point number to an integer

  • I can use the MODULUS operator to find the remainder of a division.

3

media

4

media

5

media

6

media

7

Multiple Choice

A competition was run to suggest names for a new bridge. The 20 most popular bridge names have been identified and stored.

State the predefined function that should be used to select any one of the 20 stored bridge names as the winner.

1

length

2

random

3

round

4

square

8

Open Ended

Three candidates have received the same number of votes in an election. Their names are stored in a data structure called winners. The app uses a predefined function to pick one candidate from winners. Using a programming language of your choice, write the code that will display the name of the winning candidate.

9

media

​Answer

import random

winningIndex = (random.randint(0,2))
print(winners[winningIndex])

One mark for the following code:
random
correct parameters
random number used as winners array index

10

media

11

media

12

media

13

media

14

media

15

media

16

Fill in the Blank

What would the output be from the following line of code?

print(15%4)

17

Multiple Choice

Question image

What would the output be from this program?

1

High

2

Hig

3

igh

4

e

18

Multiple Choice

Question image

What would the output be from this program?

1

Com

2

er

3

her

4

put

19

media

20

media

21

Match

Match the following pre-defined functions.

ORD

CHR

INT

MOD

Returns the ASCII value of a character

Returns the character of an ASCII value

Returns an integer part of a real number

Returns the remainder of a divsion

22

media

​Aims

  • We are learning how to use pre-defined functions with parameters in Python. Specifically, to know how to use the ORD, CHR, INT and MODULUS functions.

  • We are learning how to isolate parts of a string in Python.

Achievements (practical)

  • I can use a pre-defined function to isolate part of a string.

  • I can use the ORD pre-defined function to convert a character to its corresponding ASCII code.

  • I can use the CHR pre-defined function to convert an ASCII code into its corresponding character.

  • I can use the INT function to convert a floating-point number to an integer

  • I can use the MODULUS operator to find the remainder of a division.

media

Show answer

Auto Play

Slide 1 / 22

SLIDE