Prepared By: Jayatu Bhowmick
FIND THE OUTPUT
1. What will be the output of the following code?
def add_numbers(a, b=5):
return a + b
print(add_numbers(10))
print(add_numbers(10, 20))
2. Predict the output:
x = [1, 2, 3]
y = x
[Link](4)
print(y)
3. Output of the following code:
a = [1, 2, 3, 4]
b = a[:]
a[0] = 100
print(b)
4. What will be printed?
text = "HELLO world"
print([Link]())
print([Link]())
5. Analyze and provide the output:
numbers = [1, 2, 3, 4, 5]
print(numbers[1:4])
6. Output of this code:
a = [1, 2, 3]
b = [4, 5, 6]
c = a + b
print(c)
7. Predict the output:
for i in range(3):
print(i, end=' ')
8. What will be printed?
text = "Python"
print(text[::-1])
9. Find the output:
def factorial(n):
if n == 0:
return 1
else:
Page | 1
Prepared By: Jayatu Bhowmick
return n * factorial(n - 1)
print(factorial(3))
[Link] of the following code:
a = [1, 2, 3, 4, 5]
print(a[-1])
print(a[-3])
[Link] will be printed?
a = [1, 2, 3]
[Link](1, 10)
print(a)
[Link] the output:
text = "computer"
print(len(text))
[Link] of this code:
a = [1, 2, 3, 4]
print([Link]())
print(a)
[Link] will be printed?
text = "Python Programming"
print([Link]('o'))
[Link] and provide the output:
text = "Computer"
print(text[::2])
[Link] will be the output of the following code?
def power(x, y=2):
return x ** y
print(power(3))
print(power(3, 3))
[Link] the output:
a = [1, 2, 3]
b = a
a += [4]
print(b)
[Link] of the following code:
text = "Data Science"
print([Link]('S'))
print([Link]('s'))
Page | 2
Prepared By: Jayatu Bhowmick
[Link] will be printed?
lst = [1, 2, 3, 4, 5]
print(lst[::3])
[Link] and provide the output:
a = [1, 2, 3, 4]
print(sum(a))
[Link] of this code:
def greet(name):
return "Hello " + name
print(greet("Alice"))
[Link] the output:
text = "hello"
print([Link]())
[Link] will be printed?
a = [1, 2, 3]
[Link](2)
print(a)
[Link] the output:
a = [1, 2, 3]
[Link]([4, 5])
print(a)
[Link] of the following code:
text = "abcde"
print(text[1:4])
[Link] will be printed?
a = [1, 2, 3]
b = a * 2
print(b)
[Link] the output:
text = "Python"
print([Link]('P'))
print([Link]('n'))
[Link] of this code:
a = [1, 2, 3, 4]
print([Link](3))
[Link] will be printed?
text = "Data Science"
print([Link]('Data', 'Big Data'))
Page | 3
Prepared By: Jayatu Bhowmick
[Link] and provide the output:
a = [5, 3, 1, 4, 2]
[Link]()
print(a)
[Link] will be the output of the following code?
a = [1, 2, 3]
b = [Link]()
[Link](4)
print(b)
[Link] the output:
text = "Python Programming"
print([Link]('P'))
[Link] of the following code:
def func(x):
return x[::-1]
print(func([1, 2, 3, 4]))
[Link] will be printed?
a = [1, 2, 3, 4, 5]
print(a[2:])
[Link] and provide the output:
a = [10, 20, 30, 40]
print(a[::2])
[Link] of this code:
text = "python"
print([Link]())
print([Link]())
[Link] the output:
a = [1, 2, 3, 4]
print(len(a))
[Link] will be printed?
a = [1, 2, 3]
[Link]([4, 5])
print(a)
[Link] the output:
def reverse_string(s):
return s[::-1]
print(reverse_string("Data"))
Page | 4
Prepared By: Jayatu Bhowmick
[Link] of the following code:
a = [1, 2, 3]
[Link]()
print(a)
[Link] will be printed?
text = "Hello World"
print([Link]())
[Link] the output:
a = [1, 2, 3, 4]
print(a[1:3])
[Link] of this code:
text = "Computer"
print([Link]('p'))
[Link] will be printed?
a = [1, 2, 3]
print(a + [4, 5])
[Link] and provide the output:
a = [3, 1, 4, 1, 5]
print([Link](1))
[Link] will be the output of the following code?
a = [1, 2, 3]
print([Link](2))
[Link] the output:
text = "Data Science"
print([Link]())
print([Link]())
[Link] of the following code:
a = [1, 2, 3, 4, 5]
print(a[:3])
[Link] will be printed?
text = "Python"
print(text[0])
print(text[-1])
[Link] and provide the output:
a = [1, 2, 3]
[Link](4)
print(a)
Page | 5
Prepared By: Jayatu Bhowmick
[Link] of this code:
text = "Hello"
print([Link]())
print([Link]())
[Link] the output:
a = [1, 2, 3]
a[1] = 100
print(a)
[Link] will be printed?
text = "python programming"
print([Link]())
[Link] the output:
def sum_elements(lst):
return sum(lst)
print(sum_elements([1, 2, 3, 4]))
[Link] of the following code:
a = [1, 2, 3, 4, 5]
print(a[::-1])
[Link] will be printed?
a = [1, 2, 3]
[Link](2)
print(a)
[Link] the output:
text = "Data Science"
print([Link]('S'))
print([Link]('s'))
[Link] of this code:
a = [5, 4, 3, 2, 1]
[Link]()
print(a)
[Link] will be printed?
text = "Python"
print([Link]())
print([Link]())
[Link] and provide the output:
a = [1, 2, 3]
[Link]([4, 5])
print(a)
Page | 6
Prepared By: Jayatu Bhowmick
[Link] will be the output of the following code?
text = "Data Science"
print([Link]('Data', 'Big Data'))
[Link] the output:
a = [1, 2, 3, 4]
print(a[::2])
[Link] of the following code:
a = [1, 2, 3]
print(a * 3)
[Link] will be printed?
text = "Python Programming"
print([Link]('Pro'))
[Link] and provide the output:
a = [1, 2, 3]
b = [Link]()
[Link](4)
print(b)
[Link] of this code:
a = [1, 2, 3, 4]
print([Link](1))
print(a)
[Link] the output:
text = "PYTHON"
print([Link]())
[Link] will be printed?
text = "Python"
print([Link]())
[Link] the output:
a = [1, 2, 3]
[Link](1, 10)
print(a)
[Link] of the following code:
a = [1, 2, 3, 4, 5]
print(a[1:-1])
[Link] will be printed?
text = "Computer Science"
print([Link]('e'))
Page | 7
Prepared By: Jayatu Bhowmick
[Link] the output:
a = [1, 2, 3]
[Link]([4, 5])
print(a[3])
[Link] of this code:
text = "Data"
print(text * 3)
[Link] will be printed?
a = [5, 4, 3, 2, 1]
[Link](reverse=True)
print(a)
[Link] and provide the output:
text = "Python Programming"
print([Link]('o', '0'))
[Link] will be the output of the following code?
a = [1, 2, 3, 4]
print(a[:2])
[Link] the output:
text = "Python"
print(text[1:5:2])
[Link] of the following code:
a = [1, 2, 3]
b = [4, 5]
print(a + b)
[Link] will be printed?
a = [1, 2, 3, 4]
[Link](3)
print(a)
[Link] and provide the output:
text = "Hello World"
print([Link]())
[Link] of this code:
a = [10, 20, 30, 40]
print([Link](30))
[Link] the output:
a = [1, 2, 3]
a[1] = a[1] + 5
print(a)
Page | 8
Prepared By: Jayatu Bhowmick
[Link] will be printed?
text = "Data Science"
print([Link]())
[Link] the output:
a = [1, 2, 3, 4]
print(a[::-1])
[Link] of the following code:
text = "Python"
print([Link]())
[Link] will be printed?
a = [1, 2, 3, 4]
print(len(a))
[Link] the output:
text = "Python"
print(text[2:])
[Link] of this code:
a = [1, 2, 3, 4, 5]
print(a[::2])
[Link] will be printed?
text = "Java Programming"
print([Link]('Java', 'Python'))
[Link] and provide the output:
a = [3, 1, 4, 2]
[Link]()
print(a)
[Link] will be the output of the following code?
a = [1, 2, 3]
b = [Link]()
a += [4, 5]
print(b)
[Link] the output:
text = "Hello World"
print([Link]('H'))
print([Link]('d'))
[Link] of the following code:
a = [1, 2, 3]
[Link](2, 10)
print(a)
Page | 9
Prepared By: Jayatu Bhowmick
[Link] will be printed?
text = "Data Science"
print([Link]('S'))
[Link] and provide the output:
a = [5, 4, 3, 2, 1]
[Link]()
print(a)
[Link] of this code:
text = "Python"
print([Link]())
print([Link]())
[Link] the output:
a = [1, 2, 3, 4]
print(sum(a))
[Link] will be printed?
text = "Data"
print(text * 4)
[Link] the output:
a = [1, 2, 3]
[Link]([4, 5])
print(a)
100. Output of the following code:
text = "Computer"
print(text[::2])
Page | 10