Data structure (DSA) in Python is well supported by a lot of powerfull class like List,Stack,Queue,Set or Dictionary
This quiz is in Python quiz collection.
Start quiza = ?
a = [[1] * 2] * 2
a[0][0]=2
What is the result of this code?
a=[1,2,3,4,5,6,7,8,9]
a[::2]
What will be placed in a?
a = [1,2,3]
a[-3:-1] = 10,20,30,40
What gets printed?
kvps = { '1' : 1, '2' : 2 , '3' : 3, '4' : 4, '5' : 5}
newData = { '1' : 10, '3' : 30 }
kvps.update(newData)
x = sum(kvps.values())
print x
What gets printed?
names1 = ['Amir', 'Barry', 'Chales', 'Dao']
names2 = [name.lower() for name in names1]
print names2[2][0]
What gets printed?
names = ['Amir', 'Barry', 'Chales', 'Dao']
print names[-1][-1]
The following code will successfully print the days and then the months
daysOfWeek = ['Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday']
months = ['Jan', \
'Feb', \
'Mar', \
'Apr', \
'May', \
'Jun', \
'Jul', \
'Aug', \
'Sep', \
'Oct', \
'Nov', \
'Dec']
print "DAYS: %s, MONTHS %s" %
(daysOfWeek, months)
What is the ouput?
dict = {'Name': 'Jill', 'Age': 17, 'Name': 'Bill'} print "dict['Name']: ", dict['Name']
Which of following are valid dictionary declarations?
__________ creates a list.
What is list("abcd")?
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3]
What is len(list1)?
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3]
What is max(list1)?
© 2017 QuizBucket.org