wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Essentials

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the purpose of IDLE in Python?

a)

To compile Python code into machine language.

b)

To serve as a database management tool for Python projects.

c)

To provide a web server for hosting Python applications.

d)

The purpose of IDLE in Python is to provide an integrated development environment for writing and executing Python code.

2.

How do you read user input in Python?

a)

Use the 'get_input()' function.

b)

Use the 'scan()' function.

c)

Use the 'input()' function.

d)

Use the 'read()' function.

3.

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

a)

len()

b)

count()

c)

length()

d)

size()

4.

How can you convert a string to an integer in Python?

a)

Use str('string') to convert a string to an integer.

b)

Use int('string') to convert a string to an integer.

c)

Apply float('string') for conversion to integer.

d)

Use eval('string') to get an integer from a string.

5.

What is the result of concatenating 'Hello' and 'World'?

a)

WorldHello

b)

HelloWorld

c)

Hello World

d)

HelloWorld!

6.

How do you define a function in Python?

a)

function_name(parameters) =>

b)

create function_name(parameters)

c)

def function_name(parameters):

d)

function_name: parameters()

7.

What method would you use to remove an element from a list?

a)

Use the 'insert()' method.

b)

Use the 'extend()' method.

c)

Use the 'remove()' or 'pop()' method.

d)

Use the 'append()' method.

8.

How can you sort a list in Python?

a)

Use list.reverse() to sort a list in Python.

b)

Apply the sort() method on a string instead of a list.

c)

Use the sort_list() function to sort a list in Python.

d)

Use list.sort() or sorted(list) to sort a list in Python.

9.

What is the syntax to create a dictionary in Python?

a)

b)

{'key': 'value'}

c)

{key: value}

d)

['key', 'value']

10.

How do you access a value in a dictionary using its key?

a)

dictionary_name.get(key)

b)

dictionary_name[key]

c)

dictionary_name[key] = value

d)

dictionary_name.key()