Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Data Analytics Quiz-2

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the output of the following code?

```python

string = "Hello, world!"

print(string[7:12])

```

a)

world

b)

, wor

c)

world!

d)

Hello

2.

Which of the following strings is correctly enclosed using single quotes?

a)

"This is a string"

b)

'Another string'

c)

`Yet another string`

d)

'''String with triple single quotes'''

3.

What is the length of the string "GPT-3.5 is amazing."?

a)

13

b)

15

c)

17

d)

18

4.

Which string method can be used to convert a string to uppercase letters?

a)

upper()

b)

capitalize()

c)

title()

d)

casefold()

5.

What is the index of the first occurrence of the letter 'o' in the string "Coding is fun and challenging."?

a)

4

b)

6

c)

8

d)

10

6.

Which of the following data structures in Python stores data in key-value pairs?

a)

List

b)

Tuple

c)

Set

d)

Dictionary

7.

How are dictionary keys accessed in Python?

A)

B)

C)

D)

a)

Using indexes

b)

Using parentheses

c)

Using curly braces

d)

Using square brackets

8.

What happens if you try to add a key that already exists in a dictionary?

a)

An error is raised

b)

The existing value for that key is replaced

c)

The dictionary remains unchanged

d)

The dictionary automatically resizes

9.

Which method is used to remove a key-value pair from a dictionary in Python?

a)

popitem()

b)

remove()

c)

delete()

d)

pop()

10.

What is the result of the following code snippet?



```python

student = {

"name": "Alice",

"age": 20,

"grade": "A"

}



student["school"] = "XYZ School"

print(len(student))

```

a)

3

b)

4

c)

5

d)

6