Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics Quiz

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What is the correct way to assign a value to a variable in Python?

a)

5 = x

b)

assign x to 5

c)

x -> 5

d)

x = 5

2.

Which of the following is true about Python syntax?

a)

Python does not support comments

b)

Python ignores indentation

c)

Python variables must start with a number

d)

Python is case-sensitive

3.

What is the purpose of comments in Python?

a)

To execute code faster

b)

To create variables

c)

To describe code behavior

d)

To store data

4.

Which of the following is a valid Python list?

a)

[1, 2, 3]

b)

{1, 2, 3}

c)

1, 2, 3

d)

(1, 2, 3)

5.

What is the index of the first element in a Python list?

a)

1

b)

None

c)

0

d)

-1

6.

Which method adds a new element to the end of a list?

a)

pop()

b)

insert()

c)

remove()

d)

append()

7.

What does the remove() method do in Python lists?

a)

Removes the last element

b)

Removes a specific value

c)

Removes all elements

d)

Removes elements by index

8.

Which of the following is a string method in Python?

a)

title()

b)

append()

c)

index()

d)

remove()

9.

What does the lower() method do to a string?

a)

Converts all characters to lowercase

b)

Converts all characters to uppercase

c)

Removes spaces

d)

Reverses the string

10.

What is the purpose of a function in Python?

a)

To reuse and organize code

b)

To store data

c)

To create variables

d)

To execute loops

11.

How do you define a function in Python?

a)

Using def

b)

Using func

c)

Using function

d)

Using create

12.

What is the correct way to call a function in Python?

a)

run function_name

b)

function_name()

c)

execute function_name

d)

call function_name

13.

Which of the following is true about Python lists?

a)

Lists can store multiple values

b)

Lists are unordered

c)

Lists cannot contain strings

d)

Lists have fixed length

14.

What is the output of title() method applied to 'hello world'?

a)

World Hello

b)

hello world

c)

HELLO WORLD

d)

Hello World

15.

Which of the following is NOT a valid data type in Python?

a)

float

b)

string

c)

integer

d)

character

16.

What happens when you use the append() method on a list?

a)

A new element is added to the end

b)

The first element is removed

c)

The list is cleared

d)

The list is reversed

17.

What is the correct way to access the last element of a list?

a)

list[len(list)]

b)

list[last]

c)

list[0]

d)

list[-1]

18.

What does the len() function return when applied to a list?

a)

The first element of the list

b)

The last element of the list

c)

The index of the last element

d)

The number of elements in the list

19.

Which of the following is true about Python functions?

a)

They cannot use parameters

b)

They cannot use variables

c)

They must always return a value

d)

They may or may not return a value

20.

What is the correct way to modify an element in a list?

a)

list.change(index, new_value)

b)

list.modify(index, new_value)

c)

list[index] = new_value

d)

list.update(index, new_value)

21.

Which of the following is true about Python lists?

a)

Lists are indexed starting at 0

b)

Lists are indexed starting at 1

c)

Lists are indexed starting at -1

d)

Lists cannot be indexed

22.

What is the output of lower() method applied to 'HELLO'?

a)

hello

b)

HELLO

c)

hELLO

d)

Hello

23.

What is the correct way to retrieve the length of a list?

a)

len(list)

b)

length(list)

c)

list.length()

d)

list.size()

24.

What is the correct way to access the first element of a list?

a)

list[0]

b)

list[-1]

c)

list[1]

d)

list[first]

25.

Which of the following is true about Python syntax?

a)

Indentation is important

b)

Indentation is optional

c)

Python ignores indentation

d)

Python uses braces for indentation