Search Header Logo
AQA String Manipulation

AQA String Manipulation

Assessment

Presentation

Computers

10th Grade

Practice Problem

Easy

Created by

Roy Duguid

Used 4+ times

FREE Resource

26 Slides • 14 Questions

1

String Manipulation

2

media

3

media

4

media

5

media

6

media

7

media

8

media

9

media

10

media

11

media

12

​String Concatenation

  • The + operator does not just add two numbers

  • It can also “add” two strings

  • The process of combining two strings is called string concatenation

  • Performing string concatenation creates a brand new string comprised of the first string’s contents followed by the second string’s contents

13

media

14

​String Concatenation

  • The + operator does not just add two numbers

  • It can also “add” two strings

  • The process of combining two strings is called string concatenation

  • Performing string concatenation creates a brand new string comprised of the first string’s contents followed by the second string’s contents

media
media

​Concatenation does not include spaces between the strings!

15

media

​Finding position

16

Casting

There may be times when you want to specify a type on to a variable. This can be done with casting.

  • int() - constructs an integer number from an integer literal, a float literal (by removing all decimals), or a string literal (providing the string represents a whole number)

  • float() - constructs a float number from an integer literal, a float literal or a string literal (providing the string represents a float or an integer)

  • str() - constructs a string from a wide variety of data types, including strings, integer literals and float literals

17

Multiple Choice

What is concatenation in python?

1
Concatenation in Python refers to the method of converting strings to integers.
2
Concatenation in Python is the process of combining strings using the '+' operator.
3
Concatenation in Python is the process of splitting strings using the '-' operator.
4
Concatenation in Python is the technique of reversing strings using the '*' operator.

18

Multiple Choice

What is casting in python?

1
Casting is a method for defining functions in Python.
2
Casting in Python is the process of converting one data type to another.
3
Casting refers to the process of creating new data types in Python.
4
Casting is a way to optimize memory usage in Python.

19

Multiple Choice

What is a substring / slicing in python?

1
Extracting a character from a string using string[index]
2
Substring or slicing in Python is the process of extracting a portion of a string using the syntax string[start:end].
3
Replacing a portion of a string with another string
4
Finding the length of a string using len(string)

20

media

​Python - String Length example

21

Multiple Choice

Question image

What will the output of this code be?

1

5

2
5
3
8
4
6
5

7

22

Concatenation

media

23

Multiple Choice

Question image

what do we call what is happening on line 4?

1

concatenation

2
Variable assignment
3
Array declaration
4

interpolation

24

Multiple Choice

Question image

What will output from this code?

1
ABC123XYZ
2
XYZ123
3
XYZ123ABC
4
123ABCXYZ

25

Multiple Choice

Question image

What will output from this code?

1
XYZABC123
2
XYZ123ABC
3
ABCXYZ123
4
123XYZABC

26

media

​​Casting

27

media

28

media

29

media

30

​Checking if a string is all digits

media
media

31

Convert character to character code + convert character code to character

media

32

media

​Substring / Slicing

33

Multiple Choice

Which will change the python input to lower case?

1
user_input.toLowerCase()
2
user_input.lowercase()
3
user_input.lower()
4
user_input.make_lower()

34

Multiple Choice

Which will change the python input to upper case?

1
input_string.title()
2
input_string.lower()
3
input_string.capitalize()
4
input_string.upper()

35

Multiple Choice

The pseudocode below assigns two strings to two variables:

title = "computer science"

level = "gcse"

What is title[0]?

1

'c'

2

'o'

3

'g'

4

An error

36

Multiple Choice

The pseudocode below assigns two strings to two variables:

title = "computer science"

level = "gcse"

What is title[4]?

1

'p'

2

'u'

3

't'

4

An error

37

Multiple Choice

The pseudocode below assigns two strings to two variables:

title = "computer science"

level = "gcse"

What is level concatenated (linked together) with title?

1

"gcsecomputer science"

2

"gcse computer science"

3

"gcsecomputerscience"

4

An error

38

Multiple Choice

Question image

What is will the output be of this code?

1
None
2
Error
3
False
4
True

39

Multiple Choice

Question image

What will the output of this code be?

1
True
2
Error
3
False
4
None

40

Teams > Activity 1

String Manipulation

Show answer

Auto Play

Slide 1 / 40

SLIDE