Question types

Review of Python – 2 question types

95 questions across 7 question groups — pick any mix to generate a Computer Science paper with step-by-step answer keys.

95
Questions
7
Question groups
5
Question types
Sample Questions

Review of Python – 2 questions

One sample from each question group in this chapter. Select any group above to see the full set with answer keys.

Q 7M.C.Q1 Mark
What will be the output? >>>test=”Hello World ” >>>test[6]='t' >>>print(test)
  • A
    Hello
  • B
    Hello torld
  • Error
  • D
    Hello World

Answer: C.

View full solution
Q 8M.C.Q1 Mark
What will be the output? >>>d1 = {“Naveen ”:40, “Shailender ”:45} >>>“Naveen ”in d1
  • 1
  • B
    0
  • C
    None
  • D
    Error

Answer: A.

View full solution
Q 9M.C.Q1 Mark
What will be the output? >>>d1 = {“Naveen ”:40, “Shailender ”:45} >>>d2 = {“Naveen ”:466, “Shailender ”:45} >>>d1==d2
  • A
    1
  • 0
  • C
    None
  • D
    Error

Answer: B.

View full solution
Q 10M.C.Q1 Mark
What is the output of the following piece of code when executed in Python shell? >>>a=(5,6) >>>b=(9,8) >>>c=a+b >>>c
  • (5, 6, 9, 8)
  • B
    (14,14)
  • C
    Error as the tuples are immutable
  • D
    None

Answer: A.

View full solution
Q 121 Marks Each1 Mark

Observe the following Python code very carefully and rewrite it after removing all syntactical errors with each
correction underlined.

View full solution
Q 203 Marks Each3 Marks
Write a script to create a list of names of 10 cities and then
(a) Display the names of all the cities whose names start with 'A'
(b) Count the number of cities whose names do not start with 'A'
View full solution
Q 213 Marks Each3 Marks
Write a script to create a list of names of 10 cities and then
(a) Display all the elements of the list
(b) Display all the elements of the list in reverse order
View full solution
Q 223 Marks Each3 Marks
Write a script to create an empty list and then
(a) Input 10 numbers from the users and store them in the list using append() method
(b) Find the sum of all the even elements present in the list
View full solution
Q 233 Marks Each3 Marks
Write a script to create a list of 10 integers and then
(a) Display all the elements of the list
(b) Display the odd elements of the list
View full solution
Q 255 Marks Each5 Marks

Pawan is confused in understanding Dictionary concept. Help him to understand the concept by choosing the appropriate answer.

(a) Which statement will display Not Available?

(i) Statement 9 (ii) Statement 10

(iii) Statement 11 (iv) Statement 13

(b) Choose the key from Dictionary.

(i) ADMNO (ii) ‘admno ’

(iii) 101 (iv) “Not Available ”

(c) Which statement will display None?

(i) Statement 9 (ii) Statement 10

(iii) Statement 11 (iv) Statement 13

(d) Which Statement will display Tejas?

(i) Statement 8 (ii) Statement 9

(iii) Statement 10 (iv) Statement 11

(e) Choose the identifier.

(i) ADMNO (ii) ‘admno ’

(iii) setdefault (iv) Not Available

View full solution
Q 265 Marks Each5 Marks

The Teacher wrote the following code. Sanya was absent on the day when the topic was taught. Help her to complete the assignment.

Choose the output on the basis of the above code.

(a) Which statement is used to display “HeLLo PyThon ”?

(i) Statement 1 (ii) Statement 12

(iii) Statement 13 (iv) No Statement will display.

(b) Which statement will check for capital letters?

(i) Statement 6 (ii) Statement 7

(iii) Statement 8 (iv) Statement 9

(c) Which statement will convert it into capital letters?

(i) Statement 6 (ii) Statement 7

(iii) Statement 8 (iv) Statement 9

(d) Which is iterative Statement?

(i) Statement 5 (ii) Statement 6

(iii) Statement 8 (iv) There is No iterative Statement.

(e) What will be the output of Python code (Statement 1 to Statement 13)

(i) HeLLo PyThon (ii) No Output

(iii) hEllO pYtHON (iv) Hello Python

View full solution
Q 275 Marks Each5 Marks
Choose the correct option.
(a) What is String data-type in Python?
(i) It is written in double quotes only.
(ii) Its value can be changed.
(iii) It is enclosed in square brackets.
(iv) It is immutable data-type.
(b) Ms. Ragini is confused on the way to compare the strings. Help her in choosing the correct statement.
(i) equal() (ii) equals()
(iii) == (iv) compare()
(c) Tejas is confused in the output of the following code. Help him to choose the correct option.
age = 12
txt = "My name is Tejas, I am ", age
print(txt)
(i) ('My name is Tejas, I am ', 12)
(ii) My name is Tejas, and I am 12
(iii) (My name is Tejas, I am , 12)
(iv) [My name is Tejas, I am , 12]
(d) Help mini to choose the correct output of the following Python code.
rollno = 3
name = "Mini "
Average = 88.76
Txt = "My name is {1}, having roll no {0} and scored {2} percent."
print(Txt.format(rollno, name, Average))
(i) My name is ‘Mini ’, having roll no 3 and scored 88.76 percent.
(ii) My name is Mini, having roll no 3 and scored 88.76 percent.
(iii) ‘My name is Mini, having roll no 3 and scored 88.76 percent.’
(iv) (My name is Mini, having roll no 3 and scored 88.76 percent.)
(e) Help Gurnika to choose the correct option for the following Python code.
b = "Hello, World!"
print(b[-5:2])
(i) Hello, World! (ii) orl
(iii) Error (iv) No Output
View full solution
Q 284 Marks Each4 Marks
Write a script to create a list of 5 integers and then
(a) Create a copy of this list using copy() method
(b) Display both the lists
(c) Input an integer from the user and insert it in the first list at a specific location. The location should also be input from the user. Use insert() method for insertion.
(d) Display both the lists
View full solution
Q 294 Marks Each4 Marks

Write a script to create two lists of 5 floating point values each and then
(a) Sort the first list using sort() method and display it without using any loop
(b) Reverse the second list using reverse() method and display it without using any loop
(c) Append the second list to the first list using extend() method
(d) Delete all the elements from the second list using clear() method
(e) Display the first list (after performing the above operations)
(f) Input an integer from the user and find how many times does it exist in the first list using count() method

View full solution
Q 304 Marks Each4 Marks
Write a script to create a list of 10 random integers and display it. Then input an integer from the user and check whether it is present in the list. If it is present, find its location in the list using index() method and remove it from the list using pop() method. If the element is not present, then display an appropriate message.
View full solution
Q 314 Marks Each4 Marks

Write a script to create a list of 10 random integers and display it. Then input an integer from the user and check whether it is present in the list (use in operator). If it is present in the list, then remove it from the list. If the element is present in the list multiple times then all its occurrences should be removed. (use remove() method). If the element is not present, then display an appropriate message.

View full solution
Q 324 Marks Each4 Marks

Write a script to create a list of 10 random integers and display it. Then input an integer from the user and check whether it is present in the list (use in operator) and display an appropriate message.

View full solution

Generate a Review of Python – 2 paper free

Pick question groups from the list above, set marks and difficulty, and export a branded PDF with step-by-step answer keys. First 3 chapters free — no signup.

Download App