wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Programming_Grade11_Term3_Week02

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

text = "Hello, World!"

# What does the following code do?

result = text.lower()

a)

Converts text to uppercase

b)

Converts text to lowercase

c)

Reverses the text

d)

Removes whitespace

e)

Extracts the first word

2.

numbers = [1, 2, 3, 4, 5]

# What does the following code do?

result = sum(numbers)

a)

Finds the product of the numbers

b)

Calculates the average of the numbers

c)

Finds the maximum value in the list

d)

Finds the sum of the numbers

e)

Sorts the list in ascending order

3.

text = "Python Programming"

# What does the following code do?

result = text.split()

a)

Joins the words with a comma

b)

Reverses the words

c)

Splits the text into a list of words

d)

Removes spaces

e)

Converts the text to uppercase

4.

numbers = [2, 4, 6, 8, 10]

# What does the following code do?

result = [num * 2 for num in numbers]

a)

Adds 2 to each element

b)

Multiplies each element by 2

c)

Removes even numbers

d)

Finds the square of each element

e)

Appends 2 to the list

5.

text = "Data Science"

# What does the following code do?

result = text.replace("Science", "Analysis")

a)

Appends "Analysis" to the text

b)

Replaces "Science" with "Analysis"

c)

Removes "Data"

d)

Converts to uppercase

e)

Swaps "Data" and "Science"

6.

numbers = [3, 7, 1, 9, 4]

# What does the following code do?

result = sorted(numbers)

a)

Reverses the list

b)

Finds the maximum value

c)

Sorts the list in ascending order

d)

Finds the sum of the numbers

e)

Removes duplicates

7.

text = "Learning Python is fun!"

# What does the following code do?

result = len(text)

a)

Finds the number of words

b)

Counts the number of vowels

c)

Finds the length of the text

d)

Reverses the text

e)

Removes spaces

8.

numbers = [5, 2, 8, 1, 6]

# What does the following code do?

result = max(numbers)

a)

Finds the minimum value

b)

Calculates the average

c)

Finds the sum of the numbers

d)

Finds the maximum value

e)

Sorts the list in descending order

9.

text = "Astana-2024"

# What does the following code do?

result = text.split("-")

a)

Removes spaces

b)

Joins the words

c)

Splits the text into a list using "-" as the delimiter

d)

Reverses the text

e)

Converts to lowercase

10.

numbers = [10, 5, 8, 3, 12]

# What does the following code do?

result = [num for num in numbers if num % 2 == 0]

a)

Removes odd numbers

b)

Doubles each element

c)

Finds the maximum value

d)

Sorts the list in ascending order

e)

Appends 2 to the list