Previous Index Next

Review Questions

1. Write a statement to create a list of first 10 even numbers.


2. Write a statement to create an empty list.


3. What will the following code display?

numbers = list(range(1, 10, 2))
print(numbers)


4. What will the following code display?

numbers = [3] * 3
print(numbers)


5. What will the following code display?

numbers = [10, 20, 30, 40]
print(numbers[-4])


6. Write the output of following code.

numbers = [10, 20, 30, 40, 50]
x = numbers[1:3]
print(x)
y = numbers[1:]
print(y)
z = numbers[:1]
print(z)


7. Write the output of following code.

a = ["hello", 2.0, 5, [10, 20]]
print(a[2])
print(a[3])
print(a[3][1])


8. Write a statement to delete last element of following list.

numbers = [10,20,30,40]


9. Write a statement to add 'mango' in following list at the end.

fruits =['apple', 'banana']


10. Write the output of following code segments.

t1 = ['a', 'b', 'c']
t2 = ['d', 'e']
t1.append(t2)
print(t1)


11. Write the output of following code segments.

t1 = ['a', 'b', 'c']
t2 = ['d', 'e']
t1.extend(t2)
print(t1)


12. Write the output of following code segments.

colors = ['red', 'green', 'blue', 'orange', 'black']
colors.sort()
color = colors.pop()
print(color)
print(colors)


13. Write the output of following code segments.

s ='Just Do It'
w = s.split()
c = list(w[0]+w[1]+w[2])
print(w)
print(c)


14. Write the output of following code segments.

a = "Guido Van Rossum"
a = a.split()
b = a[0][0]+". "+a[1][0]+". "+a[2]
print (b)


15. Write the output of following code segments.

List = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Sum = 0
for I in range(1,6,2):
    Times = Times + I
    Alpha = Alpha + List[I-1]+"#"
    Sum = Sum + List[I]
print(Times,Sum,Alpha)


Programming Exercises

For Lab Programming Questions click here.

Previous Index Next