Search Header Logo
Week 7 - DCS2103 (Strings)

Week 7 - DCS2103 (Strings)

Assessment

Presentation

Computers

University

Medium

Created by

Yasmin Basiran

Used 1+ times

FREE Resource

21 Slides • 16 Questions

1

media

2

media

3

Multiple Select

If you write your name on a sticky note and put it on a lunchbox, then peel it off and put it on a new lunchbox — does the old lunchbox magically change into the new one?

1

Yes

2

No

4

media

5

media

6

media

7

media

8

media

9

media

10

media

11

media

12

Draw

Draw the string "HELLO" as a row of boxes. Label positive indexes on top (0 to 4) and negative indexes on the bottom (-5 to -1).

13

Multiple Choice

What will "Python"[0] return?

1
0
2
Python
3
P
4
N

14

Multiple Choice

What happens if you try to access "hello"[10]?

1

Error

2

None

3

o

4

" "

15

Multiple Choice

What is the result of "Python"[1:4]?

1
Python
2
Pytho
3
ythn
4
yth

16

Multiple Choice

Which code prints "Pto"?

1

"Python"[::2]

2

"Python"[1:5:2]

3

"Python"[2::2]

4

"Python"[::3]

17

media

18

media

19

media

20

media

21

media

22

Multiple Choice

Which method makes the first letter uppercase and the rest lowercase?

1

upper()

2

capitalize()

3

title()

4

swapcase()

23

Multiple Choice

What will "hello world".title() return?

1

Hello world

2

Hello World

3

HELLO WORLD

4

hello world

24

Multiple Choice

Output of "banana".count("a") is:

1
2
2
4
3
5
4
3

25

Multiple Choice

What does "hello".find("l") return?

1
2
2
3
3
1
4
-1

26

Multiple Choice

What will "apple,banana,cherry".split(",") return?

1
['banana', 'cherry']
2
['apple', 'banana']
3
['apple', 'banana', 'cherry']
4
['apple', 'cherry']

27

Multiple Choice

What will "-".join(["2025", "09", "23"]) return?

1
23-09-2025
2
2025/09/23
3
2025.09.23
4
2025-09-23

28

media

29

media

30

media

31

media

32

media

33

Multiple Choice

Which statement about Python strings is TRUE?

1

Strings are mutable.

2

Strings can be modified in-place.

3

Strings are immutable.

4

Strings are stored as arrays.

34

Multiple Choice

What happens when two variables are assigned the same short string in Python?

1
Both variables create separate string objects.
2
The first variable is deleted from memory.
3
Both variables reference the same string object in memory.
4
The second variable cannot be assigned a string.

35

Open Ended

Imagine you are writing a password checker. How could you use isalpha(), isdigit(), and isupper() to validate a user’s password?

36

Open Ended

How would you clean and format this input string: " PYTHON is Fun! " so that it becomes "Python Is Fun!"? Which string methods would you use?

37

Thank you!

media

Show answer

Auto Play

Slide 1 / 37

SLIDE