Sunday, August 6, 2023

NPTEL » The Joy of Computing using Python Week 3 : Quiz Assignment Solution

 


Week 3 : Assignment


1 point
1.What will be the output of the following code?

L = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’]

print(L[2:5])
 
 
 
 
1 point
2.Which of the following is a valid way to declare a dictionary in Python?
 
 
 
 
1 point
3.Which of the following method is correct to add an element at a specific position?
 
 
 
 
1 point
4.What is the correct syntax to add an item to the end of a list in Python?
 
 
 
 
1 point
5.Which of the following is not a valid data type in Python?
 
 
 
 
1 point
6.What is the output of the following code?

for i in range(1, 21):
    if i % 3 == 0 and i % 5 == 0:
        print("FizzBuzz")
    elif i % 3 == 0:
        print("Fizz")
    elif i % 5 == 0:
        print("Buzz")
    else:
        print(i)
 
 
 
 
1 point
7.What is the output of the following code?
a = 5
b = 2
print(a // b)
 
 
 
 
1 point
8.What is the output of the following code?
s = "hello"
print(s[::-1])
 
 
 
 
1 point
9.What is the output of the following code?
a = 10
b = 5
c = a % b
print(c)
 
 
 
 
1 point
10.What is the output of the following code?
s = "python"
print(s[1:4])
 
 
 
 

No comments:

Post a Comment