List Manipulation in Python Class 11 Questions and Answers

Teachers and Examiners (CBSESkillEduction) collaborated to create the List Manipulation in Python Class 11 Questions and Answers. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

List Manipulation in Python Class 11 Questions and Answers

1. What will be the output of the following statements?
i. list1 = [12,32,65,26,80,10]
list1.sort()
print(list1)
Answer – [10, 12, 26, 32, 65, 80]

ii. list1 = [12,32,65,26,80,10]
sorted(list1)
print(list1)
Answer – [12, 32, 65, 26, 80, 10]

iii. list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::-2]
print(list1[:3] + list1[3:])
Answer – [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

iv. list1 = [1,2,3,4,5]
print(list1[len(list1)-1])
Answer – 5

2. Consider the following list myList. What will be the elements of myList after the following two operations:
myList = [10,20,30,40]
i. myList.append([50,60])
print(myList)
Answer – [10, 20, 30, 40, [50, 60]]

ii. myList.extend([80,90])
print(myList)
Answer – [10, 20, 30, 40, 80, 90]

3. What will be the output of the following code segment:
myList = [1,2,3,4,5,6,7,8,9,10]
for i in range(0,len(myList)):
if i%2 == 0:
print(myList[i])
Answer –
1
3
5
7
9

4. What will be the output of the following code segment:
a. myList = [1,2,3,4,5,6,7,8,9,10]
del myList[3:]
print(myList)
Answer – [1, 2, 3]

b. myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:5]
print(myList)
Answer – [6, 7, 8, 9, 10]

c. myList = [1,2,3,4,5,6,7,8,9,10]
del myList[::2]
print(myList)
Answer – [2, 4, 6, 8, 10]

List Manipulation in Python Class 11 Questions and Answers

5. Differentiate between append() and extend() functions of list.
Answer – append() function helps to adds a single element to the end of the list, extend() function can add multiple elements to the end of list.

6. Consider a list:
list1 = [6,7,8,9]
What is the difference between the following operations on list1:
a. list1 * 2
b. list1 *= 2
c. list1 = list1 * 2
Answer –
1. The first line of the statement prints each element of the list twice, as in [6, 7, 8, 9, 6, 7, 8, 9]. List1, however, won’t be changed.
2. List1 will be modified and the list with repeated elements, [6, 7, 8, 9, 6, 7, 8, 9], will be assigned to List1.
3. This assertion will similarly have the same outcome as the assertion “list1 *= 2.” List1 will be given the list with the repeated elements, [6, 7, 8, 9, 6, 7, 8, 9].

List Manipulation in Python Class 11 Questions and Answers

7. The record of a student (Name, Roll No., Marks in five subjects and percentage of marks) is stored in the following list:
stRecord = [‘Raman’,’A-36′,[56,98,99,72,69],78.8]
Write Python statements to retrieve the following information from the list stRecord.
a) Percentage of the student
Answer – stRecord[3]

b) Marks in the fifth subject
Answer –
stRecord[2][4]

c) Maximum marks of the student
Answer –
max(stRecord[2])

d) Roll no. of the student
Answer –
stRecord[1]

e) Change the name of the student from ‘Raman’ to ‘Raghav’
Answer –
stRecord[0] = “Raghav”

1. Write a program to find the number of times an element occurs in the list.
Answer –
list1 = [10, 20, 30, 40, 50, 60, 20, 50]
print(“List is:”,list1)
new_list = int(input(“Enter element Which you like to count? “))
counter = list1.count(new_list)
print(“Count of Element”,new_list,”in the list is:”,counter)

Output
List is: [10, 20, 30, 40, 50, 60, 20, 50]
Enter element Which you like to count? 10
Count of Element 10 in the list is: 1

List Manipulation in Python Class 11 Questions and Answers

2. Write a program to read a list of n integers (positive as well as negative). Create two new lists, one having all positive numbers and the other having all negative numbers from the given list. Print all three lists.
Answer –
n = int(input(“Enter number of terms: “))
arr=[]
positive=[]
negative=[]
for i in range(n):
num=int(input())
arr.append(num)
for i in range(n):
if arr[i]>=0 :
positive.append(arr[i])
else:
negative.append(arr[i])
print(“Total positive numbers = “,positive)
print(“Total negative numbers = “,negative)
print(“All numbers = “,arr)

Output
Enter number of terms: 5
6
5
8
4
1
Total positive numbers = [6, 5, 8, 4, 1]
Total negative numbers = []
All numbers = [6, 5, 8, 4, 1]

List Manipulation in Python Class 11 Questions and Answers

3. Write a function that returns the largest element of the list passed as parameter.
Answer –
def myfunction(arr):
max = arr[0]
for i in range(len(arr)):
if max<arr[i]:
max=arr[i]
return max
arr = [32,92,72,36,48,105]
print(myfunction(arr))

Output
105

4. Write a function to return the second largest number from a list of numbers.
Answer –
def myfunction(new_list):
new_list.sort()
return new_list[len(new_list)-2]
new_list = [36,95,45,90,105]
print(myfunction(new_list))

Output
95

List Manipulation in Python Class 11 Questions and Answers

5. Write a program to read a list of n integers and find their median.
Note: The median value of a list of values is the middle one when they are arranged in order. If there are two middle values then take their average.
Hint: You can use an built-in function to sort the list
Answer –
def myfunction(new_list):
new_list.sort()
indexes = len(new_list)
if(indexes%2 == 0):
num1 = (indexes) // 2
num2 = (indexes // 2) + 1
med = (new_list[num1 – 1] + new_list[num2 – 1]) / 2
return med
else:
middle = (indexes – 1) // 2
med = new_list[middle]
return med
new_list = list()
inp = int(input(“Enter Number of Terms : “))
for i in range(inp):
a = int(input(“Enter the Number: “))
new_list.append(a)
print(“The median value is”,myfunction(new_list))

Output
Enter Number of Terms : 5
Enter the Number: 6
Enter the Number: 5
Enter the Number: 8
Enter the Number: 4
Enter the Number: 6
The median value is 6

List Manipulation in Python Class 11 Questions and Answers

6. Write a program to read a list of elements. Modify this list so that it does not contain any duplicate elements, i.e., all elements occurring multiple times in the list should appear only once.
Answer –
def myfunction(list1):
length = len(list1)
new_list = []
for a in range(length):
if list1[a] not in new_list:
new_list.append(list1[a])
return new_list

list1 = []

inp = int(input(“Enter Terms : “))

for i in range(inp):
a = int(input(“Enter the number: “))
list1.append(a)

print(“The list is:”,list1)

print(“List without any duplicate element :”,myfunction(list1))

Output
Enter Terms : 5
Enter the number: 6
Enter the number: 4
Enter the number: 8
Enter the number: 1
Enter the number: 6
The list is: [6, 4, 8, 1, 6]
List without any duplicate element : [6, 4, 8, 1]

7. Write a program to read a list of elements. Input an element from the user that has to be inserted in the list. Also input the position at which it is to be inserted. Write a user defined function to insert the element at the desired position in the list.
Answer –
arr=[114,25,68,84,79]
position = int(input(“Enter the position of the element: “))
element = int(input(“Enter element : “))
print(“The list before insertion : “,arr)
arr1 = arr[:position-1]+[element]+arr[position-1:]
print(“The list after insertion: “,arr1)

Output
Enter the position of the element: 2
Enter element : 75
The list before insertion : [114, 25, 68, 84, 79]
The list after insertion: [114, 75, 25, 68, 84, 79]

List Manipulation in Python Class 11 Questions and Answers

8. Read a list of n elements. Pass this list to a function which reverses this list in-place without creating a new list.
Answer –
new_list=[98,78,54,89,76]
print(“Original list: “,new_list)
new_list.reverse()
print(“List after reversing “,new_list)

Output
Original list: [98, 78, 54, 89, 76]
List after reversing [76, 89, 54, 78, 98]

omputer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer Science Class 11 Practical Questions and Answers

List Manipulation in Python Class 11 MCQs

Teachers and Examiners (CBSESkillEduction) collaborated to create the List Manipulation in Python Class 11 MCQs. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

List Manipulation in Python Class 11 MCQs

1. The data type list is an ordered sequence which is ________ and made up of one or more elements.
a. Mutable 
b. Immutable
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Mutable

2. Which statement from the list below will be create a new list?
a. new_l = [1, 2, 3, 4]
b. new_l = list()
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

3. List can content __________.
a. Integer
b. Float
c. String & Tuple
d. All of the above 

Show Answer ⟶
d. All of the above

4. list are enclosed in square ________ and are separated by _________.
a. Brackets and comma 
b. Brackets and dot
c. Curli Brackets and dot
d. None of the above

Show Answer ⟶
a. Brackets and comma

List Manipulation in Python Class 11 MCQs

5. List elements may be of the following data types.
a. Different data types 
b. Same data types
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Different data types

6. In Python, lists are mutable. It means that ________.
a. The contents of the list can be changed after it has been created 
b. The contents of the list can’t changed after it has been created
c. The list cannot store the number data type.
d. None of the above

Show Answer ⟶
a. The contents of the list can be changed after it has been created

7. What will be the output of the following python code
print(list(“Python”))
a. (‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’)
b. [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’] 
c. (“P”, “y”, “t”, “h”, “o”, “n”)
d. [“P”, “y”, “t”, “h”, “o”, “n”]Show Answer ⟶

b. [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]

8. The data type list allows manipulation of its contents through ________.
a. Concatenation
b. Repetition
c. Membership
d. All of the above 

Show Answer ⟶
d. All of the above

9. Python allows us to join two or more lists using __________ operator.
a. Concatenation 
b. Repetition
c. Membership
d. All of the above

Show Answer ⟶
a. Concatenation

List Manipulation in Python Class 11 MCQs

10. What will be the output of the following python code
new_list = [‘P’,’y’,’t’,’h’,’o’,’n’]
print(len(new_list))
a. 6 
b. 7
c. 8
d. 9

Show Answer ⟶
a. 6

11. Example of concatenation operator _______.
a. –
b. + 
c. /
d. *

Show Answer ⟶
b. +

12. If we try to concatenate a list with elements of some other data type, _________ occurs.
a. Runtime Error
b. Type Error 
c. Result
d. None of the above

Show Answer ⟶
b. Type Error

13. Python allows us to replicate a list using repetition operator depicted by symbol _________.
a. –
b. +
c. /
d. * 

Show Answer ⟶
d. *

14. Like strings, the membership operators _________ checks if the element is present in the list and returns True, else returns False.
a. In 
b. Out
c. Listin
d. None of the above

Show Answer ⟶
a. In

List Manipulation in Python Class 11 MCQs

15. We can access each element of the list or traverse a list using a _______.
a. For loop
b. While loop
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

16. _________ returns the length of the list passed as the argument.
a. len() 
b. length()
c. leth()
d. None of the above

Show Answer ⟶
a. len()

17. ________ creates an empty list if no argument is passed.
a. len()
b. list() 
c. append()
d. extend()

Show Answer ⟶
b. list()

18. ________ a single element passed as an argument at the end of the list.
a. append() 
b. extend()
c. insert()
d. None of the above

Show Answer ⟶
a. append()

19. Which of the following command is used to add an element in list?
a. new_list.add(5)
b. new_list.added(5)
c. new_list.append(5) 
d. All of the above

Show Answer ⟶
c. new_list.append(5)

List Manipulation in Python Class 11 MCQs

20. _________ returns the number of times a given element appears in the list.
a. insert()
b. index()
c. count() 
d. None of the above

Show Answer ⟶
c. count()

21. _________ returns index of the first occurrence of the element in the list. If the element is not present, ValueError is generated.
a. insert()
b. index() 
c. count()
d. None of the above

Show Answer ⟶
b. index()

22. What will be the output of the following python code.
new_list1 = [“Welcome”]
new_list2 = [“to”, “my”]
new_list3 = [“School”]
print(new_list1 + new_list2 + new_list3)

a. [‘Welcome’, ‘to’, ‘my’, ‘School’]
b. [‘Welcome’]
c. [‘Welcome’, ‘to’, ‘my’]
d. None of the above

Show Answer ⟶
a. [‘Welcome’, ‘to’, ‘my’, ‘School’]

23. ________ function removes the given element from the list. If the element is present multiple times, only the first occurrence is removed.
a. delete()
b. rem()
c. remove() 
d. None of the above

Show Answer ⟶
c. remove()

24. _______ function returns the element whose index is passed as parameter to this function and also removes it from the list.
a. push()
b. remove()
c. pop() 
d. None of the above

Show Answer ⟶
c. pop()

List Manipulation in Python Class 11 MCQs

25. What will be the output of the following python code.
new_list = [9, 8, 7]
print(sum(new_list))
a. 22
b. 23
c. 24 
d. 25

Show Answer ⟶
c. 24

26. What will be the output of the following python code.
new_list = [9, 8, 7]
print(min(new_list))
a. 9
b. 8
c. 7 
d. None of the above

Show Answer ⟶
c. 7

27. ________ function reverses the order of elements in the given list.
a. return()
b. reverse() 
c. rev()
d. None of the above

Show Answer ⟶
b. reverse()

List Manipulation in Python Class 11 MCQs

28. _______ function helps to sorts the elements of the given list.
a. acc()
b. sort() 
c. sorted()
d. None of the above

Show Answer ⟶
b. sort()

29. What will be the output of the following python code.
new_list = “1234”
print(list(new_list))
a. [‘1’, ‘2’, ‘3’, ‘4’] 
b. (‘1’, ‘2’, ‘3’, ‘4’)
c. {‘1’, ‘2’, ‘3’, ‘4’}
d. None of the above

Show Answer ⟶
a. [‘1’, ‘2’, ‘3’, ‘4’]

List Manipulation in Python Class 11 MCQs

30. What will be the output of the following python code.
new_list = “1234”
new_list = list(new_list)
print(type(new_list[2]))
a. Erron
b. class ‘str’ 
c. class ‘int’
d. None of the above

Show Answer ⟶
b. class ‘str’

31. _________ function takes a list as parameter and creates a new list consisting of the same elements arranged in sorted order.
a. acc()
b. sort()
c. sorted() 
d. None of the above

Show Answer ⟶
c. sorted()

32. When a list appears as an element of another list, it is called a ________.
a. New list
b. Nested list 
c. Multi List
d. None of the above

Show Answer ⟶
b. Nested list

List Manipulation in Python Class 11 MCQs

33. What will be the output of the following python code
new_list = [“Welcome”, “to”, “my”, “School”]
print(max(new_list))
a. Welcome
b. to 
c. my
d. School

Show Answer ⟶
b. to

34. What will be the output of the following python code.
new_list = [1, 2, 3, 4, [5, 6, 7]]
print(new_list[6])
a. 4 
b. 5
c. 6
d. 7

Show Answer ⟶
a. 4

List Manipulation in Python Class 11 MCQs

35. What will be the output of the following python code.
new_list = [“Welcome”, “to”, “my”, “School”]
print(new_list[-2][-2])
a. W
b. y
c. m 
d. S

Show Answer ⟶
c. m

36. Which of the following is not belong to the list operation?
a. Slicing
b. Slicing
c. Concatenation
d. Dividing 

Show Answer ⟶
d. Dividing

37. What will be the output of the following python code.
new_list = [“Welcome”, “to”, “my”, “School”]
print(new_list*2)
a. [‘Welcome’, ‘to’, ‘my’, ‘School’, ‘Welcome’, ‘to’, ‘my’, ‘School’] 
b. [‘Welcome’, ‘to’, ‘my’, ‘School’]
c. [‘Welcome’]
d. None of the above

Show Answer ⟶
a. [‘Welcome’, ‘to’, ‘my’, ‘School’, ‘Welcome’, ‘to’, ‘my’, ‘School’]

38. What will be the output of the following python code.
new_list = (“Welcome to my School”)
print(new_list[13 : -1])
a. School
b. Welcome
c. Schoo 
d. None of the above

Show Answer ⟶
c. Schoo

39. What will be the output of the following python code.
new_list = [5, 8, 3]
new_list1 = [1, 2, 3]
print(new_list.append(new_list1))
a. [5, 8, 3, 1, 2, 3]
b. [1, 2, 3, 5, 8, 3]
c. None 
d. None of the above

Show Answer ⟶
c. None

List Manipulation in Python Class 11 MCQs

40. Which of the subsequent results in an empty list?
a. new_list = list(0) 
b. new_list = list()
c. new_list = list(empty)
d. All of the above

Show Answer ⟶
a. new_list = list(0)
omputer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer Science Class 11 Practical Questions and Answers

String Manipulation in Python Class 11 Solutions

Teachers and Examiners (CBSESkillEduction) collaborated to create the String Manipulation in Python Class 11 Solutions. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

String Manipulation in Python Class 11 Questions and Answers

1. Consider the following string mySubject:
mySubject = “Computer Science”
What will be the output of the following string operations :
i. print(mySubject[0:len(mySubject)])
Answer – Computer Science

ii. print(mySubject[-7:-1])
Answer – Scienc

iii. print(mySubject[::2])
Answer – Cmue cec

iv. print(mySubject[len(mySubject)-1])
Answer – e

v. print(2*mySubject)
Answer – Computer ScienceComputer Science

vi. print(mySubject[::-2])
Answer – eniSrtpo

vii. print(mySubject[:3] + mySubject[3:])
Answer – Computer Science

viii. print(mySubject.swapcase())
Answer – cOMPUTER sCIENCE

ix. print(mySubject.startswith(‘Comp’))
Answer – True

x. print(mySubject.isalpha())
Answer – False

2. Consider the following string myAddress:
myAddress = “WZ-1,New Ganga Nagar,New Delhi”

What will be the output of following string operations :

i. print(myAddress.lower())
Answer – wz-1,new ganga nagar,new delhi

ii. print(myAddress.upper())
Answer – WZ-1,NEW GANGA NAGAR,NEW DELHI

iii. print(myAddress.count(‘New’))
Answer – 2

iv. print(myAddress.find(‘New’))
Answer – 5

v. print(myAddress.rfind(‘New’))
Answer – 21

vi. print(myAddress.split(‘,’))
Answer – [‘WZ-1’, ‘New Ganga Nagar’, ‘New Delhi’]

vii. print(myAddress.split(‘ ‘))
Answer – [‘WZ-1,New’, ‘Ganga’, ‘Nagar,New’, ‘Delhi’]

viii. print(myAddress.replace(‘New’,’Old’))
Answer – WZ-1,Old Ganga Nagar,Old Delhi

ix. print(myAddress.partition(‘,’))
Answer – (‘WZ-1’, ‘,’, ‘New Ganga Nagar,New Delhi’)

x. print(myAddress.index(‘Agra’))
Answer – ValueError: substring not found

String Manipulation in Python Class 11 Solutions

3. Write a program to input line(s) of text from the user until enter is pressed. Count the total number of characters in the text (including white spaces),total number of alphabets, total number of digits, total number of special symbols and total number of words in the given text. (Assume that each word is separated by one space).
Answer –
str = input(“Enter your text : “)
Alpha = 0
Digit = 0
Special = 0
words = 0
for ch in str:
if ch.isalpha():
Alpha += 1
elif ch.isdigit():
Digit += 1
else:
Special += 1

for ch1 in str:
if ch1.isspace():
words += 1
print(“Alphabets: “,Alpha)
print(“Digits: “,Digit)
print(“Special Characters: “,Special)
print(“Words in the Input :”,(words + 1))

Output
Enter your text : Hello how are you
Alphabets: 14
Digits: 0
Special Characters: 3
Words in the Input : 4

4. Write a user defined function to convert a string with more than one word into title case string where string is passed as parameter. (Title case means that the first letter of each word is capitalised)
Answer –
def convertToTitle(string):
titleString = string.title();
print(titleString)

str = input(“Type your Text : “)
Space = 0
for b in str:
if b.isspace():
Space += 1

if(str.istitle()):
print(“The String is already in title case”)
elif(Space > 0):
convertToTitle(str)
else:
print(“One word String”)

Output
Type your Text : Welcome to my school
Welcome To My School

5. Write a function deleteChar() which takes two parameters one is a string and other is a character. The function should create a new string after deleting all occurrences of the character from the string and return the new string.
Answer –
def deleteChar(string,char):
str = “”
for ch in string:
if ch != char:
str+=ch
return str

string = input(“Enter a string: “)
char = (input(“Enter a character: “))[0]
print(deleteChar(string,char))

6. Input a string having some digits. Write a function to return the sum of digits present in this string.
Answer –
def myfunction(string):
sum = 0
for a in string:
if(a.isdigit()):
sum += int(a)
return sum

str = input(“Enter any string with digits : “)
result = myfunction(str)
print(“The sum of digits in the string : “,result)

Output
Enter any string with digits : Welcome 225
The sum of digits in the string : 9

7. Write a function that takes a sentence as an input parameter where each word in the sentence is separated by a space. The function should replace each blank with a hyphen and then return the modified sentence.
Answer –
def myfunction():
string = input(“Enter a sentence: “)
str = string.replace(” “,”-“)
print(str)

myfunction()

Output
Enter a sentence: Welcome to my school
Welcome-to-my-school

omputer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer Science Class 11 Practical Questions and Answers

String in Python Class 11 MCQ

Teachers and Examiners (CBSESkillEduction) collaborated to create the String in Python Class 11 MCQ. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

String in Python Class 11 MCQ

1. _________ is a sequence which is made up of one or more UNICODE characters.
a. String 
b. Number
c. Float
d. Double

Show Answer ⟶
a. String

2. String can be a _________.
a. Letter
b. Digit
c. Whitespace & Symbol
d. All of the above 

Show Answer ⟶
d. All of the above

3. A string can be assign by enclosing ______ quote.
a. Single
b. Double
c. Triple
d. All of the above 

Show Answer ⟶
d. All of the above

4. Each individual character in a string can be accessed using a technique called _______.
a. Indexing 
b. Method
c. Storing
d. None of the above

Show Answer ⟶
a. Indexing

String in Python Class 11 MCQ

5. The index specifies the character to be accessed in the string and is written in square brackets _______.
a. ( )
b. [ ] 
c. { }
d. None of the above

Show Answer ⟶
b. [ ]

6. In the string, the index of the first character start from ______.
a. 0 
b. n-1
c. 1
d. None of the above

Show Answer ⟶
a. 0

7. In the string, the index of the last character ______.
a. 0
b. n-1 
c. 1
d. None of the above

Show Answer ⟶
b. n-1

8. If we give index value out of this range then we get an _______.
a. Run time Error
b. IndexError 
c. Syntax Error
d. None of the above

Show Answer ⟶
b. IndexError

9. What will be the output of the following python code
str1=”Welcome to my \n School”
print(str1)
a. Welcome to my
b. Welcome to my School
c. Welcome to my 
School
d. None of the above

Show Answer ⟶
c. Welcome to my

String in Python Class 11 MCQ

10. What will be the output of the following python code
str1=”Welcome to \
my School”
print(str1)
a. Welcome to my School 
b. Welcome to
my School
c. Welcome to \ my School
d. None of the above

Show Answer ⟶
a. Welcome to my School

11. A string is an _______ data type.
a. Mutable
b. Immutable t
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Immutable

12. Immutable data type means _________.
a. String can be changed after it has been created
b. String cannot be changed after it has been created 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. String cannot be changed after it has been created

13. Concatenate means ______.
a. to Join 
b. to Divide
c. to Split
d. None of the above

Show Answer ⟶
a. to Join

14. Python allows us to join two strings using concatenation operator _______.
a. + +
b. + –
c. + 
d. None of the above

Show Answer ⟶
c. +

String in Python Class 11 MCQ

15. Python allows us to repeat the given string using repetition operator which is denoted by symbol _________.
a. * 
b. &
c. #
d. $

Show Answer ⟶
a. *

16. It is possible to retrieve each individual character in a string using a method _________ .
a. Concatenation
b. Indexing 
c. Replication
d. All of the above

Show Answer ⟶
b. Indexing

17. We receive a ________ if we provide an index value that is outside of the range.
a. Syntax Error
b. Run time Error
c. Index Error 
d. None of the above

Show Answer ⟶
c. Index Error

18. Python has two membership operators _______ and ______.
a. In and Out
b. In and Not 
c. True and False
d. None of the above

Show Answer ⟶
b. In and Not

19. The _________ operator also takes two strings and returns True if the first string does not appear as a substring in the second string, otherwise returns False.
a. Not
b. Not to
c. Not in 
d. Not out

Show Answer ⟶
c. Not in

String in Python Class 11 MCQ

20. In Python, to access some part of a string or substring, we use a method called _______.
a. Joining
b. Slicing 
c. Accessing
d. None of the above

Show Answer ⟶
b. Slicing

21. The string’s initial character is at index 0 from ________.
a. Right side
b. Left side 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Left side

22. If a string’s contents cannot be modified, the string is __________.
a. Immutable 
b. Mutable
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Immutable

23. String data types can perform _______ operations in Python.
a. Slicing
b. Concatenation
c. Membership
d. All of the above 

Show Answer ⟶
d. All of the above

24. We can access each character of a string or traverse a string using ______ and ________.
a. If and for loop
b. for and while loop 
c. for and do-while loop
d. None of the above

Show Answer ⟶
b. for and while loop

String in Python Class 11 MCQ

25. ________ returns the length of the given string.
a. title()
b. len() 
c. length()
d. None of the above

Show Answer ⟶
b. len()

26. _______ returns a list of words delimited by the specified substring. If no delimiter is given then words are separated by space.
a. partition ()
b. split() 
c. divide()
d. None of the above

Show Answer ⟶
b. split()

27. Following is an example of _________.
str1 = “cbseskilleducation.com”
a. String 
b. Dictionary
c. List
d. None of the above

Show Answer ⟶
a. String

28. What will be the output of the following code.
str1=”Welcome”
str1=”Welcome to my School”
print(str1)
a. Welcome
b. Welcome to my School 
c. Welcome Welcome to my School
d. None of the above

Show Answer ⟶
b. Welcome to my School

29. _______returns the string with first letter of every word in the string in uppercase and rest in lowercase.
a. upper()
b. lower()
c. title() 
d. None of the above

Show Answer ⟶
c. title()

String in Python Class 11 MCQ

30. ________ returns the string with all uppercase letters converted to lowercase.
a. lower() 
b. upper()
c. title()
d. None of the above

Show Answer ⟶
a. lower()

31. ________returns the string with all lowercase letters converted to uppercase.
a. lower()
b. upper() 
c. title()
d. None of the above

Show Answer ⟶
b. upper()

32. Same as find() but raises an exception if the substring is not present in the given string.
a. find(str, start, end)
b. index(str, start, end) 
c. endswith()
d. None of the above

Show Answer ⟶
b. index(str, start, end)

33. _______ returns True if the given string ends with the supplied substring otherwise returns False.
a. find(str, start, end)
b. index(str, start, end)
c. endswith() 
d. None of the above

Show Answer ⟶
c. endswith()

34. What will be the output of the following python code
str1=”WelcometomySchool”
print(len(str1))
a. 17 
b. 18
c. 19
d. 20 

Show Answer ⟶
a. 17

String in Python Class 11 MCQ

35. What will be the output of the following python code
str1=”’Welcome
to
my
School”’
print(str1)
a. Welcome to my School
b. Welcome
to
my
School 
c. Welcome to
my School
d. None of the above

Show Answer ⟶
b. Welcome
to
my
School

36. ________ returns True if characters of the given string are either alphabets or numeric. If whitespace or special symbols are part of the given string or the string is empty it returns False.
a. isalnum() 
b. islower()
c. isupper()
d. None of the above

Show Answer ⟶
a. isalnum()

37. What will be the output of the following python code
str1=”Welcome to my School”
print(len(str1))
a. 17
b. 18
c. 19
d. 20 

Show Answer ⟶
d. 20

38. _______ returns True if the string is non-empty and has all lowercase alphabets, or has at least one
character as lowercase alphabet and rest are non-alphabet characters.
a. isalnum()
b. islower() 
c. isupper()
d. None of the above

Show Answer ⟶
b. islower()

39. ________ returns True if the string is non-empty and all characters are white spaces (blank, tab,
newline, carriage return).
a. isspace() 
b. istitle()
c. istrip()
d. rstrip()

Show Answer ⟶
a. isspace()

String in Python Class 11 MCQ

40. ________ returns the string after removing the spaces both on the left and the right of the string.
a. isspace()
b. strip() 
c. istrip()
d. rstrip()

Show Answer ⟶
b. strip()

41. ________ returns the string after removing the spaces only on the left of the string.
a. isspace()
b. istitle()
c. istrip() 
d. rstrip()

Show Answer ⟶
c. istrip()

42. ________ returns the string after removing the spaces only on the right of the string.
a. isspace()
b. istitle()
c. istrip()
d. rstrip() 

Show Answer ⟶
d. rstrip()

43. What will be the index value of ‘h’ in the following python code
str1=”Python”
a. 3 
b. 4
c. 5
d. 6

Show Answer ⟶
a. 3

44. What will be the output of the following python code
str1=”Python”
str1[0]=”M”
print(str1)
a. Python
b. Mython 
c. Pythonm
d. None of the above

Show Answer ⟶
b. Mython

String in Python Class 11 MCQ

45. What will be the output of the following python code
str1=”Python”
print(str[5])
a. Index Error 
b. Run time Error
c. Output Error
d. None of the above

Show Answer ⟶
a. Index Error

46. What will be the output of the following python code
print(“Python”.replace(“Python”,”My Python”))
a. Python My Python
b. Python
c. My Python 
d. None of the above

Show Answer ⟶
c. My Python

47. What will be the output of the following python code
for i in “Python”:
print(i)
a. Python
b. Py
th
on
c. P 
y
t
h
o
n
d. None of the above

Show Answer ⟶
c. P
y
t
h
o
n

48. Which operator can be applied to both integer and string values?
a. * 
b. /
c. %
d. –

Show Answer ⟶
a. *

49. What will be the output of the following python code
str1 = 20 + “20”
print(str1)
a. Syntax Error
b. TypeError 
c. No Error
d. None of the above

Show Answer ⟶
b. TypeError

String in Python Class 11 MCQ

50. Which operator is used to concatenate strings?
a. ++
b. + 
c. –
d. /

Show Answer ⟶
b. +

51. What will be the output of the following python code
print(len(“\\\@\\\/@”))
a. 6
b. 7 
c. 8
d. 9

Show Answer ⟶
b. 7

52. What will be the output of the following python code
for i in (1,2,3,4):
print(“*” * i)
a. 
*
**
***
****
b.
*
****
c.
****
***
**
*
d. None of the above

Show Answer ⟶
a.
*
**
***
****

53. What will be the output of the following python code
print(“Python”[2:3])
a. Error
b. h
c. t 
d. No Output

Show Answer ⟶
c. t

54. What will be the output of the following python code
print(“P-y-t-h-o-n”.split(“-“,3))
a. [‘P’, ‘y’, ‘t’, ‘h-o-n’] 
b. [‘P’, ‘y’, ‘t-h-o-n’]
c. [‘P’, ‘y-t-h-o-n’]
d. None of the above

Show Answer ⟶
a. [‘P’, ‘y’, ‘t’, ‘h-o-n’]

String in Python Class 11 MCQ

55. What will be the output of the following python code
print(“Welcome to my School”.find(“my”,4))
a. 09
b. 10
c. 11 
d. 12

Show Answer ⟶
c. 11

56. Which of the following is known as mapping data type?
a. List
b. Dictionary 
c. Tuple
d. String

Show Answer ⟶
b. Dictionary

57. What will be the output of the following python code.
str1 = “Welcome to my School”
str1.index(“School”)
a. Value Error
b. No Output 
c. Syntax Error
d. None of the above

Show Answer ⟶
b. No Output

58. The third parameter of a slice operation can also be used to specify the _________.
a. Step Size 
b. Indexing
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Step Size

59. What will be the output of the following python code.
print(“Welcome to my School”.count(“m”,0))
a. 0
b. 1
c. 2 
d. 3

Show Answer ⟶
c. 2

String in Python Class 11 MCQ

60. The reverse string will be returned by which of the following?
a. str[::1]
b. str[::-1] 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. str[::-1]

61. What will be the output of the following python code.
str1 = “Python”
print(str1.find(‘h’))
a. 3 
b. 5
c. 2
d. 6

Show Answer ⟶
a. 3

62. What will be the output of the following python code.
str1=”Python”
print(str1.islower())
a. Error
b. True
c. False 
d. None of the above

Show Answer ⟶
c. False

63. What will be the output of the following python code.
str1=”PYTHON”
print(str1.title())
a. PYTHON
b. pYTHON
c. Python 
d. None of the above

Show Answer ⟶
c. Python

64. What will be the output of the following python code.
str1=”Python Python Python Python”
print(str1.count(“Python”))
a. 3
b. 4 
c. 5
d. 6

Show Answer ⟶
b. 4

String in Python Class 11 MCQ

65. What will be the output of the following python code.
print(“$”.join(“Python”))
a. p$y$t$h$o$n
b. P$y$t$h$o$n 
c. $p$y$t$h$o$n
d. $P$y$t$h$o$n

Show Answer ⟶
b. P$y$t$h$o$n

66. Which of the python function return Boolean value?
a. index()
b. find()
c. endwith() 
d. None of the above

Show Answer ⟶
c. endwith()

67. The word(s) separated by the specified substring are returned by the split() function.
a. Tuple
b. List 
c. Dictionary
d. None of the above

Show Answer ⟶
b. List

68. When using the split() method, words are separated by ______ if a delimiter is not provided.
a. Semi colon
b. Comma
c. Colon
d. Space 

Show Answer ⟶
d. Space
omputer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer Science Class 11 Practical Questions and Answers

Python Function Questions and Answers

Teachers and Examiners (CBSESkillEduction) collaborated to create the Python Function Questions and Answers. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

Python Function Questions and Answers

1. Observe the following programs carefully, and identify the error:
a) def create (text, freq):
for i in range (1, freq):
print text
create(5) #function call
Answer –
There are two errors in the program –
i) The arguments in not declare properly.
ii) In the print statement text sould be written in double quotes print “text”

b) from math import sqrt,ceil
def calc():
print cos(0)
calc() #function call
Answer –
There are two errors in the above program –
i) In the header import function is written defferent and the function used in the prgram is different
ii) The declaration of print statement is wrong example, print(cos(0))

c) mynum = 9
def add9():
mynum = mynum + 9
print mynum
add9() #function call
Answer –
There are two errors in the above program –
i) mynum variable is declare outside of the function, if you want to use then you have to used global variable.
ii) Print statment is written wrong. It should be print(mynum)

d) def findValue( vall = 1.1, val2, val3):
final = (val2 + val3)/ vall
print(final)
findvalue() #function call
Answer –
There are three errors in the above program –
i) Inside the function there are three parameters but in the calling function no parameters are declare
ii) There are no arguments declare in the calling function
iii) ‘vall’ is already initialized as ‘vall = 1.0’, it is called ‘Default parameters’

e) def greet():
return(“Good morning”)
greet() = message #function call
Answer –
There are one errers in the above prgram –
i) Insilizetion is not possible in fucntion for example message = greet()

Python Function Questions and Answers

2. How is math.ceil(89.7) different from math.floor(89.7)?
Answer – math.ceil(89.7) will give output in whole number “90”, but math.floor(89.7) will given output “89”

3. Out of random() and randint(), which function should we use to generate random numbers between
1 and 5. Justify.
Answer – randint(), and random() functions are used to return from a given range of integers. The function “randint (a, b)” will produce a random integer with the specified parameters. The function “random ()” produces a random floating point number between 0 to1.

4. How is built-in function pow() function different from function math.pow() ? Explain with an example.
Answer – Function pow() will return number while math.pow() function will return value in decimal.
Example –
i) print(pow(3, 3)) will return 27
ii) print(math.pow(3, 3)) will return 27.0

5. Using an example show how a function in Python can return multiple values.
Answer –
def myfunction ( ) :
return 1, 2, 3
a, b, c = myfunction ( )
print ( a )
print ( b )
print ( c )

Python Function Questions and Answers

6. Differentiate between following with the help of an example:
a) Argument and Parameter
b) Global and Local variable
Answer –
a) Arguments are the values that are declared inside a function at the time the function is called. In comparison, a parameter is a set of variables that are specified at the time the function is called.
Example –
def myfunction(a,b):
return a + b
sum = myfunction(2, 4)
print(“Sum is = “, sum)

b) A variable that is defined outside of any function or block is referred to as a global variable. Any change made to the global variable will impact all the functions in the program.

A local variable is one that is declared inside any function or block. Only the function or block where it is defined, can access it.
Example –
str = “Good Morning” # Global Variable
def myfunction():
str1 = “Good Night” #Local Variable
print(str1) #local variable accessed
print(str) #Global variable accessed
myfunction()

7. Does a function always return a value? Explain with an example.
Answer – It’s not necessary for a function to return a value. The return statement is used to return a value in a user-defined function.

Suggested Lab. Exercises

1. Write a program to check the divisibility of a number by 7 that is passed as a parameter to the user defined function.
Answer –
def myfunction(num):
if num % 7 == 0:
print(“Divisible by 7”)
else:
print(“Not divisible by 7”)
n = int(input(“Enter number”))
myfunction(n)

Output
Enter number 7
Divisible by 7

Enter number8
Not divisible by 7

2. Write a program that uses a user defined function that accepts name and gender (as M for Male, F for Female) and prefixes Mr/Ms on the basis of the gender.
Answer –
def myfunction(name, gender):
if gender == ‘F’:
print(“Name is :”, “Ms. ” + name)
elif gender == ‘M’:
print(“Name is :”, “Mr. ” + name)
else:
print(“Select only M/F in Capital as gender”)
n = input(“Enter name “)
g = input(“Enter gender M/F in Capital “)
myfunction(n, g)

Output
Enter name Anurag
Enter gender M/F in Capital M
Name is : Mr. Anurag

Python Function Questions and Answers

3. Write a program that has a user defined function to accept the coefficients of a quadratic equation in variables and calculates its determinant. For example : if the coefficients are stored in the variables a,b,c then calculate determinant as b2-4ac. Write the appropriate condition to check determinants on positive, zero and negative and output appropriate result.
Answer –
def myfunction(a, b, c):
determinant = b**2 – 4 * a * c
if (determinant > 0):
print(“The quadratic equation has two real roots.”)
elif (determinant == 0):
print(“The quadratic equation has one real root.”)
else:
print(“The quadratic equation doesn’t have any real root.”)

a = int(input(“Enter the value of a: “))
b = int(input(“Enter the value of b: “))
c = int(input(“Enter the value of c: “))
myfunction(a,b,c)

Output
Enter the value of a: 2
Enter the value of b: 5
Enter the value of c: 7
The quadratic equation doesn’t have any real root.

4. ABC School has allotted unique token IDs from (1 to 600) to all the parents for facilitating a lucky draw on the day of their Annual day function. The winner would receive a special prize. Write a program using Python that helps to automate the task.(Hint: use random module)
Answer –
import random
winner = random.randint(1, 600)
print(” Winner Token IDs : “, winner)

Output
Winner Token IDs : 505

Python Function Questions and Answers

5. Write a program that implements a user defined function that accepts Principal Amount, Rate, Time, Number of Times the interest is compounded to calculate and displays compound interest.
(Hint: CI = ((P*(1+R/N))NT)
Answer –
def myfunction(principal, interest, year, n):
amount = principal * (1 + interest/100) ** n * year
compoundint = amount – principal
print(“Compound Interest is : “, compoundint)
principal = int(input(“Enter Principal amount : “))
interest = int(input(“Enter Rate of interest : “))
year = int(input(“Enter time period in years : “))
n = int(input(“Enter number of times in which interest is compounded”))
myfunction(principal, interest, year, n)

Output
Enter Principal amount : 5000
Enter Rate of interest : 8
Enter time period in years : 5
Enter number of times in which interest is compounded5
Compound Interest is : 31733.2

Python Function Questions and Answers

6. Write a program that has a user defined function to accept 2 numbers as parameters, if number 1 is less than number 2 then numbers are swapped and returned, i.e., number 2 is returned in place of number1 and number 1 is reformed in place of number 2, otherwise the same order is returned.
Answer –
def myfunction(a, b):
if(a < b):
return b, a
else:
return a, b

n1 = int(input(“Enter first Number: “))
n2 = int(input ( “Enter second Number: “))

n1, n2 = myfunction(n1, n2)
print(“First Number: “, n1)
print(“Second Number: “, n2)

Output
Enter first Number : 6
Enter second Number : 3
First Number : 6
Second Number : 3

omputer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer Science Class 11 Practical Questions and Answers

Flow of Control in Python Class 11 Questions and Answers

Teachers and Examiners (CBSESkillEduction) collaborated to create the Flow of Control in Python Class 11 Questions and Answers. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

Flow of Control in Python Class 11 Questions and Answers

1. What is the difference between else and elif construct of if statement?
Answer – Elif is an acronym for else if. We can check for several expressions with this. If the if condition is False, the next elif block’s condition is checked, and so on. The body of else is executed if all the conditions are false.

2. What is the purpose of range() function? Give one example.
Answer – Python comes with a built-in function called range(). It is used to generate a list of numbers from the specified start value to the specified stop value (excluding stop value). For the purpose of creating a number series, this is frequently used in for loops.

3. Differentiate between break and continue statements using examples.
Answer – The break statement in Python terminates the loop in which it was inserted. A single loop iteration is skipped using a continue statement in Python. In either a for or a while loop, you can use the break and continue statements. You could want to stop a loop in its tracks or skip a specific iteration.
Example –
Example:
for num in range(1,10):
print (num)

OUTPUT:
1
2
3
​4
5
6
7
8
9
10

Flow of Control in Python Class 11 Questions and Answers

4. What is an infinite loop? Give one example.
Answer – The test condition for the loop must finally become false according to the statement contained in the body of the loop; otherwise, the loop will continue indefinitely. So, a loop that never ends is known as an infinite loop.
Example –
i = -1
while(i != 1):
print(1)
i -= 1

5. Find the output of the following program segments:
(i)
a = 110
while a > 100:
print(a)
a -= 2
(ii)
for i in range(20,30,2):
print(i)
(iii)
country = ‘INDIA’
for i in country:
print (i)
(iv)
i = 0; sum = 0
while i < 9:
if i % 4 == 0:
sum = sum + i
i = i + 2
print (sum)
(v)
for x in range(1,4):
for y in range(2,5):
if x * y > 10:
break
print (x * y)
(vi)
var = 7
while var > 0:
print (‘Current variable value: ‘, var)
var = var -1
if var == 3:
break
else:
if var == 6:
var = var -1
continue
print (“Good bye!”)
Answer –
(i) Output
110
108
106
104
102

(ii) Output
OUTPUT:
20
22
24
26
28

(iii) Output
OUTPUT:
I
N
D
I
A

(iv) OUTPUT
12

(v) OUTPUT
2
3
4
4
6
8
6
9

(vi) OUTPUT
Current variable value: 7
Current variable value: 5
Good bye!
Current variable value: 4

Flow of Control in Python Class 11 Questions and Answers

1. Write a program that takes the name and age of the user as input and displays a message whether the user is eligible to apply for a driving license or not.
(the eligible age is 18 years).
Answer –
age = int(input(“Enter your age : “))
if age >= 18:
print(“Eligible for Voting”)
else:
print(“Not Eligible for Voting”)

Output
Enter your age : 20
Eligible for Vote

2. Write a function to print the table of a given number. The number has to be entered by the user.
Answer –
num = int(input(“Enter the number for table: “))
print(“Table – “, num);
for a in range(1,11):
print(num,” × “,a,” = “,(num*a))

Enter the number for table: 8
Table – 8
8 × 1 = 8
8 × 2 = 16
8 × 3 = 24
8 × 4 = 32
8 × 5 = 40
8 × 6 = 48
8 × 7 = 56
8 × 8 = 64
8 × 9 = 72
8 × 10 = 80

3. Write a program that prints minimum and maximum of five numbers entered by the user.
Answer –
max = 0
min = 0
for a in range(0,5):
x = int(input(“Enter the number: “))
if a == 0:
min = max = x
if(x < min):
min = x
if(x > max):
max = x
print(“The largest number is “,max)
print(“The smallest number is”,min)

Output
Enter the number: 63
Enter the number: 21
Enter the number: 49
Enter the number: 75
Enter the number: 25
The largest number is 75
The smallest number is 21

Flow of Control in Python Class 11 Questions and Answers

4. Write a program to check if the year entered by the user is a leap year or not.
Answer –
year = int(input(‘Enter year : ‘))
if (year%4 == 0 and year%100 != 0) or (year%400 == 0) :
print(year, “is a leap year”)
else :
print(year, “is not a leap year”)

Output
Enter year : 2000
2000 is a leap year

5. Write a program to generate the sequence: –5, 10, –15, 20, –25….. upto n, where n is an integer input by the user.
Answer –
num = int(input(“Enter the number: “))
for a in range(1,num+1):
if(a%2 == 0):
print(a * 5, end=”,”)
else:
print(a * 5 * (-1),end=”,”)

Output
Enter the number: 12
> 23
-5,10,-15,20,-25,30,-35,40,-45,50,-55,60,23

6. Write a program to find the sum of 1+ 1/8 + 1/27……1/n3, where n is the number input by the user.
Answer –
sum = 0
n = int(input(“Enter the number: “))
for a in range(1,n+1):
sum = sum + (1/pow(a,3))
print(“The sum of series is: “,round(sum,2))

Output
Enter the number: 10
The sum of series is: 1.2

Flow of Control in Python Class 11 Questions and Answers

7. Write a program to find the sum of digits of an integer number, input by the user.
Answer –
sum = 0
n = int(input(“Enter the number: “))
while n > 0:
num = n % 10
sum = sum + num
n = n//10
print(“The sum of digits is”,sum)

Output
Enter the number: 325
The sum of digits is 10

8. Write a function that checks whether an input number is a palindrome or not.
[Note: A number or a string is called palindrome if it appears same when written in reverse order also. For example, 12321 is a palindrome while 123421 is not a palindrome]
Answer –
rev = 0
n = int(input(“Enter the number: “))
temp = n
while temp > 0:
num = (temp % 10)
rev = (rev * 10) + num
temp = temp // 10
if(n == rev):
print(“Palidrome”)
else:
print(“Not a Palindrome”)

Output
Enter the number: 121
Palidrome

Flow of Control in Python Class 11 Questions and Answers

9. Write a program to print the following patterns:

python patterns


Answer –
i)
n = 3
for i in range (1, n + 1):
blank = (n – i)*” “
count = (2 * i – 1)*”*”
print(blank,count)
for j in range(n – 1, 0, -1):
blank = (n – j)*” “
star = (2 * j – 1)*”*”
print(blank, count)

ii)
n = 5
for i in range (1, n + 1):
blank = (n – i) * ” “
print(blank, end = ” “)
for k in range(i, 1, -1):
print(k, end = ” “)
for j in range(1, i + 1):
print(j, end = ” “)
print()

iii)
n = 5
for i in range (n, 0, -1):
blank = (n – i)*” “
print(blank, end=” “)
for j in range(1, i + 1):
print(j, end=” “)
print()

iv)
n = 3
k = 0
for i in range (1, n + 1):
blank = (n – i)*” “
print(blank, end=’ ‘)
while (k != (2 * i – 1)) :
if (k == 0 or k == 2 * i – 2) :
print(‘*’, end= “”)
else :
print(‘ ‘, end = “”)
k = k + 1
k = 0
print()
for j in range (n – 1, 0, -1):
blank = (n – j)*” “
print(blank, end=” “)
k = (2 * j – 1)
while (k > 0) :
if (k==1 or k == 2*j-1):
print(“*”,end=””)
else:
print(” “,end=””)
k = k – 1
print()

Flow of Control in Python Class 11 Questions and Answers

10. Write a program to find the grade of a student when grades are allocated as given in the table below.
Percentage of Marks Grade
Above 90%  – A
80% to 90% – B
70% to 80% – C
60% to 70% – D
Below 60% – E

Percentage of the marks obtained by the student is input to the program.
Answer –
n = int(input(‘Enter the percentage of the marks: ‘))
if(n > 90):
print(“A”)
elif(n > 80):
print(“B”)
elif(n > 70):
print(“C”)
elif(n >= 60):
print(“D”)
else:
print(“E”)

Output
Enter the percentage of the marks: 99
A

omputer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer Science Class 11 Practical Questions and Answers

Class 11 Flow of Control MCQ

Teachers and Examiners (CBSESkillEduction) collaborated to create the Class 11 Flow of Control MCQ. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

Class 11 Flow of Control MCQ

1. The order of execution of the statements in a program is known as ___________.
a. Flow of control 
b. Flow of structure
c. Flow of chart
d. None of the above

Show Answer ⟶
a. Flow of control

2. Python supports _________ control structures.
a. Selection
b. Repetition
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

Class 11 Flow of Control MCQ

3. Which one is the correct syntax of if statement in python.
a. if condition: 
statement(s)
b. if condition
statement(s)
a. if (condition)
statement(s)
a. if condition then
statement(s)

Show Answer ⟶
a. if condition: statement(s)

4. Number of ________ is dependent on the number of conditions to be checked. If the first condition is false, then the next condition is checked, and so on.
a. Elese if
b. If Else
c. Elif 
d. All of the above

Show Answer ⟶
c. Elif

Class 11 Flow of Control MCQ

5. The statements within a block are put inside __________.
a. Single quotes
b. Double quotes
c. Curly brackets 
d. Square brackets

Show Answer ⟶
c. Curly brackets

6. Leading whitespace (spaces and tabs) at the beginning of a statement is called ________.
a. Indentation 
b. Repetition
c. Code
d. None of the above

Show Answer ⟶
a. Indentation

7. This kind of repetition is also called __________ .
a. Indentation
b. Iteration 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Iteration

8. _________ constructs provide the facility to execute a set of statements in a program repetitively, based on a condition.
a. Conditional Statement
b. Looping Statement 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Looping Statement

9. The statements in a loop are executed again and again as long as particular logical condition remains true.
a. For loop
b. While loop
c. Do-while loop
d. All of the above 

Show Answer ⟶
d. All of the above

Class 11 Flow of Control MCQ

10. What will happen when condition becomes false in the loop.
a. Loop Execute
b. Loop Terminates 
c. Loop Repeat once again
d. All of the above

Show Answer ⟶
b. Loop Terminates

11. What keyword would you add to an if statement to add a different condition?
a. Else if
b. Ifelse
c. elif 
d. None of the above

Show Answer ⟶
c. elif

12. What is the output of the given below program?
if 4 + 2 == 8:
print(“Condition is True”)
else:
print(“Condition is False”)

a. Condition is True
b. Condition is False
c. No Output
d. Error

Show Answer ⟶
b. Condition is False

13. What is the output of the given below program?
if 4 + 2 == 8:
print(“Condition is True”)
else:
print(“Condition is False”)
print(“Welcome”)

a. Condition is True
b. Condition is False 
Welcome
c. Condition is True
Welcome
d. Error

Show Answer ⟶
Condition is False Welcome

14. Find the output of the given Python program?
a = 50
b = 60
if a < 50:
print(“Condition is True”)
if b <= 60:
print(“Condition is True”)
else:
print(“Condition is False”)

a. Condition is True 
b. Condition is False
c. No Output
d. Error

Show Answer ⟶
a. Condition is True

Class 11 Flow of Control MCQ

15. What is the output of the given below program?
a = 35
if a >= 35:
print(“Condition is True”)
if a <= 35:
print(“Condition is True”)
else:
print(“Condition is False”)

a. Condition is True
b. Condition is True 
Condition is True
c. Condition is True
Condition is False
d. Condition is False
Condition is True

Show Answer ⟶
b. Condition is True t
Condition is True

16. Find the output of the given Python program?
a, b, c = 1, 2, 3
if a > 0:
if b < 2:
print(“Welcome”)
elif c >= 3:
print(“Welcome to my School”)
else:
print(“New School”)

a. Welcome
b. Welcome to my School 
c. New School
d. Run time error

Show Answer ⟶
b. Welcome to my School

17. Find the output of the given Python program?
a, b, c = 1, 2, 3
if a + b + c:
print(“Condition is True”)
else:
print(“Condition is False”)

a. Condition is True 
b. Condition is False
c. No Output
d. Runt time error

Show Answer ⟶
a. Condition is True 

18. What is the output of the given below program?
b = 5
if a < b:
print(“Condition is True”)
else:
print(“Condition is False”)

a. Condition is True
b. Condition is False
c. NameError: name ‘a’ is not defined 
d. No Output

Show Answer ⟶
c. NameError: name ‘a’ is not defined

19. What is the output of the given below program?
a = b = true
if (a and b):
print(“Condition is True”)
else:
print(“Condition is False”)

a. Condition is True
b. Condition is False
c. NameError: name ‘true’ is not defined 
d. No Output

Show Answer ⟶
c. NameError: name ‘true’ is not defined

Class 11 Flow of Control MCQ

20. Which of the following is not a Python loop?
a. for loop
b. do-while loop 
c. while loop
d. None of the above

Show Answer ⟶
b. do-while loop

21. Regarding Python loops, which of the following statements is false?
a. Loops are utilized to repeat specific actions.
b. When several statements need to be performed repeatedly until the specified condition turns false, the while loop is employed. 
c. When several statements need to be run repeatedly until the provided condition is true, a while loop is employed.
d. List elements can be repeated through using a for loop.

Show Answer ⟶
b. When several statements need to be performed repeatedly until the specified condition turns false, the while loop is employed.

22. What does range() function returns ?
a. list of numbers.
b. integer object.
c. range object. 
d. None of the above

Show Answer ⟶
c. range object.

23. Which of the following statements about Python loops is True?
a. The keyword “end” should be used to end loops.
b. The components of strings cannot be repeated over using a loop.
c. You can break control from the current loop by using the keyword “break.” 
d. To continue with the remaining statements inside the loop, use the keyword “continue.”

Show Answer ⟶
c. You can break control from the current loop by using the keyword “break.”

24. What will be the output of given Python code?
a=7
b=0
while(a):
if(a>5):
b=b+a-2
a=a-1
else:
break
print(a)
print(b)

a. 4 7
b. 5 9 
c. 4 10
d. 5 3

Show Answer ⟶
b. 5 9

Class 11 Flow of Control MCQ

25. Which of the following is a valid for loop in Python?
a. for i in range(5,5)
b. for i in range(0,5)
c. for i in range(0,5): 
d. for i in range(5)

Show Answer ⟶
c. for i in range(0,5):

26. What will be the output of given Python code?
str=”Welcome”
sum=0
for n in str:
if(n!=”l”):
sum=sum+1
else:
pass
print(sum)

a. 5
b. 6 
c. 4
d. 9

Show Answer ⟶
b. 6

27. How many times will the loop run?
i=5
while(i>0):
i=i-1
print (i)

a. 5 
b. 4
c. 3
d. 2

Show Answer ⟶
a. 5

28. What will be the output of the following code?
x = 12
for i in x:
print(i)

a. 12
b. 1 2
c. Error 
d. None of the above

Show Answer ⟶
c. Error

29. One loop may be used inside another loop using the Python programming language, which is known as?
a. switch
b. foreach
c. nested 
d. forall

Show Answer ⟶
c. nested

Class 11 Flow of Control MCQ

30. Which of the following loop is work on the particular range in python ?
a. while loop
b. for loop 
c. do while loop
d. None of the above

Show Answer ⟶
b. for loop

31.What does break statement do?
a. Stop 
b. Repeat
c. Skip
d. Print

Show Answer ⟶
a. Stop

32. What does continue statement do?
a. Print
b. Stop
c. Skip 
d. Repeat

Show Answer ⟶
c. Skip

33. The if statement is used for _________.
a. Selection making
b. Decision making
c. Both a) and b)
d. None of the above

Show Answer ⟶
c. Both a) and b)

34. ___________ statement iterates over a range of values or a sequence.
a. For 
b. While
c. Do-While
d. None of the above

Show Answer ⟶
a. For

Class 11 Flow of Control MCQ

35. The statements within the body of the ________ must ensure that the condition eventually becomes false; otherwise, the loop will become an infinite loop, leading to a logical error in the program.
a. For loop
b. While loop 
c. Do-While loop
d. None of the above

Show Answer ⟶
b. While loop

36. The __________ statement immediately exits a loop, skipping the rest of the loop’s body. Execution continues with the statement immediately following the body of the loop.
a. Break 
b. Continue
c. Exit
d. None of the above

Show Answer ⟶
a. Break

37. When a _________ statement is encountered, the control jumps to the beginning of the loop for the next iteration.
a. Break
b. Continue 
c. Exit
d. None of the above

Show Answer ⟶
b. Continue

38. A loop contained within another loop is called a __________.
a. Another Loop
b. Nested Loop 
c. Next Loop
d. None of the above

Show Answer ⟶
b. Nested Loop

39. Python executes one statement to another statement from starting to end, this is known as ____________.
a. Selection construct
c. Sequential Construct 
b. Iteration Construct
d. All of the above

Show Answer ⟶
c. Sequential Construct

Class 11 Flow of Control MCQ

40. The sequence in which statements in a programme are executed is referred to as ___________.
a. Constant flow
c. Flow of control 
b. Selection flow
d. None of the above

Show Answer ⟶
c. Flow of control

41. There are _______ types of control structures that Python supports.
a. 4
b. 3
c. 2 
a. 1

Show Answer ⟶
c. 2

42. Which of the following is a Python control structure?
a. Iteration
b. Selection
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

43. With the use of a __________ statement, the idea of decision-making or selection is implemented in programming.
a. For loop
b. While loop
c. If & Else 
d. Break & Continue

Show Answer ⟶
c. If & Else

44. A program’s elif count depends on the _____________.
a. Dependent on the condition 
b. Dependent on the writing methods
c. Dependent on the loop
d. None of the above

Show Answer ⟶
a. Dependent on the condition

Class 11 Flow of Control MCQ

45. ________ is an empty statement in Python.
a. Fail
b. Pass 
c. Null
d. None of the above

Show Answer ⟶
b. Pass

46. There are ______ spaces of indentation around a statement inside of “if.”
a. 4 
b. 8
c. 16
d. 20

Show Answer ⟶
a. 4

47. If the condition is True, Amit wants to display “Welcome,” else “Welcome to my webpage” if the condition is false. Which of the following statements makes it easier to put this into practice?
a. For Statement
b. While Statement
c. If & Else Statement 
d. None of the above

Show Answer ⟶
c. If & Else Statement

48. In order to determine if a number is even or odd, Amit wants to develop a programme. He needs to have a solid understanding of _________ to do this.
a. Conditional Statement 
b. Break Statement
c. Continue Statement
d. None of the above

Show Answer ⟶
a. Conditional Statement

49. When if-elif statement is used in python?
a. Only one condition
b. Multiple condition 
c. Never used
d. None of the above

Show Answer ⟶
b. Multiple condition

50. What is the purpose of “else” statement?
a. It will execute when condition is false 
b. It will execute when condition is true
c. It will never execuite.
d. Both a) and b)

Show Answer ⟶
a. It will execute when condition is false
Computer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer

CBSE Class 11 Getting Started with Python Solutions

Teachers and Examiners (CBSESkillEduction) collaborated to create the CBSE Class 11 Getting Started with Python Solutions. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

CBSE Class 11 Getting Started with Python Solutions

1. Which of the following identifier names are invalid and why?

i.Serial_no.v.Total_Marks
ii.1st_Roomvi.total-Marks
iii.Hundred$vii._Percentage
iv.Total Marksviii.True


Answer –

Invalid IdentifierValid/ InvalidWhy
Serial_no.InvalidPython Identifier can contain underscore (_), but (.) is not allowed.
1st_RoomInvalidIdentifier cannot start with a number.
Hundred$InvalidPython Identifier can contain underscore but other special character like ( !, @, #, $, % etc. ) are not allowed.
Total MarksInvalidSpace in also not allowed in Python identifier.
total-MarksInvalid(-) hyphen is not allowed in Python identifier.
_PercentageValid( _ ) Underscore is allowed in Python identifier.
TrueInvalidKeyword is not allowed as Identifier

2. Write the corresponding Python assignment statements:
a) Assign 10 to variable length and 20 to variable breadth.
b) Assign the average of values of variables length and breadth to a variable sum.
c) Assign a list containing strings ‘Paper’, ‘Gel Pen’, and ‘Eraser’ to a variable stationery.
d) Assign the strings ‘Mohandas’, ‘Karamchand’, and ‘Gandhi’ to variables first, middle and last.
e) Assign the concatenated value of string variables first, middle and last to variable fullname. Make sure to incorporate blank spaces appropriately between different parts of names.

Answer –
a) length = 10, breadth = 20 or length, breadth = 10, 20
b) sum=(length + breadth) / 2
c) stationery = [ ‘Paper’ , ‘Gel Pen’ , ‘Eraser’ ]
d) first = ‘Mohandas’ , middle = ‘Karamchand’ , last = ‘Gandhi’
e) fullname = first + ” ” + middle + ” ” + last

3. Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, last are already having meaningful values):
a) The sum of 20 and –10 is less than 12.
b) num3 is not more than 24.
c) 6.75 is between the values of integers num1 and num2.
d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string ‘last’.
e) List Stationery is empty.

Answer –
a) ( 20 + ( – 10 )) < 12
b) num3 <= 24 or not(num3 > 24)
c) (6.75 >= num1) and (6.75 <= num2)
d) (middle > first) and (middle < last)
e) len(Stationery) == 0

4. Add a pair of parentheses to each expression so that it evaluates to True.
a) 0 == 1 == 2
b) 2 + 3 == 4 + 5 == 7
c) 1 < -1 == 3 > 4

Answer –
a) ( 0 == (1==2))
b) (2 + (3 == 4) + 5) == 7
c) (1 < -1) == (3 > 4 )

5. Write the output of the following:
a) num1 = 4
num2 = num1 + 1
num1 = 2
print (num1, num2)
b) num1, num2 = 2, 6
num1, num2 = num2, num1 + 2
print (num1, num2)
c) num1, num2 = 2, 3
num3, num2 = num1, num3 + 1
print (num1, num2, num3)

Answer –
a) 2, 5
b) 6, 4
c) Error (IndentationError: unexpected indent num3)

6. Which data type will be used to represent the following data values and why?
a) Number of months in a year
b) Resident of Delhi or not
c) Mobile number
d) Pocket money
e) Volume of a sphere
f) Perimeter of a square
g) Name of the student
h) Address of the student

Answer –

Data ValuesData TypeWhy
a) Number of months in a yearIntegerNumber can be store in Integer data type
b) Resident of Delhi or notBooleanThe result can be store in true or false
c) Mobile numberInteger/ StringYou can add mobile number in both data type
d) Pocket moneyFloatThe money can be calculated in the decimal point
e) Volume of a sphereFloatThe volume can be calculated in the decimal point
f) Perimeter of a squareFloatThe perimeter can be calculated in the decimal point
g) Name of the studentStringName contain characters
h) Address of the studentStringAddress contain characters, special symbol, numbers etc.


7. Give the output of the following when num1 = 4, num2 = 3, num3 = 2
a) num1 += num2 + num3
print (num1)
b) num1 = num1 ** (num2 + num3)
print (num1)
c) num1 **= num2 + num3
d) num1 = ‘5’ + ‘5’
print(num1)
e) print(4.00/(2.0+2.0))
f) num1 = 2+9*((3*12)-8)/10
print(num1)
g) num1 = 24 // 4 // 2
print(num1)
h) num1 = float(10)
print (num1)
i) num1 = int(‘3.14’)
print (num1)
j) print(‘Bye’ == ‘BYE’)
k) print(10 != 9 and 20 >= 20)
l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29 >= 29/9)
m) print(5 % 10 + 10 < 50 and 29 <= 29)
n) print((0 < 6) or (not(10 == 6) and (10<0)))

Answer –
a) Output 9
b) Output 1024
c) Output 1024
d) Output 55
e) Output 1.0
f) Output 17.2
g) Output 3
h) Output 10.0
i) Error
j) Output False
k) Output True
l) Output True
m) Output True
n) Output True

8. Categories the following as syntax error, logical error or runtime error:
a) 25 / 0
b) num1 = 25; num2 = 0; num1/num2

Answer –
a) Runtime Error – (ZeroDivisionError: division by zero)
b) Runtime Error

9. A dartboard of radius 10 units and the wall it is hanging on are represented using a two-dimensional coordinate system, with the board’s center at coordinate (0,0). Variables x and y store the x-coordinate and the y-coordinate of a dart that hits the dartboard. Write a Python expression using variables x and y that evaluates to True if the dart hits (is within) the dartboard, and then evaluate the expression for these dart coordinates:
a) (0,0)
b) (10,10)
c) (6, 6)
d) (7,8)

Answer –
a) True
b) False
c) True
d) False

10. Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes as 0 degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale.
(Hint: T(°F) = T(°C) × 9/5 + 32)

Answer –
# boiling – b, freezeing – f, boiling temperature – bt, freezing temperature – ft
b = 100
f = 0
bt = b * (9/5) + 32
ft = f * (9/5) + 32
print (‘ Boiling temperature in Fahrenheit’)
print (bt)
print (‘Freezing temperature in Fahrenheit’)
print (ft)

Output
Boiling temperature in Fahrenheit
212.0
Freezing temperature in Fahrenheit
32.0

11. Write a Python program to calculate the amount payable if money has been lent on simple interest. Principal or money lent = P, Rate of interest = R% per annum and Time = T years. Then Simple Interest (SI) = (P x R x T)/ 100. Amount payable = Principal + SI. P, R and T are given as input to the program.

Answer –
p = float(input(‘Enter principal amount – ‘))
r = float(input(‘Enter the rate of interest – ‘))
t = float(input(‘Enter the time – ‘))
si = (p * r * t)/100
rs = si + p
print(‘Total amount – ‘,rs)

Output
Enter principal amount – 5000
Enter the rate of interest – 6
Enter the time – 2
Total amount – 5600.0

12. Write a program to calculate in how many days a work will be completed by three persons A, B and C together. A, B, C take x days, y days and z days respectively to do the job alone. The formula to calculate the number of days if they work together is xyz/(xy + yz + xz) days where x, y, and z are given as input to the program.

Answer –
x = int(input(‘Number of days required to do the job alone by A – ‘))
y = int(input(‘Number of days required to do the job alone by B – ‘))
z = int(input(‘Number of days required to do the job alone by C – ‘))
calculate = (x * y * z) / (x*y + y*z + x*z)
days = round(calculate,2)
print(‘Total number of days to complete the work together by A, B & C – ‘, days)

Output
Number of days required to do the job alone by A – 10
Number of days required to do the job alone by B – 15
Number of days required to do the job alone by C – 20
Total number of days to complete the work together by A, B & C – 4.62


13. Write a program to enter two integers and perform all arithmetic operations on them.

Answer –
num1 = int(input(“Enter 1st number “))
num2 = int(input(“Enter 2nd number “))
print(“Results:-“)
print(“Addition – “,num1 + num2)
print(“Subtraction – “,num1 – num2)
print(“Multiplication – “,num1 * num2)
print(“Division – “,num1 / num2)
print(“Modulus – “, num1 % num2)
print(“Floor Division – “,num1 // num2)
print(“Exponentiation – “,num1 ** num2)

Output
Enter 1st number 7
Enter 2nd number 4
Results:-
Addition – 11
Subtraction – 3
Multiplication – 28
Division – 1.75
Modulus – 3
Floor Division – 1
Exponentiation – 2401


14. Write a program to swap two numbers using a third variable.

Answer –
num1 = int(input(‘Enter 1st Number ‘))
num2 = int(input(‘Enter 1st Number ‘))
temp = num1
num1 = num2
num2 = temp
print(“After Swap”)
print(“Value of num1 – “, num1)
print(“Value of num2 – “, num2)

Output
Enter 1st Number 6
Enter 1st Number 4
After Swap
Value of num1 – 4
Value of num2 – 6

15. Write a program to swap two numbers without using a third variable.

Answer –
num1 = int(input(‘Enter 1st Number ‘))
num2 = int(input(‘Enter 1st Number ‘))
num1 = num1 + num2
num2 = num1 – num2
num1 = num1 – num2
print(“After Swap”)
print(“Value of num1 – “, num1)
print(“Value of num2 – “, num2)

Output
Enter 1st Number 6
Enter 1st Number 4
After Swap
Value of num1 – 4
Value of num2 – 6

16. Write a program to repeat the string ‘‘GOOD MORNING” n times. Here ‘n’ is an integer entered by the user.

Answer –
str = “GOOD MORNING “
n = int(input(“Enter the terms – “))
if n>0:
print(str * n)
else:
print(“Enter the value more then 0”)

Output
Enter the terms – 5
GOOD MORNING GOOD MORNING GOOD MORNING GOOD MORNING GOOD MORNING

17. Write a program to find average of three numbers.

Answer –
a = 7
b = 8
c = 9
average = (a + b + c)/3
print(“The average of a, b and c is “,average)

Output
The average of a, b and c is 8.0

18. The volume of a sphere with radius r is 4/3πr3. Write a Python program to find the volume of spheres with radius 7cm, 12cm, 16cm, respectively.

Answer –
r1 = 7
r2 = 12
r3 = 16
print(“Volume of Sphere when radius is 7cm “, round((4/3*22/7*r1**3),2))
print(“Volume of Sphere when radius is 12cm “, round((4/3*22/7*r2**3),2))
print(“Volume of Sphere when radius is 16cm “, round((4/3*22/7*r3**3),2))

Output
Volume of Sphere when radius is 7cm 1437.33
Volume of Sphere when radius is 12cm 7241.14
Volume of Sphere when radius is 16cm 17164.19

19. Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the year in which they will turn 100 years old.

Answer –
name = input(“Enter your name: “)
age = int(input(“Enter your age: “))
hundred = 2020 + (100 – age)
print(“Hello”, name,”! You will turn 100 years old in the year”, hundred)

Output
Enter your name: Rajesh
Enter your age: 22
Hello Rajesh ! You will turn 100 years old in the year 2098

20. The formula E = mc2 states that the equivalent energy (E) can be calculated as the mass (m) multiplied by the speed of light (c = about 3×108 m/s) squared. Write a program that accepts the mass of an object and determines its energy.

Answer –
mass = int(input(“Enter the mass “))
energy = mass * ((3 * 10 ** 8) ** 2)
print(“Energy produced by given mass is “,energy)

Output
Enter the mass 50
Energy produced by given mass is 4500000000000000

21. Presume that a ladder is put upright against a wall. Let variables length and angle store the length of the ladder and the angle that it forms with the ground as it leans against
the wall. Write a Python program to compute the height reached by the ladder on the wall for the following values of length and angle:
a) 16 feet and 75 degrees
b) 20 feet and 0 degrees
c) 24 feet and 45 degrees
d) 24 feet and 80 degrees

Answer –
import math
length = int(input(“Enter the length of ladder – “))
degrees = int(input(“Enter the angle in degree – “))
rad = math.radians(degrees)
sin = math.sin(rad)
height = round(length * sin,2)
print(“Height reached by ladder”, height)

Output
Enter the length of ladder – 20
Enter the angle in degree – 70
Height reached by ladder 18.79

Computer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer

Getting Started with Python Class 11 MCQ

Teachers and Examiners (CBSESkillEduction) collaborated to create the Getting Started with Python Class 11 MCQ. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

Getting Started with Python Class 11 MCQ

1. An ordered set of instructions to be executed by a computer to carry out a specific task is called a ___________.
a. Program 
b. Instruction
c. Code
d. None of the above

Show Answer ⟶
a. Program

2. Computers understand the language of 0s and 1s which is called __________.
a. Machine language
b. Low level language
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

3. A program written in a high-level language is called _________.
a. Language
b. Source code 
c. Machine code
d. None of the above

Show Answer ⟶
b. Source code

4. An interpreter read the program statements _________.
a. All the source at a time
b. One by one 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. One by one

5. Python is a __________.
a. Low level language
b. High level language 
c. Machine level language
d. All of the above

Show Answer ⟶
b. High level language

6. Python is __________.
a. Open source language
b. Free language
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

7. Python support __________.
a. Compiler
b. Interpreter 
c. Assembler
d. None of the above

Show Answer ⟶
b. Interpreter

8. Python programs are ___________.
a. Easy to understand
b. Clearly defined syntax
c. Relatively simple structure
d. All of the above 

Show Answer ⟶
d. All of the above

9. Python is _________.
a. Case – sensitive 
b. Non case – sensitive
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Case – sensitive

10. Python is platform independent, meaning ___________.
a. It can run various operating systems
b. It can run various hardware platforms
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

11. Python uses indentation for __________.
a. Blocks
b. Nested Blocks
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

12. To write and run (execute) a Python program, we need to have a ___________.
a. Python interpreter installed on the computer
b. We can use any online python interpreter
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

13. The interpreter is also called python _______.
a. Shell 
b. Cell
c. Program
d. None of the above

Show Answer ⟶
a. Shell

14. To execute the python program we have to use __________.
a. Interactive mode
b. Script mode
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

15. __________ allows execution of individual statements instantaneously.
a. Interactive mode 
b. Script mode
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Interactive mode

16. _________allows us to write more than one instruction in a file called Python source code.
a. Interactive mode
b. Script mode 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Script mode

17. To work in the interactive mode, we can simply type a Python statement on the ________ prompt directly.
a. >>> 
b. >>
c. >
d. None of the above

Show Answer ⟶
a. >>>

18. In the script mode, we can write a Python program in a ________, save it and then use the interpreter to execute it.
a. Prompt
b. File 
c. Folder
d. All of the above

Show Answer ⟶
b. File

19. By default the python extension is __________.
a. .py 
b. .ppy
c. .pp
d. .pyy

Show Answer ⟶
a. .py


20. __________ are reserved words in python.
a. Keyword 
b. Interpreter
c. Program
d. None of the above

Show Answer ⟶
a. Keyword

21. The rules for naming an identifier in Python are ________.
a. Name should begin with an uppercase, lowercase or underscore
b. It can be of any length
c. It should not be a keyword
d. All of the above 

Show Answer ⟶
d. All of the above

22. To define variables in python _______ special symbols is not allowed.
a. @
b. # and !
c. $ and %
d. All of the above 

Show Answer ⟶
d. All of the above

23.A variable in a program is uniquely identified by a name __________.
a. Identifier 
b. Keyword
c. Code
d. None of the above

Show Answer ⟶
a. Identifier

24. Variable in python refers to an ________.
a. Keyword
b. Object 
c. Alphabets
d. None of the above

Show Answer ⟶
b. Object

25. The variable message holds string type value and so its content is assigned within _________.
a. Double quotes “”
b. Single quotes ”
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

26. _________ must always be assigned values before they are used in expressions.
a. Keyword
b. Variable 
c. Code
d. None of the above

Show Answer ⟶
b. Variable

27. ___________ are used to add a remark or a note in the source code.
a. Keyword
b. Source
c. Comment 
d. None of the above

Show Answer ⟶
c. Comment

28. __________ are not executed by a python interpreter.
a. Keyword
b. Source
c. Comment 
d. None of the above

Show Answer ⟶
c. Comment

29. In python comments start from _______.
a. # 
b. @
c. %
d. $

Show Answer ⟶
a. #

30. Python treats every value or data item whether numeric, string, or other type (discussed in the next section) as an _________.
a. Object 
b. Variable
c. Keyword
d. None of the above

Show Answer ⟶
a. Object

31. _________ identifies the type of data values a variable can hold and the operations that can be performed on
that data.
a. Data type 
b. Data base
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Data type

32. Number data type classified into ________.
a. int
b. float
c. complex
d. All of the above 

Show Answer ⟶
d. All of the above

33. ________ data type is a subtype of integer
a. Boolean 
b. string
c. list
d. None of the above

Show Answer ⟶
a. Boolean

34. A Python sequence is an ordered collection of items.
a. Number
b. Sequence 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Sequence

35. Sequence data type is classified into _________.
a. Strings
b. Lists
c. Tuples
d. All of the above 

Show Answer ⟶
d. All of the above

36. __________ is a group of characters in python.
a. Number
b. String 
c. Boolean
d. All of the above

Show Answer ⟶
b. String

37. In the string data type you can store __________.
a. Alphabets
b. Digits
c. Special character including space
d. All of the above 

Show Answer ⟶
d. All of the above

38. _________ is a sequence of items separated by commas and the items are enclosed in square brackets [ ].
a. List 
b. Tuple
c. String
d. None of the above

Show Answer ⟶
a. List

39. __________ is a sequence of items separated by commas and items are enclosed in parenthesis ( ).
a. List
b. Tuple 
c. String
d. None of the above

Show Answer ⟶
b. Tuple

40. _________ is an unordered collection of items separated by commas and the items are enclosed in curly brackets { }.
a. List
b. Set 
c. String
d. None of the above

Show Answer ⟶
b. Set

41. ________ data type cannot have duplicate entries.
a. List
b. Set 
c. String
d. None of the above

Show Answer ⟶
b. Set

42. None is a special data type with a single value. It is used to signify the absence of value in a situation.
a. List
b. Set
c. String
d. None 

Show Answer ⟶
d. None

43. ___________ in Python holds data items in key-value pairs.
a. Dictionary 
b. Set
c. String
d. None

Show Answer ⟶
a. Dictionary

44. Items in a dictionary are enclosed in __________.
a. Parenthesis ()
b. Brackets []
c. Curly brackets {} 
d. All of the above

Show Answer ⟶
c. Curly brackets {}

45. In the dictionary every key is separated from its value using a _________.
a. Colon (:) 
b. Semicolon (;)
c. Comma (,)
d. All of the above

Show Answer ⟶
a. Colon (:)

46. Variables whose values can be changed after they are created and assigned are called __________.
a. Immutable
b. Mutable 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Mutable

47. Variables whose values cannot be changed after they are created and assigned are called _________.
a. Immutable 
b. Mutable
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Immutable

48. When we need uniqueness of elements and to avoid duplicacy it is preferable to use __________.
a. List
b. Set 
c. Tuple
d. All of the above

Show Answer ⟶
b. Set

49.The values that the operators work on are called __________.
a. Operands 
b. Assignment
c. Mathematical Operator
d. All of the above

Show Answer ⟶
a. Operands

50. ____________ that are used to perform the four basic arithmetic operations as well as modular division, floor division and exponentiation.
a. Arithmetic Operator 
b. Logical Operator
c. Relational Operator
d. All of the above

Show Answer ⟶
a. Arithmetic Operator

51. __________ calculation on operands. That is, raise the operand on the left to the power of the operand on the right.
a. Floor Division (//)
b. Exponent (**) 
c. Modulus (%)
d. None of the above

Show Answer ⟶
b. Exponent (**)

52. _____________ compares the values of the operands on either side and determines the relationship among them.
a. Arithmetic Operator
b. Logical Operator
c. Relational Operator 
d. All of the above

Show Answer ⟶
c. Relational Operator

53. _________ assigns or changes the value of the variable on its left.
a. Relational Operator
b. Assignment Operator 
c. Logical Operator
d. All of the above

Show Answer ⟶
b. Assignment Operator

54. Which one of the following logical operators is supported by python.
a. and
b. or
c. not
d. All of the above 

Show Answer ⟶
d. All of the above

55. _________ operator is used to check both the operands are true.
a. and 
b. or
c. not
d. All of the above

Show Answer ⟶
a. and

56. ___________ are used to determine whether the value of a variable is of a certain type or not.
a. Relational Operator
b. Logical Operator
c. Identity Operator 
d. All of the above

Show Answer ⟶
c. Identity Operator

57. ___________ can also be used to determine whether two variables are referring to the same object or not.
a. Relational Operator
b. Logical Operator
c. Identity Operator 
d. All of the above

Show Answer ⟶
c. Identity Operator

58. Membership operators are used to check if a value is a member of the given sequence or not.
a. Identity Operator
b. Membership Operators 
c. Relational Operators
d. All of the above

Show Answer ⟶
b. Membership Operators

59. An __________ is defined as a combination of constants, variables, and operators.
a. Expressions 
b. Precedence
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Expressions

60. Evaluation of the expression is based on __________ of operators.
a. Expressions
b. Precedence 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Precedence

61. Example of membership operators.
a. in
b. not
c. in
d. All of the above 

Show Answer ⟶
d. All of the above

62. Example of identity operators.
a. is
b. is not
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

63. In Python, we have the ____________ function for taking the user input.
a. prompt()
b. input() 
c. in()
d. None of the above

Show Answer ⟶
b. input()

64. In Python, we have the ___________ function for displaying the output.
a. prompt()
b. output()
c. print() 
d. None of the above

Show Answer ⟶
c. print()

65. ____________, also called type casting, happens when data type conversion takes place because the programmer forced it in the program.
a. Explicit conversion 
b. Implicit conversion
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Explicit conversion

66. __________, also known as coercion, happens when data type conversion is done automatically by Python and is not instructed by the programmer.
a. Explicit conversion
b. Implicit conversion 
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Implicit conversion

67. A programmer can make mistakes while writing a program, and hence, the program may not execute or may generate wrong output. The process of identifying and removing such mistakes, also known as __________.
a. Bugs
b. Errors
c. Both a) and b) 
d. None of the above

Show Answer ⟶
c. Both a) and b)

68. Identifying and removing bugs or errors from the program is also known as __________.
a. Debugging 
b. Mistakes
c. Error
d. None of the above

Show Answer ⟶
a. Debugging

69. Which of the following errors occur in python programs.
a. Syntax error
b. Logical error
c. Runtime error
d. All of the above 

Show Answer ⟶
d. All of the above

70. A _________ produces an undesired output but without abrupt termination of the execution of the program.
a. Syntax error
b. Logical error 
c. Runtime error
d. All of the above

Show Answer ⟶
b. Logical error

71. A ___________ causes abnormal termination of the program while it is executing.
a. Syntax error
b. Logical error
c. Runtime error 
d. All of the above

Show Answer ⟶
c. Runtime error

72. Python is __________ language that can be used for a multitude of scientific and non-scientific computing purposes.
a. Open – source
b. High level
c. Interpreter – based
d. All of the above 

Show Answer ⟶
d. All of the above

73. Comments are __________ statements in a program.
a. Non – executable 
b. Executable
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Non – executable

74. __________ is a user defined name given to a variable or a constant in a program.
a. Keyword
b. Identifier 
c. Data type
d. All of the above

Show Answer ⟶
b. Identifier

75. The process of identifying and removing errors from a computer program is called _______.
a. Debugging 
b. Mistakes
c. Error
d. None of the above

Show Answer ⟶
a. Debugging
Computer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer

Introduction to Problem Solving Class 11 Questions and Answers

Teachers and Examiners (CBSESkillEduction) collaborated to create the Introduction to Problem Solving Class 11 Questions and Answers. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

Introduction to Problem Solving Class 11 Questions and Answers

1. Write pseudocode that reads two numbers and divide one by another and display the quotient.
Answer –
Input num1
Input num2
Calculate div = num1 / num2
Print div

2. Two friends decide who gets the last slice of a cake by flipping a coin five times. The first person to win three flips wins the cake. An input of 1 means player 1 wins a flip, and a 2 means player 2 wins a flip. Design an algorithm to determine who takes the cake?
Answer –
Set p1 = 0
Set p2 = 0
For i in range (5):
Input coin
If coin = 1 then
P1 += 1
Elif coin = then
P2 += 1
If p1 > 2 then
P1 wins
Elif p2 > 2 then
P2 wins

3. Write the pseudocode to print all multiples of 5 between 10 and 25 (including both 10 and 25).
Answer –
FOR num := 10 to 25 DO
IF num % 5 = 0 THEN
PRINT num
END IF
END LOOP

4. Give an example of a loop that is to be executed a certain number of times.
Answer –
SET i: = 1
FOR i: = 1 to 10 do
PRINT i
END LOOP

5. Suppose you are collecting money for something. You need ` 200 in all. You ask your parents, uncles and aunts as well as grandparents. Different people may give either ` 10, ` 20 or even ` 50. You will collect till the total becomes 200. Write the algorithm.
Answer –
Step 1 : Start
Step 2 : Set money := 0
Step 3 : While Loop (money <200)
Input money
Step 4 : money = money + money
Step 5 : End Loop
Step 6 : Stop

6. Write the pseudocode to print the bill depending upon the price and quantity of an item. Also print Bill GST, which is the bill after adding 5% of tax in the total bill.
Answer –
INPUT Item
INPUT price
CALCULATE bill := Item * price
PRINT bill
CALCULATE tax := bill * (5 / 100)
CALCULATE GST_Bill := bill + tax
PRINT GST_Bill

7. Write pseudocode that will perform the following:
a) Read the marks of three subjects: Computer Science, Mathematics and Physics, out of 100
b) Calculate the aggregate marks
c) Calculate the percentage of marks
Answer –
INPUT computer, maths, phy
COMPUTE average := (computer + maths + phy) / 3
COMPUTE percentage := (average / 300) * 100
PRINT average
PRINT percentage

8. Write an algorithm to find the greatest among two different numbers entered by the user.
Answer –
INPUT num1, num2
IF num1 > num2 THEN
PRINT num1
ELSE IF num2 > num1 THEN
PRINT num2
END IF

9. Write an algorithm that performs the following: Ask a user to enter a number. If the number is between 5 and 15, write the word GREEN. If the number is between 15 and 25, write the word BLUE. if the number is between 25 and 35, write the word ORANGE. If it is any other number, write that ALL COLOURS ARE BEAUTIFUL.
Answer –
INPUT num
IF num >=5 AND num < 15 THEN
PRINT ‘GREEN’
ELSE IF num >= 15 AND num < 25 THEN
PRINT ‘BLUE’
ELSE IF num >= 25 AND num < 35 THEN
PRINT ‘ORANGE’
ELSE
PRINT ‘ALL COLOURS ARE BEAUTIFUL’
END IF

10. Write an algorithm that accepts four numbers as input and find the largest and smallest of them.
Answer –
INPUT max
SET min := max
FOR i: = 1 to 3 do
INPUT num
IF num<max THEN
SET max :=num
ELSE
SET min := num
END LOOP
PRINT max
PINT min

11. Write an algorithm to display the total water bill charges of the month depending upon the number of units consumed by the customer as per the following criteria:
• for the first 100 units @ 5 per unit
• for next 150 units @ 10 per unit
• more than 250 units @ 20 per unit
Also add meter charges of 75 per month to calculate the total water bill .
Answer –
INPUT units
SET bill := 0
IF units > 250 THEN
CALCULATE bill := units * 20
ELIF units <= 100 THEN
CALCULATE bill := units * 5
ELSE
CALCULATE bill := 100 * 5 + (units – 100) * 10
END IF
END IF
CALCULATE totalBill := bill + 75
PRINT totalBill

12. What are conditionals? When they are required in a program?
Answer – Conditionals are programming language elements used in computer science that execute various computations or actions based on whether a boolean condition supplied by the programmer evaluates to true or false.

When a software needs to calculate a result based on a given circumstance, they are necessary (s).

14. Following is an algorithm for going to school or college. Can you suggest improvements in this to include other options?
Reach_School_Algorithm
a) Wake up
b) Get ready
c) Take lunch box
d) Take bus
e) Get off the bus
f) Reach school or college
Answer –
a) Wake up
b) Brush your teeth
c) Take bath
d) Dress up
e) Eat breakfast
f) Take lunch box
g) Take Bus
h) Get off the bus
i) Reach school or college

15. Write a pseudocode to calculate the factorial of a number (Hint: Factorial of 5, written as 5!=5 4 3 21 ×××× ).
Answer –
INPUT num
SET fact := 1, i := 1
WHILE i <= num DO
CALCULATE fact := fact * i
INCREASE i by 1
END LOOP
PRINT fact

16. Draw a flowchart to check whether a given number is an Armstrong number. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.
Answer –

flow chart of Armstrong number

17. Following is an algorithm to classify numbers as “Single Digit”, “Double Digit” or “Big”.
Classify_Numbers_Algo
INPUT Number
IF Number < 9
“Single Digit”
Else If Number < 99
“Double Digit”
Else
“Big”
Verify for (5, 9, 47, 99, 100 200) and correct the algorithm if required
Answer –
INPUT Number
IF Number <= 9
“Single Digit”
Else If Number <= 99
“Double Digit”
Else
“Big”

18. For some calculations, we want an algorithm that accepts only positive integers upto 100.

Accept_1to100_Algo
INPUT Number
IF (0<= Number) AND (Number <= 100)
ACCEPT
Else
REJECT
a) On what values will this algorithm fail?
b) Can you improve the algorithm?


Answer –
INPUT number
IF (number>0) AND (number <=100)
ACCEPT
Else
REJECT

Computer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions

Computer

error: Content is protected !!