CLASS-XII (SESSION 2021-22) SUBJECT: COMPUTER SCIENCE

2y ago
458 Views
73 Downloads
1.17 MB
59 Pages
Last View : 11d ago
Last Download : 14d ago
Upload by : Elise Ammons
Transcription

https://pythonschoolkvs.wordpress.com/CLASS-XII (SESSION 2021-22)SUBJECT: COMPUTER SCIENCE (083) – PYTHONINDEXCHAPTERNO.CHAPTER NAME (UNIT-1)PAGENO.1REVIEW OF CLASS-XI22FUNCTIONS IN PYTHON143RECURSION264FILE HANDLING285CREATE & IMPORT PYTHON LIBRARIES486IDEA OF EFFICIENCY527DATA STRUCTURE- (STACK AND QUEUE)52By: Vikash Kumar YadavPGT-Computer ScienceK.V. No.-IV ONGC Vadodarahttps://pythonschoolkvs.wordpress.com/Page 1

CHAPTER-1REVIEW OF CLASS-XIQuestions based on python topics of class-XI:1. What is case sensitivity of a language?2. Write name of modes which are used by python interpreter.3. Find valid identifier among the following:(i) and(ii) for is(iii) simple-interest(iv) 4you4. Write the type/name of token for the following:i) 83.95ii) 5. Which of the following operator has right to left associativity in python:(i) %(ii) and(iii) **(iv) 6. How many times the following loop will execute:for L in range(7,29,4):if L%5 0:breakelse:print(L)7. A string is declared as: S “HELLO PROGRAMMER”What will be the output of S.find("GRAM", 2, 15)8. Given the list L [25,8,61,80,54,17,11,99]Write the output of print(L[-2 : -7 : -3])9. Write output for the following python code: K [5,7,8, [10,4], 11,2] print(len(K))10. Write the output of the following python statements (Assume that math modulealready imported):math.floor(-44.6)math.fabs(-67.8)11. Write size (length) of following strings:i) ‘\\’ii) com/Page 2

12. Look at the following python code and find the possible output(s) from the options(i) to (iv) following it.import randomfor i in range(4):VALUE random.randint (4,11) 7print(VALUE, "#", end " ")(i) 10#13#17#12#(iii) 18#12#15#17#(ii) 11#16#17#17#(iv) 14#9#16#12#13. Which type of value does input( ) return?14. Write output for the following: str(print("KVS")) "CBSE"15. Write any four features of python language.16. is known in python:(a) compiler(b) output(c) prompt(d) shell17. Line indentation is rigidly enforced in python:a) True(b) False18. Convert the following mathematical expression into equivalent python expression:𝐾 3 7𝑚(𝑚 𝑛)219. Write difference between mutable and immutable data types. Write name of anytwo immutable data types.20. Rewrite the following code in python after removing all syntax error(s). Underlineeach correction done in the code.for mn in loop(4, 20, 2):if mn%4 0:print("Number is divided by 4")elseprint("Number is not divided by 4)21. Convert the following for loop into while loop without change in output of thecode.for p in range(6,21,3):print(p 2)print("Loop Conversion")22. Evaluate the following expressions:i) True 8ii) 36 % 3 ** 3 // 9 4iii) bool('0') and 13 78https://pythonschoolkvs.wordpress.com/Page 3

23. Consider the following code:str input("Enter a string: ")for j in range(1, 5):if str[-1] 'k':str str[0:2] 'p'elif 'j' in str:str str[1:] 'r'else:str 'T' str[1:] 'z'print(str)What will be the output produced if input is:(i) Joy7k(ii) jump5(iii) 2020HY24. Write a program to search an element in a given list of numbers.25. Write a python code to add 1 in each odd value and 2 in each even value of thelist L.Example:If original elements of the list L are:L [35, 12, 16, 69, 26]The modified list will be:L [36, 14, 18, 70, 28]26. Which type of value does print( ) function return?27. Write the size of following strings:(i)(ii)str1 '''ab\str2 '''abcd\cde'''e'''28. Rewrite the following code after removing the syntax error. Underline eachcorrection.print(x)for i is range(0, -4):print(i)5 7 yPrint(y)29. What is type casting? Write the example of type casting in python.30. Write the following expression in python:(i)𝜋𝑟 2 ��� 𝑃(1 𝑅)𝑇 𝑃100Page 4

31. Write the output of the following expressions:(i) 5.7//2-1 4(ii) 4*2**432. Evaluate the following and write the output of the following:(i) math.fabs(-4.7)(ii) math.floor(78.6)(iii) math.ceil(-3.2)(iv) math.pow(-5,2)33. Write the output of the following programs:(a)for z in range(13,29):if z%3 0:breakelse:print(z)(b)for z in range(13,29):if z%3 0:continueelse:print(z)34. Look at the following python code and find the possible output(s) from the options(i) to (iv) following it. Also, write the highest and lowest values that can bepointed by label LABEL. import random for b in range(5,9):LABEL random.randint (20,26) 7print(LABEL, "@", end " ")(i) 28@30@31@29@(iii) 27@33@29@30@(ii) 29@28@27@29(iv) 31@32@33@27@35. Rewrite following python code fragment using for loop. Output of the programshould not be changed.n 39while(n 45):print(“Python”)n 2https://pythonschoolkvs.wordpress.com/Page 5

36. Suppose that L is a list as given below:[“Book”, “is”, “the”, [“best”, “friend”], “of”, “a”, “human”, “being”]What does each of the following expressions evaluate to ?(i) L[3:4][0](ii) L[3:4][0][1](iii) L[3:4][0][1][3](iv) “modern” in L37. Carefully go through the code given below and answer the questions based on it:thestr “This is a test”inputInt int(input( “ Enter an integer :” ))testStr theStrwhile inputInt 0:testStr testStr[1:-1]inputInt inputInt – 1testBool ‘t’ in tement-2print(testBool)#statement-3(i) Given the input integer 3, what output is produced by statement-1 ?(ii) Given the input integer 3, what output is produced by statement-2 ?(iii) Given the input integer 2, what output is produced by statement-3 ?38. Write difference between the following:(i) del and pop( )(ii) append( ) and extend( )(iii) list and tuple(iv) id( ) and type( )39. Write the valid identifiers among the following:data, global, with8, 23file, AND, file, data-rec, my.data40. if s1 ’xyz’ and s2 input(“Enter a string:”)if a user enters the string ‘xyz’ then what will be the output of the followingstatements: s1 s2 s1 is s2https://pythonschoolkvs.wordpress.com/Page 6

41. Evaluate the following and write the output of the following:(i) 0 or None and “none”(ii) 1 or None and “you” or “me”(iii) (6 19) or (30 80/0)(iv) bool(‘0’) and 13 7842. Write the valid identifiers among the following:bool, and, 8digit, Sum, first second, Hello7, min value, Else43. Write type of token for the following:(i) 88.7(ii) continue44. Write name of python module which is to be imported in program to use thefollowing functions:(i) ceil ( )(ii) date( )45. Write the output of the following python statements:(i) type(7 3)(iii) bool('0') and 13 78(ii) 36 % 3 ** 3 // 9 4(iv) True 846. Look at the following python code and find the possible output(s) from the options(i) to (iv). Also, write the Maximum and Minimum values that can be pointed bylabel LBL.import randomVALUE random.randint(2,7)LBL VALUE 3while VALUE LBL:print(VALUE, end '@')VALUE VALUE 1(i) 1@2@3@(iii) 6@7@8@(ii) 2@3@4@(iv) 8@9@10@47. Write the output of the following python code:for dept in ['Research', 'Marketing', 'Production', 'HR']:print(dept)if dept[0] 'P':https://pythonschoolkvs.wordpress.com/Page 7

print("Completed")breakelse:print("Traversed")48. Consider a dictionary given below:Marks {‘Physics’ : 67, ’Chemistry’ : 78, ‘CS’ : 75}Write the python statements for the following:(i) Add ‘Maths’ : 71 to the given dictionary.(ii) Update the marks of ‘CS’ 75 to 81.49. Write a statement to add a single element (element is 57) in given tuple:T (15, 28, 45, 78)50. Name the python library need to be imported to invoke following functions:(i) randint( )(ii) date( )51. A string is declared as: S “OFFICIAL WARRANTY”What will be the output of S.find("ARRA", 4, 13)52. Given the list L [23,7,38,82,54,45,10,91]Write the output of print(L[-3 : -8 : -3])53. Evaluate the following expressions:i) 12*(3%4)//2 6**2ii) 54 52 or 23 56 and not 5iii)54. Rewrite the following code in python after removing all syntax error(s). Underlineeach correction done in the code.str list("Python Program@2021')for Y is range(len(str)-1):if Y 7:str[Y] str*2elif(str[Y].isupper():str[Y] str*3elif(str[y].isdigit()):str[Y] 'D'print(str)55. Consider a given list L. Write output for the following code:L ['hurry', 'up', s.wordpress.com/Page 8

L.sort(reverse -2print(L.index('for'))#statement-356. Given the lists L [25,8,61,80,54,17,11,99]Write the output of print(L[-2:-7:-3])57. Suppose a tuple TP is declared as TP (15, 32, 10, 28), which of the following isincorrect?i) print(TP[1])ii) print(max(TP))iii) T[2] 52iv) print(len(TP))58. A string is declared as: S “PERIODIC TEST3”What will be the output of S.find("IODI",2,15)59. Write a statement in Python to declare a dictionary whose keys are ‘Phy’, ‘Chem’,‘Maths’ and values are 68, 74 and 81 respectively.60. Write output for the following: S1 "AISSCE PRACTICE PAPER" S2 S1.split( ) print(type(S2))61. Write output for the following: ‘aBcD’ ‘abCd’62. Find the output - A [17, 24, 15, 30] A.insert( 2, 33) print ( A [-4])63. Which of the following are valid operator in Python:(i) */(ii) is(iii) (iv) like64. Which of the following statements will create a tuple ?(a) Tp1 (“a”, “b”)(b) Tp1 (3) * 3(c) Tp1[2] (“a”, “b”)(d) None of these65. What will be the result of the following code? d1 {“abc” : 5, “def” : 6, “ghi” : 7} print (d1[0])https://pythonschoolkvs.wordpress.com/Page 9

(a) abc(b) 5(c) {“abc”:5}(d) Error66. Find the output of the following: S 1, (2,3,4), 5, (6,7) len(S)67. Which of the following are Keywords in python ?(i) break(ii) check(iii) range(iv) while68. Find the output of the following: Name “Python Examination” print (Name [ : 8 : -1])69. Evaluate the following expressions:a) 12*(3%4)//2 6b) not 12 6 and 7 17 or not 12 470. What possible output(s) are expected to be displayed on screen at the time ofexecution of the program from the following code? Also specify the minimumvalues that can be assigned to each of the variables BEGIN and LAST.import randomVALUES [10, 20, 30, 40, 50, 60, 70, 80]BEGIN random.randint (1, 3)LAST random.randint(2, 4)for I in range (BEGIN, LAST 1):print (VALUES[I], end "-")(i) 30-40-50(iii) 30-40-50-60-(ii) 10-20-30-40(iv) 30-40-50-60-70-71. Find the invalid identifier from the followinga) defb) Forc) bonusd)First Name72. What will be the output of following program:a 'hello' b 'virat'for i in range(len(a)): print(a[i],b[i])73. Give Output:colors ["violet", "indigo", "blue", "green", "yellow", "orange", "red"]del olors)https://pythonschoolkvs.wordpress.com/Page 10

74. Which statement is correct for dictionary?(i) A dictionary is a ordered set of key:value pair(ii) each of the keys within a dictionary must be unique(iii) each of the values in the dictionary must be unique(iv) values in the dictionary are immutable75. If given A 2,B 1,C 3, What will be the output of following expressions:(i) print((A B) and (B C) or(C A))(ii) print(A**B**C)76. What possible outputs(s) are expected to be displayed on screen at the time ofexecution of the program from the following code? Also specify the maximumvalues that can be assigned to each of the variables FROM and TO.import randomAR [20,30,40,50,60,70]FROM random.randint(1,3)TO random.randint(2,4)for K in range(FROM,TO):print (AR[K],end ”#“)(i)10#40#70#(ii)30#40#50#(iii)50#60#70# (iv)40#50#70#77. What will be the output of following program:s "welcome2kv"n len(s)m ""for i in range(0, n):if (s[i] 'a' and s[i] 'm'):m m s[i].upper()elif (s[i] 'n' and s[i] 'z'):m m s[i-1]elif (s[i].isupper()):m m s[i].lower()else:m m '#'print(m)78. Which is the correct form of declaration of dictionary?(i) Day (ii) Day (iii) Day (iv) Day ps://pythonschoolkvs.wordpress.com/Page 11

79. Evaluate the following expressions:(i) not(20 6) or (19 7)and(20 20)(ii) 17%2080. Rewrite the following code in python after removing all syntax error(s). Underlineeach correction done in the code.30 Tofor K in range(0,To)IF k%4 0:print (K*4)Else:print (K 3)81. Consider the following code:import mathimport ))),end ' end ' What could be the possible outputs out of the given four choices?i) 2 3 4ii) 9 4 4iii)16 16 16iv)2 4 982. Find the invalid identifier from the followinga) Subtotal b) assertc) temp calcd) Name283. Which operator is used for replication?a) b) %c) *d) //84. Give the output of the following code:L [ 1,2,3,4,5,6,7]B LB[3:5] 90,34print(L)85. A tuple is declared as T (1,2), (1,2,4), (5,3)What will be the value of min(T) ?86. Which of the following functions generates an integer?a) uniform( )b) randint( )c) random( )d) None of the above87. What is the output of the following code:for i in range(-3,4,2):print(i, end '@')https://pythonschoolkvs.wordpress.com/Page 12

88. Consider the following code and find out the possible output(s) from the optionsgiven below. Also write the least and highest value that can be generated.import random as rprint(10 r.randint(10,15) , end ‘ ‘)print(10 r.randint(10,15) , end ‘ ‘)print(10 r.randint(10,15) , end ‘ ‘)print(10 r.randint(10,15))i) 25 25 25 21ii) 23 27 22 20iii) 23 22 25 20iv) 21 25 20 2489. Suppose a tuple Tup is declared as Tup (12, 15, 63, 80),which of the following is incorrect?a) print(Tup[1])b) Tup[2] 90c) print(min(Tup))d) print(len(Tup))90. Identify the valid declaration of P:P [‘Jan’, 31, ‘Feb’, 28]a. dictionaryb. stringc.tupled. list91. What is the length of the tuple shown below?t (((('a',1),'b','c'),'d',2),'e',3)92. Define the following:(i) docstring(ii) literal93. Write difference between list and tuple.94. Write difference between keyword and identifier.95. What is operator precedence and m/Page 13

CHAPTER-2FUNCTIONS IN PYTHON2.1 Definition: Functions are the subprograms that perform specific task. Functionsare the small modules.2.2 Types of Functions:There are three types of functions in python:1. Library Functions (Built in functions)2. Functions defined in modules3. User Defined FunctionsBuilt in functionsTypes of functionsFunctions defined inmodulesUser defined functions1. Library Functions: These functions are already built in the python library.2. Functions defined in modules: These functions defined in particular modules.When you want to use these functions in program, you have to import thecorresponding module of that function.3. User Defined Functions: The functions those are defined by the user are calleduser defined functions.1. Library Functions in Python:These functions are already built in the library of python.For example: type( ), len( ), input( ), id( ), range( ) etc.2. Functions defined in modules:a. Functions of math module: To work with the functions of math module,we must import math module in program.import mathhttps://pythonschoolkvs.wordpress.com/Page 14

S.No.1FunctionDescriptionsqrt( )Returns the square root of a number2ceil( )Returns the upper integer3floor( )Returns the lower integer4pow( )Calculate the power of a number5fabs( )Returns the absolute value of a number6exp( )Returns the e raised to the power i.e. e3Example math.sqrt(49)7.0 math.ceil(81.3)82 math.floor(81.3)81 math.pow(2,3)8.0 math.fabs(-5.6)5.6 math.exp(3)20.085536923187668b. Function in random module:random module has the following functions: random( ) : returns random value between 0 to 1. It doesn’t include 0and 1. randint(start, stop): returns any integer number from start to stop. Itincludes start and stop also. randrange(start, stop) : returns a number between start and stop. Itdoesn’t include start and stop value.Example:import randomn random.randint(3,7)*The value of n will be 3 to 7.c. Functions in datetime module:It has date function. Which has three parameters named as year, monthand day.3. USER DEFINED FUNCTIONS:The syntax to define a function is:deffunction-name ( parameters) :#statement(s)Where: Keyword def marks the start of function header.https://pythonschoolkvs.wordpress.com/Page 15

A function name to uniquely identify it. Function naming follows thesame rules of writing identifiers in Python. Parameters (arguments) through which we pass values to a function. Theyare optional. A colon (:) to mark the end of function header. One or more valid python statements that make up the function body.Statements must have same indentation level. An optional return statement to return a value from the function.Example:def display(name):print("Hello " name " How are you?")2.3 Function Parameters:A functions has two types of parameters:1. Formal Parameter2. Actual Parameter1. Formal Parameter: Formal parameters are written in the function prototype andfunction header of the definition. Formal parameters are local variables which areassigned values from the arguments when the function is called.Python supports two types of formal parameters:i.ii.Positional parametersDefault parametersi.Positional parameter: These are mandatory arguments. Value must beprovided to these parameters and values should be matched with parameters.Example:Let a function defined as given below:def Test(x,y,z): Then we can call the function using these possible function calling age 16

p,q,r 4,5,6Test(p,q,r)Test(4,q,r)Test(4,5,6)# 3 variables which have values, are passed# 1 Literal value and 2 variables are passed# 3 Literal values are passedSo, x,y,z are positional parameters and the values must be provided theseparameters.ii.Default Parameters: The parameters which are assigned with a value infunction header while defining the function, are known as default parameters.This values is optional for the parameter.If a user explicitly passes the value in function call, then the value which ispassed by the user, will be taken by the default parameter. If no value isprovided, then the default value will be taken by the parameter.Default parameters will be written in the end of the function header, meanspositional parameter cannot appear to the right side of default parameter.Example:Let a function defined as given below:def CalcSI(p, rate, time 5): # time is default parameter here.Then we can call the function using these possible function calling statements:CalcSI(5000, 4.5) # Valid, the value of time parameter is not provided, so it willtake# default value, which is 5.CalcSI(5000,4.5, 6) # Valid, Value of time will be 6Valid/Invalid examples to define the function with default arguments:CalcSI(p, rate 4.5, time 5):#ValidCalcSI(p, rate 4.5, time 5): # ValidCalcSI(p, rate 4.5, time):#Invalid, Positional argument cannot comeafter default#parameterCalcSI(p 5000, rate 4.5, time 5):#Valid2. Actual Parameter: When a function is called, the values that are passed in the callare called actual parameters. At the time of the call each actual parameter is assignedto the corresponding formal parameter in the function definition.Example :https://pythonschoolkvs.wordpress.com/Page 17

def ADD(x, y):parameters#Defining a function and x and y are formalz x yprint("Sum ", z)a float(input("Enter first number: " ))b float(input("Enter second number: " ))ADD(a,b)#Calling the function by passing actual parametersIn the above example, x and y are formal parameters. a and b are actual parameters.Difference between formal parameter and actual parameter:Formal parameterFormal parameters are written inthe function prototype and functionheader of the definition. Formalparameters are local variableswhich are assigned values from thearguments when the function iscalled.Actual parameterWhen a function is called, thevalues th

class-xii (session 2021-22) subject: computer science (083) – python index chapter no. chapter name (unit-1) page no. 1 review of class-xi 2 2 functions in python 14 3 recursion 26 4 file handling 28 5 create & import python

Related Documents:

Number of Clusters XII-9. C) Overlap XII-10. D) An Example XII-10. 5. Implementation XII-13. A) Storage Management XII-14. 6. Results XII-14. A) Clustering Costs XII-15. B) Effect of Document Ordering XII-19. Cl. Search Results on Clustered ADI Collection . XII-20. D) Search Results of Clustered Cranfield Collection. XII-31. 7. Conslusions XII .

websites and helpful for searching stuff related to Board Exam of class X & XII. . Class 12 class 11 Years CBSE Champion Chapterwise Topicwise. KENDRIYA VIDYALAYA SOUTHERN COMMAND LIBRARY PUNE . Physics-Class XII 2020-21 Computer Science XII 2020-21 Biology Class XII

TEKNIK PEMESINAN GERINDA 1 Program Studi: Teknik Pemesinan Kode: TM.TPM-TPG 1 (Kelas XII-Semester 5) . Teknik Pemesinan Frais (TM.TPM-TPF) Teknik Pemesinan Bubut (TM.TPM-TPB) TM.TPM- TPB1 (XI-3) (XII-5) TM.TPM- TPB 2 (XI-4) TM.TPM- TPB 3 TM.TPM- TPB 4 (XII-6) TM.TPM-TPF 1 (XI-3) TM.TPM-TPF 2 (XI-4) TM.TPM-TPF 3 (XII-5) TM.TPM-TPF 4 (XII-6) TM.TPM-TPG 1 (XII-5) TM-MK/EM 1 (X-1) TM.TPM-TPC)1 .

CLASS - L K G St Pauls Vallabh Nagar Year - 2020-21 . 8 Laboratory Manual Math IV APC 9 Learning Science IV Cordova 10 Sahaj Hindi Gram IV Learnwell . 7 Lab Manual Physics XII Elite 8 Lab Manual Chemistry XII Elite 9 Mathematics I XII NCERT 10 Mathematics II XII NCERT 11 Info. Practics XII NCERT

Practical Work in Geography Part I, Class XI, Published byNCERT 4. Fundamentals of Human Geography, Class XII, Published byNCERT 5. India - People and Economy, Class XII, Published byNCERT 6. Practical Work in Geography Part II, Class XII, Published byNCERT Note: The above

Mathematics for class - XII (R.S. Agarwal) Bharati Bhawan Physics Physics 1 & 2 for Class XII NCERT Concept in Physics Part 1 & 2 Bharati Bhawan Lab Manual in Physics for XII Part II Arya REFERENCE BOOK New Era Physics Part 1 & 2 GRB Bathala Pub Chemistry Chemistry for Class XII NCERT

List of Books for Class XII (Commerce & Arts) Session - 2021-2022 Note:- This is the list of recommended books for the New Session(2021-2022) Parents can purchase the books from anywhere. S.No Subject Name of the Book

(ii) Class XI/IX examinations shall be conducted internally by the schools themselves. (iii) The Board will conduct the external examinations at the end of Class XII/Class X. (iv) Class XII/Class X examinations will be based on the syllabi as prescribed by the Board for class XII/X respectively from time to time.