wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Basic Programming Quiz

Total questions: 27

Worksheet time: 14mins

Name
Class
Date
1.

What is a string?

a)

A type of list

b)

A programming language

c)

A collection of numbers

d)

A collection of characters

2.

How can you write a string?

a)

Using brackets

b)

Using single or double quotes

c)

Using curly braces

d)

Using angle brackets

3.

What does print(text[0]) return if text = 'Python'?

a)

P

b)

n

c)

y

d)

h

4.

What does print(text[-1]) return if text = 'Python'?

a)

P

b)

y

c)

n

d)

h

5.

What is the output of print(text[0:6]) if text = 'PythonProgramming'?

a)

P

b)

Pytho

c)

Programming

d)

Python

6.

What function do you use to find the length of a string?

a)

len()

b)

count()

c)

length()

d)

size()

7.

What does the method upper() do?

a)

Makes text uppercase

b)

Makes text lowercase

c)

Counts letters

d)

Removes spaces

8.

What is a list?

a)

A collection of characters

b)

A programming function

c)

A type of string

d)

A collection of multiple values

9.

How do you create a list of numbers?

a)

numbers = (1, 2, 3, 4)

b)

numbers = [1, 2, 3, 4]

c)

numbers = {1, 2, 3, 4}

d)

numbers = '1, 2, 3, 4'

10.

What does print(names[0]) return if names = ['Abhishek', 'Ravi', 'Amit']?

a)

Ravi

b)

Amit

c)

None

d)

Abhishek

11.

What does print(nums[1:4]) return if nums = [10, 20, 30, 40, 50]?

a)

[20, 30, 40]

b)

[30, 40, 50]

c)

[10, 30, 50]

d)

[10, 20, 30]

12.

What does the method append() do?

a)

Adds one element

b)

Removes an element

c)

Clears the list

d)

Sorts the list

13.

What does the method remove() do?

a)

Reverses the list

b)

Sorts the list

c)

Removes a value

d)

Adds an element

14.

What does the method pop() do?

a)

Removes by index

b)

Removes by value

c)

Clears the list

d)

Adds an element

15.

What does the method sort() do?

a)

Removes all elements

b)

Adds an element

c)

Sorts the list

d)

Reverses the list

16.

What is the output of print(nums[::2]) if nums = [10, 20, 30, 40, 50]?

a)

[10, 20, 30]

b)

[20, 30, 40]

c)

[10, 30, 50]

d)

[30, 40, 50]

17.

What does the method clear() do?

a)

Adds an element

b)

Sorts the list

c)

Removes all elements

d)

Reverses the list

18.

What is the first character of the string 'Python'?

a)

n

b)

t

c)

y

d)

P

19.

What does the method find() do?

a)

Finds a character

b)

Counts characters

c)

Removes spaces

d)

Replaces text

20.

What is the output of print(text[-11:]) if text = 'PythonProgramming'?

a)

Pytho

b)

Python

c)

None

d)

Programming

21.

What does the method title() do?

a)

Makes every word capital

b)

Makes text lowercase

c)

Removes spaces

d)

Counts letters

22.

What is the output of print(len('Abhishek'))?

a)

7

b)

8

c)

9

d)

10

23.

What does the method reverse() do?

a)

Reverses the list

b)

Removes all elements

c)

Sorts the list

d)

Adds an element

24.

What is the last character of the string 'Python'?

a)

n

b)

o

c)

y

d)

P

25.

What does the method replace() do?

a)

Counts characters

b)

Replaces text

c)

Finds a character

d)

Removes spaces

26.

What is the output of print(nums[:3]) if nums = [10, 20, 30, 40, 50]?

a)

[20, 30, 40]

b)

[10, 30, 50]

c)

[10, 20, 30]

d)

[30, 40, 50]

27.

What does the method count() do?

a)

Counts words

b)

Finds position

c)

Replaces text

d)

Removes spaces