Search Header Logo

Python Sets Quiz

Authored by Shiwen Zhang

Computers

University

Used 1+ times

Python Sets Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

16 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

下面哪个是集合?

myset = 'apple, banana, cherry'

myset = {'apple', 'banana', 'cherry'}

myset = ['apple', 'banana', 'cherry']

myset = ('apple', 'banana', 'cherry')

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

下面哪个表述方式可以在python里面表示一个集合?

myset = ('apple', 'banana', 'cherry')

myset = ['apple', 'banana', 'cherry']

myset = {'apple', 'banana', 'cherry'}

set myset = {'apple', 'banana', 'cherry'}

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

下面哪个语句不可以定义一个集合?

myset = ('apple', 'banana', 'cherry')

myset = {'apple', 'banana', 'cherry'}

myset = set(['apple', 'banana', 'cherry'])

myset = {'apple', 'banana', 'cherry', 'apple'}

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

您可以通过引用索引来访问集合项

5.

FILL IN THE BLANK QUESTION

1 min • 1 pt

完善语句,使代码可以检查apple是否存在于fruits集合中

fruits = {"apple", "banana", "cherry"}

if "apple" ___fruits:

print("Yes, apple is a fruit!")

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

考虑以下代码运行后的结果为:
thisset = {'apple', 'banana', 'cherry'}
print('banana' not in thisset)

True

False

{'apple', 'cherry'}

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

下面哪个方法可以添加一个元素到集合中

add()

insert()

push()

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?