Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
24 views
53 pages
12 TH MLM Comp Sci em
Uploaded by
leo.bloodsweet.19
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save 12 Th Mlm Comp Sci Em For Later
Download
Save
Save 12 Th Mlm Comp Sci Em For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
24 views
53 pages
12 TH MLM Comp Sci em
Uploaded by
leo.bloodsweet.19
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save 12 Th Mlm Comp Sci Em For Later
Carousel Previous
Carousel Next
Download
Save
Save 12 Th Mlm Comp Sci Em For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 53
Search
Fullscreen
Litas advals sem serene GiFA wrew io Crocdflens Gly — G\rsion_md 2 sior() ata om BBL BA a9) sousfiosfi 2 Malwied (epiidin exp) 2020-2021 Minnal kaise an — Seo aiié) HG -5.pspem, M.A.,B.Ed.,M.Sc.,M.Phil.,M.B.A., (YSstronns sede s\sy\o180i Sores SMES torre,12" STD COMPUTER SCIENCE MINIMUM MATERIAL PREPARATION TEAM 4. K.Balamurugan WMCA.,B.Ed.,M-Phil Kabilar Govt.Boys Hr.Sec.School, Tirukoilur 2. V.Ramesh WNCA.,B.Ed.,MPhil A.S.Govt.Girls Hr.sec.School., Tirukoilur 3. P.Thamizhchelvan, M.sc.,B.Ed.,M.Phil Govt.Hr.Sec.School, Nainarpalayam 4. T.Mythili M.sc.,B.€d.,.M.Phil Govt.Girls Hr.Sec.School, Ulundurpet. 5. R.Ambika McA., 8.Ed., MPhil Govt.Girls Hr.Sec.School, Elavanasurkottai.1. FUNCTIONS Section-A Choose the bestanswer (Mark) 1. The smalll sections of code that are used to perform a particular task is called {A) Subroutines (B)Files (C)Pseudocode (D)Modules 2. Which of the following is a unit of code that is often defined within a greater codestructure? A) Subroutines (B) Function (Files (D)Modules 3. Which of the following is a distinct syntacticblock? A) Subroutines (B) Function (C) Definition (D)Modules 4. The variables in a function definition are calledas A) Subroutines (B) Function (©Definition (D)Parameters 5. The values which are passed to a function definition arecalled A) Arguments (B)Subroutines —_(C)Funetion (D)Definition 6. Which of the following are mandatory to write the type annotations in the functiondefinition? A) Curely braces (B) Parentheses_" (C)Square brackets.) indentations Answer the following questions (2Mark) 1. What is asubroutine? © Subroutines are the basic building blocks of computerprograms. * Subroutines are small sections of code that are used to perform a particular task that can beused repeatedly. 2. Define Function with respect to Programminglanguage. © A function is a unit of code that is often defined within a greater codestructure. * A function works on many kinds of inputs and produces a concreteoutput 3. Write the inference you get fromX:=(78). © X:=(78) is a functiondefinition. © Definitions bind values tonames. ‘* Hence, the value 78 bound to the name "X". Section - D Answer thefollowingquestions: (5Mark) 1. What are called Parameters and write a noteon (i) Parameter without Type (ii) Parameter withTypeAnswer: Parameters are the variables in a function definition > Arguments are the values which are passed to a functiondefinition. > Two types of parameter passingare, 1, Parameter WithoutType 2. Parameter WithType L Parameter WithoutType: Let see an example of a function definition of Parameter Without Type: (requires: b>=0 ) (returns: a to the power of b) let ree pow a b: if b=0 then 1 else a * pow a (b-1) * _ Intheabovefunctiondefinitionvariable‘b ‘istheparameterandthevaluepassedtothevariable “b’ is the argument. ‘* The precondition (requires) and postcondition (returns) of the function isgiven. * We have not mentioned any types: (data types). This is called parameter withouttype. + Intheabovefunctiondefinitiontheexpressionhastype ‘int’, sothefunction'sreturntypealsobe ‘int’ by implicit. 2, Parameter WithType: Now Let us write the same function definition with types, (requires: b> 0) (returns: a to the power of b ) let rec pow (a: int) (b: int) : int := if b=0 then 1 else a * pow b (a-1) © Here, whenwewritethetypeannotationsfor, a“and.,b"theparanthesesaremandatory. © This is the way passing parameter with type which helps the compiler to easily inferthem.2. DATA ABSTRACTION Choose the best answer Section -A 1. Which of the following functions that build the abstract data type? (A) Constructors (B) Destructors 2. Which of the following functions that retrieve information from the datatype? (A) Constructors B)Selectors (1Mark) (©yrecursive (D)Nested (Oprecursive (D)Nested 3. The data type whose representation is unknown arecalled (A) Builtin datatype (C) Concretedatatype Answer thefollowingquestions 1, What is abstract datatype? (B) Deriveddatatype (D) Abstractdatatype 5Section-B (2Mark) ‘© Abstract Data type (ADT) is a type or class for objects whose behavior is defined by a set ofvalue and a set ofoperations. 2, Differentiate constructors andselectors. CONSTRUCTORS SELECTORS © Constructors are functions that buildthe abstract datatype. + Selector are functions that retrieve information from the data type. * Constructors create an object, bundling together different pieces ofinformation * Selectorss extract individual pieces of information from the object. Answer thefollowingquestions: Section - D (SMark) 1. How will you facilitate data abstraction. Explain it with suitableexample. > Data abstraction is supported by defining an abstract data type (ADT), which is a collection of constructors andselectors. > Constructors > Selectors a)Constructor: > Constructors are functions that build the abstract datatype. > Constructors create an object, bundling together different pieces ofinformation.> For example, say you have an abstract data type calledcity. > This city object will hold the city"s name, and its latitude andlongitude. > To create a city object, you'd use a function like city = makecity (name, lat,lon). > Here makecity (name, lat, lon) is the constructor which creates the objectcity. ‘b) Selectors: ‘Selectors are functions that retrieve information from the data type. > Selectors extract individual pieces of information from theobject. > To extract the information of a city object, you would use functionslike = getname(city) = getlat(city) = getlon(city) These are the selectors because these functions extract the information of the city object. 3. SCOPING Section -A Choose the best answer (1 Mark) 1. Which of the following refers to the visibility of variables in one part of a program to another part of, the sameprogram. (A) Scope (B)Memory (C)Adadress (D)Accessibility 2. The process of binding a variable name with an object iscalled {A) Scope (B)Mapping (C)latebinding —_(D) earlybinding 3. Which of the following is used in programming languages to map the variable andobject? (A) Bi= (= (D): 4. Containers for mapping names of variables to objects iscalled {A) Scope (B) Mapping (CBinding (D)Namespaces 5. Which scope refers to variables defined in currentfunction? (A) LocalScope (B) Global scope (C)Module scope (D) FunctionScopeSection-B Answer the following questions (2Mark) 1. What is ascope? ‘© Scope refers to the visibility of variables, parameters and functions in one part of a programto another part of the sameprogram. 2. Why scope should be used for variable. State thereason. © The scope should be used for variables because; it limits a variable's scope to a singledefinition. That is the variables are visible only to that part of thecode. 3. What is Mapping? ‘© The process of binding a variable name with an object is calledmapping. ‘© := (colon equal to sign ) is used in programming languages to map the variable and object. 4. What do you mean by amespaces? ‘* Namespaces are containers for mapping names of variables to objects (name : * Example: :=5 Here variable "a™ is mapped to the value "5". Answer the following questions (3Mark) 1. Define Local scope with an example. ‘© Local scope refers to variables defined in currentfunction. * A function will always look up for a variable name in its localscope. * Only if it does not find it there, the outer s copes arechecked. 2. Define Global scope with an example. * A variable which is declared outside of all the functions in a program is known as globalvariable. © Global variable can be accessed inside or outside of all the functions in aprogram. 3. Define Enclosed scope anexample. «A variable which is declared inside a function which contains another function definition with in it, the inner function can also access the variable of the outer function. This scope is called enclosed scope. ‘* When a compiler or interpreter searches for a variable in a program, it first search Local, and then search Enclosingscopes.Section - D Answer the following questions: (5Mark) 1. Explain the types of scopes for variable or LEGB rule withexample. SCOPE: Scope referstothe visibilityof variables parametersandfunctionsinonepartofaprogramtoanother part of the same program. TYPES OF VARIABLE SCOPE: > LocalScope > Enclosed Scope > Global Scope > Built-in Scope LEGB RULE: © The LEGB rule is used to decide the order in which the scopes are to be searched for scoperesolution. © The scopes are listed below in terms of hierarchy (highest tolowest). a : “A i) LOCAL SCOPE; Local scope refers to variables defined in current function. * A function will always look up for a variable name in its localscope. ‘* Only if it does not find it there, the outer scopes arechecked. * Example: 1. DispO: ‘Ourput ofthe Programm Rew 3 pots Disp‘* Oneexecution of the above code the variable a displays the value 7, because it is defined and available in the localscope. ‘Variable whichisdeclaredinsideafunctionwhichcontainsanotherfunctiondefinitionwithinit, the inner function can also access the variable of the outer function. This scope is called enclosed scope. ‘© When a compiler or interpreter searches for a variable in a program, it first search Local, and then search Enclosingscopes. | ssw © IntheaboveexampleDisp | QisdefinedwithinDisp(). Thevariable””a" definedinDisp()canbe even used by Disp1() because it is also a member of Disp(). iii) GLOBAL SCOPE: * Variablewhichisdeclaredoutsideofallthefunctionsinaprogramisknownasglobalvariable. Global variable can be accessed inside or outside of all the functions in aprogram. ° Example: 12 On execution of the above code the variable a which is defined inside the function displays the value 7 for the function call Disp() and then it displays 10, because a is defined in globalscope. iv) BUILT-IN-SCOPE: [Buin Scope asalthenamesthatarepre-loadedintotheprogramscopewhenwestartthe compiler or interpreter. ‘* Any variable or module which is defined in the library functions of a programming language has Built-in or modulescope.4. ALGORITHMIC STRATEGIES Section-A_ Choose the bestanswer (1Mark) 1. The word comes from the name of a Persian mathematician Abu Jafar Mohammed ibn-i Musa al Khowarizmi iscalled? (A) Flowchart (B)Flow (C) Algorithm —(D)Syntax 2. From the following sorting algorithms which algorithm needs the minimum number ofswaps? (A) Bubblesort (B)Quicksort (C)Merge sort (D) Selectionsort 3. Which of the following is not a stable sortingalgorithm? (A) Insertionsort B) Selectionsort (CBubble sort (D) Mergesort Section-B Answer the following questions (2Mark) 1. What is an Algorithm? * Analgorithm is a finite set of instructions to accomplish a particulartask. + Itis a step-by-step procedure for solving a givenproblem. 2. Define Pseudocode. * Pseudo code is a methodology that allows the programmer to represent the implementation ofan algorithm. * Ithas no syntax like programming languages and thus can't be compiled or interpreted by the computer. 3. What is Sorting? © Sorting is a process of arranging group of items in an ascending or descending order. * Bubble Sort, Quick Sort, Heap Sort, Merge Sort, Selection Sort are the various sortingalgorithms. 4. What is searching? Write itstypes. * A Search algorithm is the step-by-step procedure used to locate specific data among a collection of data. © Example: Linear Search, BinarySearchSection - D Answer the following questions: (5 Mark) 1. Explain the characteristics of an algorithm, SS a CS [oor [tenement ‘Simplicity Easy to implement. " Algorithm should be clear and unambiguous. Each of its steps should be clear Unambiguous and must lead to only one meaning. Feasibility Should be feasible with the available resources. Portable inputs. ‘An algorithm should have step-by-step directions, which should be independent Independent of any programming code. ss about Linear search algorithm. LINEAR SEARCH: © Linear search also called sequential search is a sequential method for finding a particular value in a lis © This method checks the search element with each element in sequence until the desired element is found or the list isexhausted. © In this searching algorithm, list need not beordered. Pseudo code; 1, Traverse the array using for loop 2. Inevery iteration, compare the target search key value with the current value of thelist. > If the values match, display the current index and value of the array > If the values do not match, move on to the next array element. If no match is found, display the search element notfound. 3. If no match is found, display the search element notfound.Example: ‘Search thenumber2Sinthearraygivenbelow linearsearchwillgostepbystepinasequential order starting from the first element in the given array. > if the search element is found that index is returned otherwise the search is continued till the last index of thearray. > In this example number 25 is found at index number3. Snippet: Input: values[}={10,12,20,25,30} Target=25 Out " 3. What is Binary search? Explain. BINARY SEARCH: Binary search also called half-interval search algorithm. # It finds the position of a search element within a sortedarray. * The binary search algorithm can be done as divide-and-conquer search algorithm and executes in logarithmic time. Pseudo code for Binary search: 1. Start with the middleelement: a) If the search element is equal to the middle element of the array, then return the index ofthe middle element. b) If not, then compare the middle element with the searchvalue, c) If (Search element > number in the middle index), then select the elements to the right side of the middle index, and go toStep-1. d) If (Search element < number in the middle index), then select the elements to the left side of the middle index, and start withStep-1 2. When a match is found, display success message with the index of the elementmatched. 3. If no match is found for all comparisons, then display unsuccessfulmessage.4. Explain the Bubble sort algorithm © Bubble sort is a simple sorting algorithm, it starts at the beginning of the list of values stored in an array. © Itcompares each pair of adjacent elements and swaps them if they are in the unsortedorder. ‘© This comparison and passed to be continued until no swaps are needed, which shows the values in an array issorted. © It is named so becase, the smaller elements "bubble" to the top of thelist. * Its too slow and less efficient when compared to other sortingmethods. Pseudo code 1. Start with the first element i.e., index = 0, compare the current element with the next element ofthe array. 2. If the current element is greater than the next element of the array, swapthem, 3. If the current element is less than the next or right side of the element, move to the nextelement. * Go to Step | and repeat until end of the index isreached. Similarly, remaining iteration can bedone. © The final iteration will give the sortedarray. © Atthe end of all the iterations we will get the sorted values in an array as givenbelow: 5. PYTHON - VARIABLES AND OPERATORS. Section - A Choose the best answer (Mark) 1. Who developed Python? AQ Ritche B)GuidoVanRossum —_C) Bill Gates D) SunderPitchai 2. The Python prompt indicates that Interpreter is ready to acceptinstruction. Ap>> B)<<< O# D<< 3. Which of the following shortcut is used to create new Python Program? A) Cul +c B) Ctrl +F ©) CulyB D)Ctrl nN 4, Which of the following character is used to give comments in Python Program? At B)& o@ D)$ 5. This symbol is used to print more than one item on a singleline. A)Semicolon(;) —_B)Dollor($) C)comma(.) D)Colon(:)6. Which of the following is not a token? A) Interpreter —_B)Identifiers ) Keyword D)Operators 7. Which of the following is not a Keyword in Python? A) break B) while ©) continue Dooperators 8. Which operator is also called as Comparativeoperator? A)Arithmetic _ B)Relational C)Logical D)Assignment 9. Which of the following is not Logical operator? Ajand B) or C)not D)Assignment 10. Which operator is also called as Conditionaloperator? A) Ternary B)Relational C)Logical D)Assignment 19Section-B Answer the following questions (2Mark) 1, What are the different modes that can be used to test Python Program? ‘* InPython, programs can be written in two ways namely Interactive mode and Scriptmode. ‘* Interactive mode allows us to write codes in Python command prompt ( >>>). ‘© Script mode is used to create and edit python source file with the extension.py 2. Write short notes onTokens. ‘* Python breaks each logical line into a sequence of elementary lexical components known asTokens. ‘© The normal token types are, 1) Identifiers, 2) Keywords, 3) Operators, 4) Delimiters and 5) Literals. 3. What are the different operators that can be used in Python? ‘* Operators are special symbols which represent computations, conditional matching inprogramming. ‘© Operators are categorized as Arithmetic, Relational, Logical, Assignment andConditional. 4. What is a literal? Explain the types of literals ? Literal is a raw data given in a variable orconstant. ‘© InPython, there are various types of literals. Theyare, 1) Numeric Literals consists of digits and areimmutable 2) String literal is a sequence of characters surrounded byquotes. 3) Boolean literal can have any of the two values: True orFalse.Section-C Answer the following questions (3 Mark) 1. Write short notes on Arithmetic operator withexamples. © An arithmetic operator is a mathematical operator used for simplearithmetic. ‘* Ittakes two operands and performs a calculation onthem. 2. What are the assignment operators that can be used inPython? « =" is a simple assignment operator to assign values tovariable. © There are various compound operators in Python like +=, ° Example: a=S ——# assigns the value 5 toa , /=, %o=, **= and//=. a,b=5,10 # assigns the value 5 toa and 10 to b at=2 — #a=a+2,add2tothevalueof,,aandstorestheresultin, a" (Lefthandoperator) 3. Explain Ternary operator withexamples. © Ternary operator is also known as conditional operator that evaluates something based on a condition being true or false. © Itsimply allows testing a condition in a single line replacing the multiline if-else making the code compact. ‘Syntax: Variable Name = [on_true] if [Test expression] else [on_false] Example: min = 50 if 49<50else 70 # Outpul 4. Write short notes on Escape sequences withexamples. = mil «In Python strings, the backslash "\" is a special character, also called the "escape" character. © Itis used in representing certain whitespacecharacters. ‘* Python supports the following escape sequencecharacters. 5. What are string literals?Explain, In Python a string literal is a sequence of characters surrounded byquotes. Python supports single, double and triple quotes for astring. A character literal is a single character surrounded by single or doublequotes. The value with triple-quote "" "" is used to give multi-line stringliteral.° Example: string: chai “This is Python" cr multiline_str = "' This is a multiline string with more than one line code.’ print (strings) print (char) print (multiline_str) © Output: This is Python Cc Thi a multiline string with more than one line code. Section - D Answer the following questions: (5 Mark) 1. Describe in detail the procedure Script modeprogramming.. SCRIPT MODE PROGRAMMING: * Script text file containing the Python statements. * Once the Python Scripts is created, they are reusable , it can be executed again and again without retyping. © The Scripts areeditable. ( Creating Scripts in Pvth 1. Choose File > New File or press Ctrl + N in Python shellwindow. 2. An untitled blank script text editor will be displayed onscreen. 3. Type the code in Script editor, Gi) Saving PvthonSeri (1) Choose File —» Save or Press Ctrl +8 (2) Now, Save As dialog box appears on thescreen. (3) In the Save As dialogbox Select the location to save your Pythoncode. ‘Type the file name in File Namebox. Python files are by default saved with extension.py. So, while creating scripts using Python Script editor, no need to specify the fileextension. (4) Finally, click Save button to save your Pythonscript.Gi Executing P seri (1) Choose Run — Run Module or PressF5 (2) If your code has any error, it will be shown in red color in the IDLE window, and Python describes the type of erroroccurred. > To correct the errors, go back to Script editor, make corrections, save the file and execute itagain. (3) For all error free code, the output will appear in the IDLE window of Python, 2. Explain input() and print() functions withexamples. Input and OutputFunctions Programs needs to interact with the user to accomplish the desired task this can be achieved using Input-Output functions. © The input() function helps to enter data at run time by theuser * The output function print( is used to display the result of the program on the screen afterexecution. DD print0 function python the priint() function is used to display result on the screen. * Syntax for print: print ("string to be displayed as output") print (variable ) print (“String to be displayed as output" variable) print (“Stringl variable, “String 2° variable, “String 3” .....) + Example: >>> print (“Welcome to Python Programming”) Welcome to Python Programming >>> y=6 >>> a=xty >>> print (2) un >>> print (“The sum =", z) ‘The sum = 11 >>> print (“The sum of % x, “and *.y, "is", z) The sum of Sand 6 is 11 © The print () evaluates the expression before printing it on themonitor. © The print () displays an entire statement which is specified within print (). * Comma (, ) is used as a separator in print () to print more than oneitem.Python input() fun yn is used to accept data as input at runtime. © The syntax for input() functionis, Variable = input ("prompt string”) © “Prompt string” in the syntax is a message to the user, to know what input can begiven. © Ifa prompt string is used, it is displayed on the monitor; the user can provide expected data from the inputdevice. © The input() takes typed data from the keyboard and stores in the givenvariable. © If prompt string is not given in input ), the user will not know what is to be typed asinput. ° Example: Example Lipa) with prompt string >> citysinput ("Eater Your City:") Enter Your City: Madurai Example 2:input() without prompt string >> ctyeinpat() Rajarsjan © In Example 1 input() using prompt string takes proper input and produce relevantoutput. © In Example 2 input() without using prompt string takes irrelevant input and produce unexpected output. © So, to make your program more interactive, provide prompt string with input(). InputQ.using Numericalyalues:. © The input () accepts all data as string or characters but not asnumbers. © The int() function is used to convert string data as integer dataexplicitly. ¢ Example: x= int (input(“Enter Number 1:")) y = int (input(“Enter Number 2:")) print (The sum =") x+y) Outpar Enter Number 1: 34 Enter Number 2: 563. Discuss in detail about Tokens inPython., r Python breaks eachn logical line into a sequence of elementary lexical components known as Tokens. © The normal token typesare, 1) Identifiers, 2) Keywords, 3) Operators, 4) Delimiters and 5) Literals. © Whitespace separation is necessary between tokens, identifiers orkeywords. L Identifiers An identifier is a name used to identify a variable,function,class, module or object. © An identifier must start with an alphabet (A..Z or a..z) or underscore ( Identifiers may contain digits (0 ..9) Python identifiers are case sensitive i.e. uppercase and lowercase letters aredistinct. Identifiers must not be a pythonkeyword. Python does not allow punctuation character such as %,$, @ etc., within identifiers. Example of valid identifiers: Sum, total_marks, regno,num1 Example of invalid identifiers: 12Name, name$, total-mark,continue J. ° ° ° ° ° ° 2) Keywords * Keywords are special words used by Python interpreter to recognize the structure ofprogram. * Keywords have specific meaning for interpreter, they cannot be used for any otherpurpose. * Python Keywords: false, class, If, elif, else, pass, breaketc. 3) Operators An Identifier is a name used to identify a variable, function, clas © Operators are categorized as Arithmetic, Relational, Logical, Assignment andConditional. , module or object. * Value and variables when used with operator are known asoperands. print ("The Sum = print ("The a >b print ("The a> bora at=10 print(“The a+=10 is* Output: The Sum = 110 The a>b = True The a>bora==b=True The a+=10 is= 110 4) Delimiters Python uses the symbols and symbol combinations as delimiters in expressions, lists, dictionaries and strings. 3 Literals Literals is a raw data given in a variable or constant. In Python, there are various types of literals. Theyare, 1) Numeric Literals consists of digits and areimmutable 2) String literal is a sequence of characters surrounded byquotes. 3) Boolean literal can have any of the two values: True orFalse. 6. CONTROL STRUCTURES Choose the bestanswer (Mark) 1. How many important control structures are there inPython? AB B)4 o5 D)6 2. elif can be considered to be abbreviationof Ad nestedif B)if..else Qelseit D)if.elif 3. What plays a vital role in Pythonprogramming? AQ Statements B) Control ©)Structure Dindentation, 4, Which statement is generally used as aplaceholder? A) continue B) break C)pass D)goto 5. The condition in the if statement should be in the formof A) Arithmetic orRelationalexpression B) Arithmetic or Logicalexpression ©) Relational orLogicalexpression D)Arithmetic 6. Which is the most comfortableloop? Ad do..while B) while CO for D)if.elif 7. Which amongst this is not a jump statement? Ad for B)goto ©) continue D)break Section-B Answer the following questions (2 Mark) 1. List the control structures inPython. «Three important control structuresare, 1 Sequential 2.Alternative or Branching 3 Iterative or Looping2. Write note on break statement > The break statement terminates the loop containing it. > Control of the program flows to the statement immediately after the body of the loop 2. Write is the syntax of if. Syntax: if
: statements-block else: statements-block 2 3. Define control structure. Isestatement + A program statement that causes a jump of control from one part of the program to another is called control structure or controlstatement. 4. Write note on range () inloop range() generates a list of values starting from start till stop-1 in forloop. © The syntax of range() is asfollows: range (start,stop.[step]) Where, start — refers to the initial value stop — refers to the final value step — refers to increment value, this is optional part. Section-C Answer thefollowingquestions (3Mark) 1. Write a program to display A AB ABC ABCD ABCDE CODE; for i in range(65, 70): for j in range(65, i+1): print(chr(j), end=,, print(end="\n" it=12. Write note on if..else structure. © The if... else statement provides control to check the true block as well as the falseblock. © if..else statement thus provides two possibilities and the condition determines which BLOCK is tobe executed. ‘Syntax: if
: statements-block | else: statements-block 2 3. Using if..clse..clif statement write a suitable program to display largest of 3numbers. CODE: n= int(input("Enter the first number:")) n2= int(input("Enter the second numb ) n3= int(input("Enter the third number:")) if(n1>=n2)and(n1>=n3): biggest=n1; elif(n2>=n1 )and(n2>=1 biggest=n2 else: biggest=n3 print(""The biggest number between" n1,",",n2,"and",n3,"is" biggest) ourPurT Enter the first number: 1 Enter the second number:3 Enter the third number:5 The biggest number between 1 , 3 and 5 is 54, Write the syntax of while loop.Syntax: while
: statements block 1 [else: statements block2] 5. List the differences between break and continuestatements. break continue [The break containing it. The continue Statementisusedtoskipthe statement terminates the loop remmsinidg pat of aloop and Control of the program flows to the statement Control of the program flows start with next immediately afier the body of the loop. iteration. ‘Syntax: ‘Syntax: break continue Section - D Answer the following questions: (5 Mark) 1. Write a detail note on forloop. * for loop is the most comfortable loop. Itis also an entry checkloop. © The condition is checked in the beginning and the body of the loop(statements-block 1) is executed if it is only True otherwise the loop is notexecuted. ‘Syntax: for counter_variable in sequence: statements-block 1 [else: _ # optional block statements-block2] © The counter_variable is the controlvariable. © The sequence refers to the initial, final and incrementvalue. * for loop uses the range() function in the sequence to specify the initial, final and incrementvalues.range() generates a list of values starting from start tillstop-1. © The syntax of range() is asfollows: range (start,stop,{step]) Example: for i inrange(2,10, print (i,end=") else: print ("\nEnd of the loop") Output: 2468 End of the loop 32 2. Write a program to display all 3 CODE: Jower=int(input("Enter the lower limit for the range:")) upper=int(input("Enter the upper limit for the range:")) for i in range(lower,upper+1): ifi%2!=0): print(iend="") dower lame upper limic (os 107 109 31: 9 118 127 119 121 129 125 12 291 199 195 197 199 141 243 245 147 149 7. PYTHON FUNCTIONS Section-A Choose the bestanswer (Mark) 1. A named blocks of code that are designed to do one specific job is calledas (a) Loop (b) Branching {Function (d)Block 2. A Function which calls itself is calledas (a) Built-in ) Recursion (c)Lambda (return 3. Which function is called anonymous un-namedfunction (b) Lambda (b) Recursion: (c)Function (d)define4.In which arguments the correct positional order is passed to function? (©) Required. () Keyword (c)Default (@Variable-length 5. Pick the correct one to execute the given statementsuccessfully. if print(x, " is a leapyear") a) x%2=0 (b)x%4==0 (©) x/4=0 (d)x%4=0 6. Which of the following keyword is used to define the function testpython():? A) define (b)pass det (@while Section-B Answer the following questions (2Mark) 1, What is function? © Functions are named blocks of code that are designed to do one specificjob. + Types of Functions are User defined, Built-in, lambda and recursion. © Function blocks begin with the keyword “def” followed by function name and parenthesis() 2 Write the different types of function. 1.User Defined function 2.Built-in Function 3.Lambda Function 4.Recursion Function 3. What are the main advantages offunction? Main advantages of functions are, © Itavoids repetition and makes high degree of codereusing. © It provides better modularity for yourapplication. 4, What is meant by scope of variable? Mention itstypes. © Scope of variable refers to the part of the program, where it is accessible, i.e., area where you can refer (use)it. © Scope holds the current set of variables and theirvalues. © The two types of scopes are- local scope and globalscope. 5. Define globalscope. * A variable, with global scope can be used anywhere in theprogram. © Itcan be created by defining a variable outside the scope of any function/block.Section-C Answer the following questions (3Mark) 1. Write the rules of local variable. + A variable with local scope can be accessed only within the function/block that it is createdin, + When a variable is created inside the function/block, the variable becomes local toit. + A local variable only exists while the function isexecuting. + The formal arguments are also local tofunction. 2. Write the basic rules for global keyword inpython, The basic rules for global keyword in Python are: + Whenwedefineavariableoutsideafunction,it'sglobalbydefault. Youdon"thavetouseglobal keyword, + We use global keyword to read and write a global variable inside afunction.Use of global keyword outside a function has noeffect. 3. Write a Python code to check whether a given year is leap year or not., CODE: n=int(input("Enter the year")) if(n%4==0): print ("Leap Year") else: print ("Not a Leap Year") Output: Enter the year 2012 Leap Year Section - D Answer the following questions: (5Mark) 1. Explain the different types of function with an example. © Functions are named blocks of code that are designed to do one specificjob. * Types ofFunctions: User Defined Function * Built-in Funetion * LambdaFunction © RecursionFunctionBUILT-IN FUNCTION: Built in functions are Functions that are inbuilt with in Python. + print, echo() are some built-infunction. + Functions defined by the users themselves are called user definedfunction. © Functions must be defined, to create and use certainfunctionality. Function blocks begin with the keyword “def” followed by function name and parenthesis() When defining functions there are multiple things that need to benoted; . “det” Any input parameters should be placed within theseparentheses. * The code block always comes after a colon (:) and isindented. © The statement “return [expression]” exits a function, and it isoptional. * A “return” with no arguments is the same as returnNone. iii) LAMBDA FUNCTION: .anonymousfunctionisafunctionthat isdefinedwithoutaname. + While normal functions are defined using the def keyword, in Python anonymous functions are defined using the lambdakeyword. + Hence, anonymous functions are also called as lambdafunctions. USE OF LAMBDA OR ANONYMOUS FUNCTION: + Lambda function is mostly used for creating small andone-time anonymous function. + Lambda functions are mainly used in combination with the functions like filter(), map() and reduce(), iv) RECURSIVE FUNCTION: Functions that calls itself is known as recursive. Overview of how recursive function works 1. Recursive function is called by some externalcode. i . If the base condition is met then the program gives meaningful output andexits 3. Otherwise, function does some required processing and then calls itself to continuerecursion.8. STRINGS AND STRING MANIPULATION Section-A Choose the best answer (Mark) 1. Which of the following is the output of the following pythoncode? strl="TamilNadu" print(strl[::-1)) (a) Tamilnadu (b)Tmlau (©udanlimaT @udaNlimaT 2. What will be the output of the following code? strl = "Chennai Schools" str1 [7] (a) Chennai-Schools (b)Chenna-School ()Typeerror — (d)Chennai 3. Which of the following operator is used forconcatenation? (a+ )& (o)* (d= 4, Defining strings within triple quotes allows creating: (a) SinglelineStrings _(c) MultiLineStrings (©) DoublelineStrings (a) MultipleStrings 5. Strings inpython: (a) Changeable (b) Mutable (Immutable —_(d)flexible Which of the following is the slicingoperator? 6. What isstride? (a) index value ofslideoperation (b) first argument of sliceoperation (©) second argument ofslice operation (d) third argument of sliceoperation 7.The subscript of a string maybe: (a) Positive (b)Negative (c) Both (a)and(b) (Either (a) or(b) Section-B Answer thefollowingquestions (2Mark) 1, What isString? © String is a data type in python, used to handle array ofcharacters. © String is a sequence of characters that may be a combination of letters, numbers, orspecial symbols enclosed within single, double or even triplequotes. 2. How will you delete a string inPython? © Python will not allow deleting a particular character in astring. © Whereas you can remove entire string variable using delcommand. o Example: del str1(2]3. What will be the output of the following pythoncode? strl = “School” print(str1*3) OUTPUT: School School School 4. What isslicing? © Slice is a substring of a mainstring. © A substring can be taken from the original string by using [ ] slicing operator and index or subscript values. © Using slice operator, you have to slice one or more substrings from a mainstring. General format of slice operation: str[start:end] Section-C Answer the following questions (3Mark) 1. Write a Python program to display the given pattern COMPUTER COMPUTE compur compu comp com co c CODE: str="COMPUTER" index=len(str) for i in str: print(str[:index])Answer the following questions: (SMark) 1. Explain about string operators in python with suitable example. STRING OPERATORS Python provides the following string operators to manipulate string. nc : Joining two or more strings using +)operatoriscalledasConcatenation. Example >>> "welcome" + "Python" Qutput; — 'welcomePython’ a ~ Adding more strings at the end of an existing string using operator+=isknownasappend. Exampl D> s ="Welcome to" >>> strl+="Learn Python" >>> print (strl) Output; Welcome to LearnPython Multiplication operator(*) is used to display a string in muttiple number of times. Example: >>> str ‘Welcome " >>> print (strl*4) Output; Welcome Welcome WelcomeWelcome Gv) String stci Slice is a substring of a main string. * A substring can be taken from the original string by using [] sl ing operator and indexvalues. © Using slice operator, you have to slice one or more substrings from a mainstring. General format of slice operation; str[start:end] © Where start is the beginning index and end is the last index value of a character in thestring. © Python takes the end value less than one from the actual indexspecified.Example; slice a single character from a string >>> strl="THIRUKKURAL" >>> print (str1[0) Output: = T ©) Suri Jicing stri ‘When the slicing operation, you can specify a third argument as the stride, which refers to the number of characters to move forward after the first character is retrieved from the string. © The default value of stride is1. © Python takes the last value asn-1 * You can also use negative value as stride, to prints data in reverseorder. Example: >>> str "Welcome to learn Python" >>> print (str1[10:16]) >>> print(strl[::-2]) Output; = Learn nhy re teolW 9, LISTS, TUPLES, SETS, AND DICTIONARY Section-A. Choose the best answer (Mark) 1. Pick odd one in connection with collection datatype {a) List (b)Tuple (©) Dictionary (@Loop 2. Let list =[2,4,6,8,10), then print(List -2)) will resultin (a)l0 (8 (4 (a6 3. If List=[10,20,30,40,50] then List{2}=35 willresult (a)[35,10,20,30,40,50] (b)[10,20,30,40,50,35] £0)110,20,35,40,50] (d)[10,35,30,40,50] What will be the result of the following Python code? S=[x**2 for x inrange(5)] print(S) (a)[0,1,2,4,5] (y10.1.4.9.16) (c)[0,1,4,9,16,25] (@L.4,9,16,25] 5. What is the use of type() function inpython? A)To createaTuple (b) To know the type of an element intuple. (d) To create alist.6.Let setA=(3,6,9}, setB=(1,3,9}. What will be the result of the followingsnippet? print(setA|setB) (a){3.6, 9} (b){3,9} {1} ()11,3,6.9) 7. Which of the following set operation includes all the elements that are in two sets but not the one that are common to twosets? a) Symmetricdifference —_(b)Difference (c)Intersection (Union Section-B Answer the following questions (2Mark) 1. What is List in Python? A List in python known as asequencedata type”. © Each value of a list is called aselement. Elements can be a numbers, characters, strings and even the nestedlists. Syntax _ variable=[element-1,element-2,element-3.....element-n] 2. How will you access the list elements in reverse order? © Python enables reverse or negative indexing for the listelements. © A negative index can be used to access an element in reverseorder. © Thus, python lists index in oppositeorder. © The python sets -1 as the index value for the last element in list and -2 for the preceding element and soon. © This is called as ReverseIndexing. 3. What will be the value of x in following pythoncode? Listl=[2,4,6,[1,3,5]] x=len(Listl) print(x) ourrur,Section - D Answer thefollowing questions: (5 Mark) 1. Explain the different set operations supported by python with suitableexample. > A Set is a mutable and an unordered collection of elements without duplicates. Set Qnerations: suchas Union, Intersection, difference and Symmetric difference. @ Union: It include all elements from two or more sets. © The operator | is used to union of twosets. © The function union( ) is also used to join two sets inpython. Output: (2,4, 6,8, Itincludes the common elements in two sets. © The operator &is used to intersect two sets inpython, © The function intersection( ) is also used to intersect two sets inpython.Example: set_A=('A', 2, 4, 'D'} set_B=('A', 'B','C, 'D') print(set_A & set_B) Output: (aN It includes all elements that are in first set(say set A) but not in the second set(say set B). + The minus (-) operator is used to difference set operation inpython. © The function difference( ) is also used to differenceoperation. print(set_A - set_B) Output: {2,4} (iv) Symmetric difference © Itincludes all the elements that are in two sets (say sets A and B) but not the one that are common to two sets. © The caret () operator is used to symmetric difference set operation inpython. * The function symmetric_difference( ) is also used to do the sameoperation.Example: "A 2,4,'D'} ‘A’, BY,'C,'D') set_B={ print(set_A 4 set_B) Output: {2,4, BY 'C} 10. PYTHON CLASSES AND OBJECTS Section-A Choose the bestanswer (Mark) 1. Which of the following are the key features of an Object Oriented Programming language? (a) Constructorand Classes (b) Constructor andObject (©) ClassesandObiects (d) Constructor andDestructor 2. Functions defined inside aclass: (a) Funetions (b) Module () Methods (@)section 3. Class members are accessed through whichoperator? (@& (b). (ot (% 4. Which of the following method is automatically executed when an object iscreated? (a) object() (b) del (c) fune() (@) init 0 5. A private class variable is prefixedwith @__ (D)&& (pit a 6. Which of the following method is used asdestructor? (a) init() (b) dest() (c) rem0), (d)del) 7. Which of the following class declaration is correct? (a)classclass_name (b) classclass_name<> —(e)elassclass name: ——_(d) class class_name[] 8. Which of the following is the private classvariable? (a) num (b)##num (©)$$num (d&&num 9. The process of creating an object is calledas: (a) Constructor (b) Destructor (©) Init (@InstantiationSection-B Answer the following questions (2Mark) 1. What is class? © Class is the main building block inPython. © Class is a template for theobject. and function that act on thosedata. © Object is a collection of di © Objects are also called as instances of a class or classvariable. 2. What is instantiation? © The process of creating object is called as “Class Instantiation”. ‘Syntax: Object_name = clas -_name( ) 3. How will you create constructor in Python? © “init” is a special function begin and end with double underscore in Python act as aConstructor. © Constructor function will automatically executed when an object of a class iscreated. General format: def init(self.{args..
4. What is the purpose of Destructor? © Destructor is also a special method gets executed automatically when an object exit from thescope. © In Python, del ( ) method is used asdestructor. General format: defdel(self):
Section-C Answer the following questions (3Mark) 1. What are class members? How do you defineit? © Variables defined inside a class are called as “Class Variable” and functions are called as“Methods”. © Class variable and methods are together known as members of theclass. © The class members should be accessed through objects or instance ofclass. * Aclass can be defined anywhere in a Pythonprogram,class class_name: statement_I statement_2 statement_n 11. DATABASE CONCEPTS Section-A Choose the best answer 1, What is the acronym of DBMS? os a) DataBaseManagement Symbol 'b) Database ManagingSystem ©) DataBase Management$ystem 4d) DataBasic ManagementSystem 2. A table is known as a) tuple b)attribute relation d)entity 3. A tuple is also known as a) table byrow c)attribute field Section-B Answer the following questions (2Mark) 1. Mention few examples of adatabase. © Foxpro © dbase, IBM DB2 * MicrosoftAccess. © MicrosoftExcel. 2. What is data consistency? © Data Consistency means that data values are the same at all instances of adatabase.Answer the following questions: Section - D (5 Mark) 1. Explain the characteristics of DBMS. 1. Data Stored in a Tables Data is stored into a atables,created inside the database. DBMS also allows to have relationship betweentables. 2. Reduced Redundancy Unnecessary repetition of data in database was a big problem, DBMS follows Normalisation which divides the datain such a way that repetition is minimum. 3:Data Consistency ‘* Data Consistency meansthatdatavaluesarethesameatall instances of a database. 4Support Multiple user and Concurrent Access DBMS allows multipleuserstoworkonit(update,insert, delete data) at the same time and still manages to maintain the data consistency. S.Query Language * DBMS Provide userswithasimplequerylanguage,using which data can be easily fetched, inserted, deleted and updated in a database. 6. Security * DBMS alsotakescareofthesecurityofdata, protecting the data from unauthorizedaccess. © Creating user accounts with different accesspermissions «we can easily secure our data. 7. DBMS Supports ‘Transactions It alllows us to better handle and manage data integrity in © real world applications where _ multi-threadin; is extensively used.12. STRUCTURED QUERY LANGUAGE Section-A_ Choose the bestanswer (Mark) 1. Which commands provide definitions for creating table structure, deleting relations, and modifying relation schemas. a. DDL b.DML ¢.DCL 4.DQL 2. Which command lets to change the structure of thetable? a. SELECT b.ORDER BY 3. The command to delete a tableis c.MODIFY ALTER a. DROP. b.DELETE DELETE ALL d. ALTERTABLE 4. Queries can be generatedusing a. SELECT b.ORDER BY c.MODIFY d.ALTER 5. The clause used to sort data in adatabase a, SORTBY bORDER BY c.GROUPBY d.SELECT Section-B Answer the following questions (2 Mark) 1. Write a query that selects all students whose age is less than 18 in orderwise., Query: SELECT * FROM Student WHERE Age<=18 ORDER BYName; 2. Differentiate Unique and Primary Keyconstraint. Unique Key Constraint Primary Key Constraint This constraint ensures that no two rows have the same value in the specified columns. This constraint declares a field as a Primary key which helps to uniquely identify a record. The UNIQUE constraint can be applied only to fields that have also been declared as NOT NULL The Primary key does now allow Null Values and therefore a primary key field must have the NOT NULL Constraint.3. What is the difference between SQL andMySQL? sal MySQL Structured Query Language is a language | MySQL is a database management system, used for accessing databases like SQL Server, Oracle, Informix, Postgres, etc SQL isa DBMS MySQL is a RDBMS Answer thefollowingquestions (3Marks) 1, What is a constraint? Write short note on Primary key constraint. © Constraint is a condition applicable on a field or set offields. © Primary constraint declares a field as a Primary key which helps to uniquely identify arecord. + Itis similar to unique constraint except that only one field of a table can be set as primarykey. © The primary key does not allow NULL values and therefore a primary key field must have the NOT NULL constraint. 2. Write the use of Savepoint command with anexample. © The SAVEPOINT command is used to temporarily save a transaction so that you can rollback to the point wheneverrequired. ‘Syntax: Example: SAVEPOINTA; 3. Write a SQL statement using DISTINCT keyword. table. ForExample: The DISTINCT keyword is used along with the SELECT command to eliminate duplicate rows in the This helps to eliminate redundant data. SELECT DISTINCT Place FROM Student;4. Write a SQL statement to modify the student table structure by adding a newfield. Syntax : ALTER TABLE
ADD
; To add a new column “Address” of type ,,char” to the Student table, the command is used as ‘Statement: ALTER TABLE Student ADD Addresschar; 5. Write any three DDL commands.Data, Definition . Create Command: To create tables in the database. CREATE TABLE Student (Admno integer, Name char(20), Gender char(1), Age integer); Alter Command; Alters the structure of the database. ALTER TABLE Student ADD Address char; Drop Command:Delete tables from database. DROP TABLE Student; 13. PYTHON AND CSV FILES Section-A Choose the bestanswer (Mark) 1. A CSV file is also known asa (A) Hat File (B)3D File (C)StringFile (D) RandomFile 2. The expansion of CRLFis (A) Control Return andLineFeed (B) Carriage Return and FormFeed (C) Control Router andLineFeed (D) Carriage Return and LineFeed 3. Which of the following module is provided by Python to do several operations on the CSVfiles? (A) py (B)xls (Cocsv (D)os 4, Which of the following mode is used when dealing with non-text files like image or exefiles? (A) Textmode (ByBinarvmode —_ (C) xlsmode (D) esvmode 5. Making some changes in the data of the existing file or adding more data is called (A)Editing (B) Appending —_(C)Modification _(D)AlterationSection-B (2Mark) 1, What is CSVFile? * A CSV file is a human readable text file where each line has a number of fields, separated bycommas or some otherdelimiter. * A CSV file is also known as a Flat File that can be imported to and exported from programs thatstore data in tables, such as Microsoft Excel orOpenOfficeCale. 2. Mention the two ways to read a CSV file usingPython, Two ways of Reading CSV gy reader() function] [Dict Reader class 3. Mention the default modes of theFile. © The default is reading (_,r) in textmode. * In this mode, while reading from the file the data would be in the format ofstrings. Section-C Answer the following questions (3Mark) 1. Write a note on open() function of python. What is the difference between the twomethods? © Python has a built-in function open() to open afile. * This function returns a file object, also called a handle, as it is used to read or modify the file accordingly. © The default is reading in textmode. © In this mode, while reading from the file the data would be in the format ofstrings. On the other hand, binary mode returns bytes and this is the mode to be used when dealing with non- text files like image or exefiles.2. what is the difference between w\Write mode and Append mode. Write Mode Append Mode my my JOpen for apppeding at the end the file Open a File for a writing. ithout truncating it ‘reate a new file if it does not existor 7 reate a new files if it does not exist. incates the file if it exists. 3. Differentiate Excel file and CSV file. Excel csv [Excel is a binary file that holds CSV format is a plain text format with a series information about all the worksheets ina | Of values separated by commas file, including both content and formatting LS files can only be read by applications | CSV can be opened with any text editor in hat have been especially written to read | Windows like notepad, MS Excel. heir format, and can only be written in the] OpenOffice, ete ame way. [Excel is a spreadsheet that saves files into | CSV is a format for saving tabular its own proprietary format viz. xls or xlsx | information into a delimited text file with extension .csv 14. IMPORTING C++ PROGRAMS IN PYTHON Section-A Choose the best answer (Mark) 1. Which of the following is not a scriptinglanguage? (A) JavaScript (B)PHP (©Perl (®)HTML 2. Importing C++ program in a Python program iscalled (A) wrapping (B) Downloading (C) Interconnecting (D)Parsing 3. The expansion of APIis (A) ApplicationProgrammingInterpreter {B) Application ProgrammingInterface (© ApplicationPerformingInterface (D) Application Programminglaterlink 4. A framework for interfacing Python and C++is, (A) Ctypes (B)SWIG (©Cython Boost,5. Which of the following is a software design technique to split your code into separateparts? (A) Object oriented Programming (C) LowLevelProgramming {B) Modularprogramming (D) Procedure orientedProgramming 6. The module which allows you to interface with the Windows operating systemis (A) OSmodule (B) sysmodule (C)csvmodule —_(D) getoptmodule 7. getopt() will return an empty array if there is no error in splitting stringsto (A) argwvariable (B) optvariable (C)args variable(D) ifilevariable 8. Identify the function call statement in the followingsnippet. ifname, ==' main’: main(sys.argv[1:]) (Cymain. (D)argy 9. Which of the following can be used for processing text, numbers, images, and scientificdata? (A) main(svsargvf1:) — (B)name. (A) HTML (B)C 10. What doesname___contains? Answer the following questions (©) C++ (PYTHON, Section-B (2Mark) 1. What is the theoretical difference between Scripting language and other programming language? Scripting Language Programming Language A scripting language requires an interpreter. A programming language requires a compiler. A scripting language need not be compiled. A programming languages needs to be compiled before running . Example: JavaScript, VBScript, PHP, Perl, Python, Ruby, ASP and Tel. Example: C, C++, Java, C# etc.2. Differentiate compiler and interpreter Compiler Interpreter Compiler generates an Intermediate Code. Interpreter generates Machine Code. Compiler reads entire program for compilation. Interpreter reads single statement at a time for interpretation. Error deduction is difficult Error deduction is easy Comparatively faster Slower Example: gec, g++, Borland TurboC Example: Python, Basic, Java 3. Write the expansion of (i)SWIG. SWIG - MinGW - 4, What is the use of modules? (MinGW Simplified Wrapperlnterface Generator - Both C andC++ Minimalist GNU forWindows © Modules are used to break down large programs into small manageable and organizedfiles. * Modules provide reusability ofcode. © We can define our most used functions in a module and import it, instead of copying theirdefinitions into differentprograms. 5, What is the use of cd command. © Syntaxied
“cd” commmand used to change directory and absolute path refers to the complete path where Python is installed. ive an example. © Example:c:\>cd c:\ program files \ openoffice 4 \programAnswer the following questions (3Mark) 1. Differentiate PYTHON and C++. PYTHON CH Python is typically an "interpreted" language C++ is typically a "compiled" language Python is typically an "interpreted" language C++ Compiled statically typed Language Data type is not required while declaring variable Data type is required while declaring Variable It can act both as scripting and general purpose language Itis a general purpose language 2. What are the applications of scripting language? © To automate certain tasks in aprogram Extracting information from a dataset * Less code intensive as compared to traditional programminglanguage ‘* can bring new functions to applications and glue complex systemstogether 3. What is MinGW? What is its use? © MinGW refers to a set of runtime headerfiles. © It is used in compiling and linking the code of C, C++ and FORTRAN to be run on Windows OperatingSystem. ‘© MinGW allows to compile and execute C++ program dynamically through Python program using g++.15. DATA MANIPULATION THROUGH SQL Section-A Choose the bestanswer (Mark) 1. Which of the following is an organized collection ofdata? (A) Database — (B) DBMS (Clnformation (D)Records 2. SQLite falls under which databasesystem? (A) Flat file databasesystem B) Relational Databasesystem (©) Hierarchicaldatabase system (D) Object oriented Databasesystem 3. Which of the following is a control structure used to traverse and fetch the records of the database? (A) Pointer (B) Key () Cursor (D) Insertionpoint 4. Any changes made in the values of the record should be saved by thecommand (A) Save (B) SaveAs {C) Commit (D)Oblige 5. Which of the following executes the SQL command to perform someaction? (A) Execute() — (B) Key() (C) Cursor() (D)run() 6. Which of the following function retrieves the average of a selected column of rows in atable? (A) Add() (B)SUMO. {Q.AVGO (D)AVERAGE() 7. The function that returns the largest value of the selected columnis (A) MAXQ(B) LARGE) (C) HIGHO (D)MAXIMUM() 8. The most commonly used statement in SQLis (A) cursor Bselect, (Cexecute (D)commit Section-B Answer thefollowingquestions (2Mark) 1. Mention the users who uses theDatabase. > Users of database can be human users, other programs orapplications 2. Which method is used to connect a database? Give anexample. > Create a connection using connect () method and pass the name of the databaseFile. ° Example: import sqlite3 # connecting to the database connection = sqlite3.connect ("Academy.db") # cursor cursor = connection.cursor()3. What is the advantage of declaring a column as “INTEGER PRIMARY KEY” * Ifa column of a table is declared to be an INTEGER PRIMARY KEY, then whenever a NULL will be as an input for this column, the NULL will be automatically converted into an integer which will one ld than the highest value so far used in thatcolumn, © Ifthe table is empty, the value 1 will beused. 4. Write the command to populate record in a table. Gi e an example. © To populate (add record) the table "INSERT" command is passed to SQLite. “execute” method executes the SQL command to perform some action. ° Example: sql_command = """ INSERT INTO Student (Rollno, Sname, Grade, gender, Average, birth_date) VALUES (NULL, "Akshay", "B","M","87. 001-12-12");""" cursor.execute(sql_command) 5. Which method is used to fetch all rows from the database table? © The fetchall() method is used to fetch all rows from the databasetable. © Example: result =cursor.fetchall() Section-C Answer the following questions (3Mark) 1, What is SQLite? What is it ? * SQLite is a simple relational database system, which saves its data in regular data files or even in the internal memory of thecomputer. ADVANTAGES: © SQLite isfast.rigorouslytested,andflexible,makingiteasiertowork. © Python has a native library forSQLite. 2. Mention the difference between fetchone() and fetchmany() fetchone() fetchmany() The fetchone() method returns the next rowof © The fetchmany() method returns the next a query result set or None in case there is no row number of rows (n) of the resultset. left ising while loop and fetchone() method we can © Displaying specified number of records isdone flisplay all the records from a table by using fetchmany().Section - D Answer the following questions: (SMark) 1. Write in brief about SQLite and the steps used to useit. > SQLite is a simple relational database system, which saves its data in regular data files or even in the internal memory of thecomputer. > Itis designed to be embedded in applications, instead of using a separate database server program such as MySQLorOracle. ADVANTAGES: * SQLite is fast, rigorously tested, and fl exible, making it easier to work Python has a native library forSQLite. Steps To Use SOLite: Step 1: import sqllite3 ‘Step 2 : Createaconnectionusingconnect()methodandpassthenameofthedatabaseFile > Connecting to a database in step2 means passing the name of the database to beaccessed. > If the database already exists the connection will open thesame. > Otherwise, Python will open a new database file with the specifiedname. Step 3: Set the cursor object cursor = connection. cursor () © Curser is a control structure usedtotraverseandfetchtherecordsofthedatabase Cursor has a major role in working withPython, All the commands will be executed using cursor objectonly. To create a table in the database, create an object and write the SQL command init. Example:-sql_comm = "SQL statement" © For executing the command use the cursor method and pass the required sql command as a parameter Many number of commands can be stored in the sql_comm and can be executed one afterother. Any changes made in the values of the record should be saved by the commend "Commit" before closing the "Tableconnection".16. DATA VISUALIZATION USING PYPLOT: LINE CHART, PIE CHART AND BAR CHART Section-A Choose the best answer (Mark) 1. Which is a python package used for 2Dgraphics? a) matplotlib.pyplot b. matplotlib.pip c.matplotlib.numpy d.matplotlib.plt 4, Identify the package manager for Python packages, ormodules. a) Matplotlib bPIP cplt.show() d. pythonpackage 5. To install matplotlib, the following function will be typed in your commandprompt. What does “-U"represents? Python ~m pip install -U pip a) downloading pip to thelatestversion _, upgrading pip to the latestversion c. removingpipd. upgrading matplotlib to the latestversion 6. Which key is used to run themodule? a) F6 bF4 c.F3 GES 7. Identify the right type of chart using the followinghints. Hint 1: This chart is often used to visualize a trend in data over intervas of time. Hint 2: The line in this type of chart is often drawn chronologically. a) Linechart b.Barchart c.Pie chart d. Scatterplot 8. Read the statements given below. Identify the right option from the following for piechart. Statement A: To make a pie chart with Matplotlib, we can use the plt.pie()function. Statement B: The autopct parameter allows us to display the percentage value using the Python string formatting. a. Statement Aiscorrect b. Statement B iscorrect c) Both the statementsarecorrect d. Both the statements arewrong Answer the following questions (Mark) a, Define: DataVisualization. © Data Visualization is the graphical representation of information anddata. * The objective of Data Visualization is to communicate information visually to users using statistical graphics.b. List the general types of datavisualization. Charts Tables vvv Graphs v Maps vy Infographics Dashboards v ¢. List the types of Visualizations inMatplotlib. Line plot Scatterplot > > > Histogram > Box plot > Bar chartand > Pie chart 4, How will you install Matplotlib? ‘© Matplotlib can be installed using pipsoftware. + Pip is a management software for installing pythonpackages. Importing Matplotlib usingthe command:import matplotlib.pyplot asplt © Matplotlib can be imported in theworkspace. 5. Write any three uses of datavisualization, > Data Visualization help users to analyze and interpret the dataeasily. > Itmakes complex data understandable andusable. > Various Charts in Data Visualization helps to show relationship in the data for one ormore variables. 6. Write the coding for thefollowing: * To check if PIP is Installed in yourPC. + In command prompt type pip —version. + Ifitis installed already, you will getversion. + Command: Python - m pip install - Upip+ To Check the version of PIP installed in yourPC. + C:\Users\ YourName\AppData\Local\Programs\Python\Python36-32\Scripts>pip- version + To list the packages inmatplotlib. + C:\Users\ YourName\AppData\Local\Programs\Python\Python36-32\Scripts> piplist Section - D Answer the following questions: (5Mark) 1. Explain in detail the types of pyplots using Matplotlib.. Line Chart: Line Chart or Line Graph is a type of chart which displays information as a series of data points called ,,markers” connected by straight line segments. © A Line Chart is often used to visualize a trend in data over intervals of time ~ a time series ~ thus the line is often drawnchronologically. Example: import matplotlib.pyplot as plt years = [2014, 2015, 2016, 2017, 2018] total_populations = (8939007, 8954518, 8960387, 8956741, 8943721] plt.plot (years, total_populations) plt.title ("Year vs Population in India") plt.xlabel ("Year") plt.ylabel ("Total Population") plt.show() In this program, Plt.title() + specifies title to the graph Plt.xlabel() — specifies label for X-axis Plt.ylabel() — specifies label for Y-axis Output:2. Explain the various buttons in a matplotlibwindow. HomeButton: > The Home Button will help once you have begun navigating yourchart. > If you ever want to retum back to the original view, you can click onthis. Forward/Back Buttons: > These buttons can be used like the Forward and Back buttons in yourbrowser. > You can click these to move back to the previous point you were at, or forward again. Pan A: > This cross-looking button allows you to click it, and then click and drag your grapharound. Zoom: > The Zoom button lets you click on it, then click and drag a square that you would like to zoom into specifically. > Zooming in will require a left click anddrag. > You can alternatively zoom out with a right click anddrag. Configure Subplots: > This button allows you to configure various spacing options with your figure andplot. Save Figure: >T s button will allow you to save your figure in variousforms, Plant trees to save lives ! Don’t cut trees instead plant some !!
You might also like
12th Computer Science Study Material
PDF
No ratings yet
12th Computer Science Study Material
66 pages
Xii - Cs Em Minimum Study Material 2024-2025
PDF
100% (1)
Xii - Cs Em Minimum Study Material 2024-2025
95 pages
12th Computer Science Study Material
PDF
No ratings yet
12th Computer Science Study Material
136 pages
Starting Out With C++ From Control Structures To Objects 9th Edition Gaddis Solutions Manual download
PDF
100% (1)
Starting Out With C++ From Control Structures To Objects 9th Edition Gaddis Solutions Manual download
50 pages
12th Computer Science Study Material
PDF
No ratings yet
12th Computer Science Study Material
138 pages
Namma Kalvi 12th Computer Science Chapter 1 To 4 Notes em
PDF
No ratings yet
Namma Kalvi 12th Computer Science Chapter 1 To 4 Notes em
13 pages
12CS_EM_2025-5-178
PDF
No ratings yet
12CS_EM_2025-5-178
174 pages
Xii - Computer Science Reudced Syllabus Minimum Study Material 2021-2022
PDF
No ratings yet
Xii - Computer Science Reudced Syllabus Minimum Study Material 2021-2022
67 pages
12CS_EM_2025
PDF
No ratings yet
12CS_EM_2025
194 pages
12CS_EM_2025
PDF
No ratings yet
12CS_EM_2025
193 pages
12th PYTHON Chapter 1 To 16
PDF
No ratings yet
12th PYTHON Chapter 1 To 16
271 pages
xii cs material 24-25
PDF
No ratings yet
xii cs material 24-25
161 pages
XII CS STUDY MATERIAL
PDF
No ratings yet
XII CS STUDY MATERIAL
107 pages
Xii Cs em Study Material 2024 2025
PDF
100% (1)
Xii Cs em Study Material 2024 2025
108 pages
12th English paragraph
PDF
No ratings yet
12th English paragraph
87 pages
12CS em 2024
PDF
No ratings yet
12CS em 2024
152 pages
UNIT-1-2
PDF
No ratings yet
UNIT-1-2
54 pages
CSC305 CHAPTER 2b
PDF
No ratings yet
CSC305 CHAPTER 2b
54 pages
12 Cs Full Study Materials 2022-23
PDF
No ratings yet
12 Cs Full Study Materials 2022-23
136 pages
+2 CS MLM 1-36
PDF
No ratings yet
+2 CS MLM 1-36
36 pages
STD 12 Cs Chapters 1 To 16
PDF
No ratings yet
STD 12 Cs Chapters 1 To 16
111 pages
Namma Kalvi 12th Computer Science Question Bank em 220030
PDF
No ratings yet
Namma Kalvi 12th Computer Science Question Bank em 220030
73 pages
12th Comp.sci Ln 1 16 EM Book Back Ques Ans 2024-25-1
PDF
No ratings yet
12th Comp.sci Ln 1 16 EM Book Back Ques Ans 2024-25-1
86 pages
12th Computer Science Study Material 2024 25
PDF
No ratings yet
12th Computer Science Study Material 2024 25
168 pages
Kalviexpress'Xii Cs Full Material
PDF
No ratings yet
Kalviexpress'Xii Cs Full Material
136 pages
Python Question Bank (1)
PDF
No ratings yet
Python Question Bank (1)
118 pages
12th Computer Science EM Sura Guide Sample 2020-21 WWW - Kalvikadal.in
PDF
No ratings yet
12th Computer Science EM Sura Guide Sample 2020-21 WWW - Kalvikadal.in
262 pages
Complete Material
PDF
No ratings yet
Complete Material
145 pages
Xii - Cs em Study Material 2023-2024
PDF
67% (3)
Xii - Cs em Study Material 2023-2024
92 pages
Ch03 Names Scopes and Bindings 4e
PDF
No ratings yet
Ch03 Names Scopes and Bindings 4e
45 pages
CS Final Corrected Export - 080625
PDF
No ratings yet
CS Final Corrected Export - 080625
66 pages
5_6138568079229064804
PDF
No ratings yet
5_6138568079229064804
80 pages
Split_20250312_1013
PDF
No ratings yet
Split_20250312_1013
83 pages
Computer Science - em - Key Answer
PDF
No ratings yet
Computer Science - em - Key Answer
8 pages
yasi
PDF
No ratings yet
yasi
56 pages
CSC305 Chapter 2 (Part 2)
PDF
No ratings yet
CSC305 Chapter 2 (Part 2)
27 pages
XII CS Chapter 3 - Scoping notes 2025-2026 -
PDF
No ratings yet
XII CS Chapter 3 - Scoping notes 2025-2026 -
7 pages
XII Computer Science EM Five Mark Question and Answer
PDF
No ratings yet
XII Computer Science EM Five Mark Question and Answer
16 pages
Scopes and Data Types: CMSC 124
PDF
No ratings yet
Scopes and Data Types: CMSC 124
34 pages
Xii - Cs Em Study Material 2025-2026
PDF
No ratings yet
Xii - Cs Em Study Material 2025-2026
108 pages
MCQ 3
PDF
No ratings yet
MCQ 3
22 pages
+2 Computer Science One Mark
PDF
82% (11)
+2 Computer Science One Mark
23 pages
ch-1-4
PDF
No ratings yet
ch-1-4
28 pages
12CS em 01
PDF
No ratings yet
12CS em 01
45 pages
Ch#5
PDF
No ratings yet
Ch#5
6 pages
Dynamic Scope Rule: Example 1
PDF
No ratings yet
Dynamic Scope Rule: Example 1
8 pages
Unit 3 Scoping
PDF
No ratings yet
Unit 3 Scoping
4 pages
Chapter3 - Scoping-12
PDF
No ratings yet
Chapter3 - Scoping-12
2 pages
Announcements Announcements: Project 1 Is Graded
PDF
No ratings yet
Announcements Announcements: Project 1 Is Graded
8 pages
12CS_EM_OneMarks_2025
PDF
No ratings yet
12CS_EM_OneMarks_2025
18 pages
12th Comp.Sci (EM) - SLM - 2024 - 25
PDF
No ratings yet
12th Comp.Sci (EM) - SLM - 2024 - 25
11 pages
12CS EM OneMarks Without Answers
PDF
No ratings yet
12CS EM OneMarks Without Answers
19 pages
Names, Bindings, Scopes: Programming Languages
PDF
No ratings yet
Names, Bindings, Scopes: Programming Languages
39 pages
Cse VI Programming Languages 10cs666 Solution PDF
PDF
No ratings yet
Cse VI Programming Languages 10cs666 Solution PDF
17 pages
CS Functions
PDF
No ratings yet
CS Functions
6 pages
12th-Computer-Science-Public-Exam-March-2024-Official-Answer-key-English-Medium-PDF-Download (1)
PDF
No ratings yet
12th-Computer-Science-Public-Exam-March-2024-Official-Answer-key-English-Medium-PDF-Download (1)
8 pages
12th - Computer Science-U1 - EM
PDF
No ratings yet
12th - Computer Science-U1 - EM
11 pages
Ch5 Python
PDF
No ratings yet
Ch5 Python
10 pages
12 CS EM Public Answer Key May 2022
PDF
No ratings yet
12 CS EM Public Answer Key May 2022
10 pages