Python One Mark Questions with Answers for Class 12
Python One Mark Questions with Answers for Class 12
According to CBSE Latest Sample Paper – 2024. There are 21 Questions in Section A including Assertion and Reasoning . Each Question is of One Mark. Student has to attempt all the questions. Division is as follows according to CBSE Sample Paper.
- Python ——————- 13 Questions. (including 1 question of Assertion and Reasoning)
- SQL ———————- 5 Questions. (including 1 question of Assertion and Reasoning)
- Networking ————–3 Questions.
Further Analysis of Questions.
- True/False (From Python)
- Output based (from String in Python)
- Boolean Expression
- Output based (from String in Python)
- Output based (from String in Python)
- Output based (from Tuple in Python)
- Exception Handling (from Dictionary in Python)
- Question Regarding remove( ) function in List.
- Error finding question (from Tuple in Python)
- Missing Statement (from File Handling in Python)
- True/False (from Exception Handling in Python)
- Output based (from Function in Python)
- SQL
- SQL
- SQL
- SQL
- Networking
- Networking
- Networking
- Assertion & Reasoning (from Function in Python)
- Assertion & Reasoning (from SQL)
This article will give exposure of all expected Questions of Python(1 mark only), in the same pattern as given in CBSE Sample Paper.
Python One Mark Questions with Answers for Class 12
Q1. Identify the valid identifier out of the following.
- item*qty
- $price
- for
- price
Ans. price
Q2. Write the output of the following
k = ['a', 'b', 'c', 'd', 'e'] print(k[-1 : -7 : -1])
Ans. ['e', 'd', 'c', 'b', 'a']
Q3. Write the full form of CSV.
Ans. CSV Stands for Comma Separated Value
Q4. Write the membership Operator.
Ans. in and not in are two membership operator
Q5. Tuple is a mutable or immutable type(T/F)
Ans. Tuple is Immutable
Python One Mark Questions with Answers for Class 12
Q6. Name a function which is used to create empty dictionary.
Ans. dict( )
Q7. Write the output of the following:
L = list("Python Questions") print(L)
Ans. ['P', 'y', 't', 'h', 'o', 'n', ' ', 'Q', 'u', 'e', 's', 't', 'i', 'o', 'n', 's']
Q8. What is abs( ) function in python?
Ans. abs( ) function returns the absolute value of given number. for example print(abs(-6)) will return 6
Q9. Fill in the blank in the following code:
import _________ print(_______.fabs(8))
Ans. math
Q10. Write the output of the following:
print(st[5 : 9] where st = “python questions”
Ans. n qu
Python One Mark Questions with Answers for Class 12
Q1. Find the invalid identifier from the following:
- Myname
- Yourname
- True
- pricein$
Ans. True and pricein$ are invalid identifier.
Q2. Write the output of the following :
A = [1,2,3,4,5,6,7,8,9] print(A[3,9])
Ans. Error
Q3. _____________ module to be imported to work with CSV file.
Ans. CSV
Q4. Write a mathematical operator which returns the remainder.
Ans. %
Q5. The following declaration is of __________ (Tuple/Dictionary)
A = (“Amit”, “Sumit”, “Naman”)
Ans. Tuple
Python One Mark Questions with Answers for Class 12
Q6. Write the code to create a dictionary of three fruits:
Ans D = {1 : “Apple”, 2 : “Banana”, 3 : “Kiwi”}
Q7. Give example of two mutable data type.
Ans. List and Dictionary
Q8. What do you mean by len( ) function?
Ans. len( ) function returns the number of the elements in the object.
Q9. Write the output of the following:
D = {1 : 40, 2 : 50, 3 : 43} print(D[1])
Ans. 40
Q10. Name a string function which returns the first alphabet of string in upper case and rest in small case.
Ans. capitalize( )
Q1. Identify the invalid identifier and specify the reason.
- Name
- Mytemp
- Templerun
- temp 123
Ans. temp 123 is invalid as spaces are not allowed in identifier.
Q2. Write the code to create an empty list named ‘temp’:
Ans. temp = [ ]
Q3. Write the type of file and the mode of opening file in the following code:
f = open(“data.txt”, “r+”)
Ans. Type of file is : Text File and Mode of opening is : reading and writing
Q4. Name the operator used in the following code and also write the output:
>>>7//3
Ans. Operator used is Integer division(//) and output is 2
Q5. Write the output of the following:
t = (1, 2, 3, "r") print(t[2] + t[-3])
Ans. 5
Python One Mark Questions with Answers for Class 12
Q6. Write the output of the following:
L = list("String") print(L[-5:-1])
Ans. [‘t’, ‘r’, ‘i’, ‘n’]
Q7. Define get( ) function in reference to dictionary.
Ans. get( ) function simply returns the value for a given key. If the key is not available then it returns the None.
Q8. Which function returns this output of the given input string
Input String : python questions Output String : Python Questions
Ans. title( )
Q9. Write the output of the following :
L = {1 : 34, 3 : 45, 5 : 29} s=0 for i in L: s=s+i print(s)
Ans. 9
Q10. What type of error is returned by the following code
s = "python practice" s[5] = 'd
Ans. TypeError
Q1. Which of the following can be used as identifiers in python?
- 4thnum
- Total
- for
- data
Ans. Total and data are valid identifiers.
Q2. Write the output of the following :
L = ["20","30","40","50","60"] if "20" in L: print(not(True))
Ans. False
Q3. Write the code to open binary file “data.dat” in append mode using ‘fobj’ as file handle
Ans. fobj = open(“data.dat” , “ab”))
Q4. Write the output of the following code and also write the name of operator used.
print(34//4)
Ans. Output – 8, Operators used : Integer Division(//)
Q5. Write the output of the following :
L = ["20","30","40","50","60"] s=0 c=3 for i in [1,2,3,5,4]: t=L[c] s=int(t) + i print(s) c=c-1
Ans. Output is 51 42 33 25 64
Python One Mark Questions with Answers for Class 12
Q6. What do you mean by Traversing of String?
Ans. Accessing each element of string is called traversing of string.
Q7. Write the output of the following:
s = "python questions" for i in range(0,10,4): print(s[i+1])
Ans. y n e
Q8. Which function will return the largest value from a list of 10 numbers?
Ans. max( ) function
Q9. Is Tuple mutable or immutable?
Ans. Immutable
Q10. Which function of string return True if the string contains only alphabets?
Ans. isalpha( )
Q1. Find the invalid identifier from the following.
a. Mynum2
b. My2place
c. _myname
d. My name
Ans. d. My name
Q2. Write the output of the following code.
p = (1,2) b = (0,9) print(p+b)
Ans. (1, 2, 0, 9)
Q3. Fill the blanks in the following code :
import ________ with open("Text.csv", 'r') as ________ L = csv.reader(fin) for line in ___: print(___________)
Ans. csv, fin, L, line
Q4. Write the name of the following operator
- //
- %
Ans. 1. Floor Division 2. Modulus
Q5. Which is mutable out of List and String?
Ans. List
Python One Mark Questions with Answers for Class 12
Q6. Write the output of the following:
print((1,2,3,4,5).index(4))
Ans. 3
Q7. Find error in the following code :
a = 7 while (a =>9) print(a)
a = 7 while (a >= 9): print(a)
Q8. Write the output of the following:
print(“Python One Mark Questions with Answers“.upper( ))
Ans. PYTHON ONE MARK QUESTIONS WITH ANSWERS
Q9. What will be return by following code :
def sum(q, e, r): print(q)
Ans. None
Q10. Write the statement to open “data.txt” file in append mode.
Ans. f = open(“data.txt”, “a”)
Python One Mark Questions with Answers for Class 12
Q1. Which of the following are invalid identifiers?
- my_num_1
- 1st_name
- _
- yield
Q2. Write the output of the following.
z = "Python One Mark Questions with Answers" m = "Q" while m in z: print(m)
Ans. Infinite loop (print ‘Q’ infinite times)
Q3. Write the output of the following.
print(2 + 0 == 2)
Ans. True
Q4. Write the output of the following:
L = ['11','22','33','44','55'] D = L D[3]='SONU' print(D)
Ans. [’11’, ’22’, ’33’, ‘SONU’, ’55’]
Q5. Akhil wants to generate random integers between 2 and 9 (including both). He write the following code but missed the arguments in function, so please help him to write the correct code.
import random print(random.randint())
Ans. import random print(random.randint(2,9))
Python One Mark Questions with Answers for Class 12
Q6. Write the output of the following:
D = [11,22,33] D.extend(44,55) print(D)
Ans. Error
Q7. A tuple is declared as List = (1,2,3,4,5). What will be the value of print(List[: : -1])?
Ans. (5, 4, 3, 2, 1)
Q8. Which module to be import to use the “sqrt( )” function?
Ans. Math module
Q9. Fill in the blank to find the maximum value from the list
List = [1,2,3,4,5] print( _____ (List))
Ans. max
Q10. Write the output of the following:
a = "CS" b = "IP" print(a+b, "a+b" ,[a+b])
Ans. CSIP a+b [‘CSIP’]
Python One Mark Questions with Answers for Class 12
Q1. Which of the following is not a valid identifier name in Python?
a) 5NUM b) _Radius_ c) PICKLE d)While
Ans. Invalid identifier is a) 5NUM
Q2. What is the output when following code is executed?
>>>str1=”Python One Mark Questions with Answers”
>>>str1[11 : 15 : ]
Ans. ‘Mark’
Q3. In which mode the following file opens?
f = open(“Data.txt”)
Ans. Read mode
Q4. Which of the following is a invalid relational operator in Python?
a) >= b) < c) >> d) ==
Ans. c) >>
Q5. What type of error is returned by the following statements?
L = (23, 45, 34, 21, 1 )
L[1] = 25
Ans. TypeError
Python One Mark Questions with Answers for Class 12
Q6. Write a statement to declare a blank dictionary named “Dict” by using inbuilt function.
Ans. Dict = dict( )
Q7. Fill in the blank
print(___________(1, 2, 3, 4, 5)) so that output is 5
Ans. max
Q8. Write the output of the following :
list1 = [2 * x for x in range(1,4)]
print(list1)
Ans. [2, 4, 6 ]
Q9. Identify the valid declaration of T:
L = [“J‟, “912‟, “EAR‟, 3]
a) dictionary b) string c) tuple d) list
Ans. List
Q10. Expand LIFO
Ans. Last In First Out
Python One Mark Questions with Answers for Class 12
Q1. Which of the following is a valid identifier name in Python?
a) for b) If c) while d) None of the above
Ans. b) If
Q2. What is the output of the following code
>>>B=”python one mark questions with answers”
>>>B[5:15:2]
Ans. ‘noemr’
Q3. Name any two file access modes in python.
Q4. What is the length of the tuple shown below?
>>>t=((((‘a’,9),’b’,’z’),’c’,2),’d’,0)
>>>t[0]
Ans. (((‘a’, 9), ‘b’, ‘z’), ‘c’, 2)
Q5. Which of the following is a valid Mathematical Operator in Python?
a) ? b) < c) =< d) //
Ans. d) //
Python One Mark Questions with Answers for Class 12
Q6. Identify the valid declaration of ‘C’:
C =(‘I’ , ”Janyary” , 89)
(i)List (ii)Tuple (iii)String (iv)Dictionary
Ans. Tuple
Q7. Name the built-in mathematical function / method that is used to return square root of a
number.
Ans. sqrt( )
Q8. Identify the data type of ‘T’
T = list(tuple( (‘S’, ‘U’, ‘M’ , ‘A’ , ‘N’) ) )
Ans. List
Q9. Write the output of the following python code:
Q = “PHYTHON MARK”
print(Q.isupper( ))
Ans. False
Q10. Which operator is used in the python to import all modules from packages?
(a) . operator (b) * operator (c) -> symbol (d) = operator
Ans. (b)
Python One Mark Questions with Answers for Class 12
Q1. Which of the following is a invalid identifier name in Python? And justify your answer.
a) 23Kg b) 23@Kg c) Kg23 d) Kg_23
Q2. Declare a dictionary with keys 10, 20, 30 and Values ‘A’, ‘B’ and ‘C’ respectively.
Ans. D = { 10 : ‘A’ , 20 : ‘B’ , 30 : ‘C’}
Q3. Name two file modes in which new file created (while opening) if the file does not exist.
Q4. Write the output of the following :
>>> A = “Class XII”
>>> A[-3 : ]
Ans. ‘XII’
Q5. Name the Python Library modules which need to be imported to invoke the load( ) function.
Ans. pickle
Python One Mark Questions with Answers for Class 12
Q6. Write the output of the following :
>>> A = (“10” , “A” , 20 , “B” , 30)
>>> B = A[2 : 4]
>>>type(B)
Ans. <class ‘tuple’>
Q7. Explain floor( ) function with the help of example.
Ans. floor( ) function convert the fraction to the nearest lower whole number. E.g. floor(2.2)= 2 and floor(2.7) = 2
Q8. What will be the output of the following Python code?
>>>A = (11, 22, 33)
>>>2 * A
Ans. ( 11, 22, 33, 11, 22, 33 )
Q9. Name the Python Library modules which need to be imported to invoke the pow( ) function :
Ans. math module
Q10. Identify the valid arithmetic operator in Python from the following.
a) ? b) < c) ** d) and
Ans. c) **
Python One Mark Questions with Answers for Class 12
Q1. Write any two keywords of python.
Ans. True, False
Q2. Write the output of the following.
>>> 123 // 5
Ans. 24
Q3. Name the Python Library modules which need to be imported to invoke the uniform( ) function :
Ans. random module
Q4. A tuple is declared as T = ((100,35), (10,20,40), (50,30), (1, 2, 3, 4))
What will be the value of max(T) ?
Ans. (100,35)
Q5. Evaluate the following expressions:
a) 5<10 or 12<7 and not 3>18
Ans. True
Python One Mark Questions with Answers for Class 12
Q6. How can you access a global variable inside the function, if function has a variable with same name.
Ans. By using keyword ‘global’ before the variable name.
Q7. What do you mean by actual or formal parameters ?
Ans. The variables used in a function call is called actual parameter(s) whereas the list of variables used in the function definition is called formal parameter(s).
Q8. Write a statement to open a file “data.txt” in append mode.
Ans. f = open(“data.txt” , “a”)
Q9. What is random( ) function?
Q10. Expand LIFO.
Ans. Last In First Out
MCQ of Computer Science Chapter Wise
1. Functions in Python
2. Flow of Control (Loop and Conditional statement)
3. 140+ MCQ on Introduction to Python
4. 120 MCQ on String in Python
5. 100+ MCQ on List in Python
6. 50+ MCQ on Tuple in Python
7. 100+ MCQ on Flow of Control in Python
8. 60+ MCQ on Dictionary in Python
Important Links
Disclaimer : I tried to give you the correct “Python One Mark Questions with Answers ” , but if you feel that there is/are mistakes in the “Python One Mark Questions with Answers ” given above, you can directly contact me at csiplearninghub@gmail.com. All Questions given in above article “Python One Mark Questions with Answers” are important from Exam. Reference taken from NCERT book and KV Papers.
Class 12 Computer Science Sample Paper 2020-2021.
Class 12 Computer Science Sample Paper Marking Scheme
Class 12 Computer Science Test Series
Python One Mark Questions with Answers