'''
Date : 2020-Mar-08
Purpose: This program is for assessing TN 12th standard students CS objective type question skill
Source : Questions are taken from TamilNadu state board CS book sylabus chapters from 1 to 16
Run instructions: Each question will have 4 answers A,B,C and D
User can input Capital or Small letters
Environment or Pre-requiste : Install python3x for running this program
eg: Windows python bin directory -> python3 12th_CS_Quiz.py
Ctrl+C to cancel the execution anytime
Updated : 2020-Mar-09
Additional questions added in chapter 7 - mathematical functions
Fixed correct answers in Chapter 4 - Algorithms
'''
import random
chapter1_questions = 'chapter1 questions'
chapter2_questions = 'chapter2 questions'
chapter3_questions = 'chapter3 questions'
chapter4_questions = 'chapter4 questions'
chapter5_questions = 'chapter5_questions'
chapter6_questions = 'chapter6 questions'
chapter7_questions = 'chapter7 questions'
chapter8_questions = 'chapter8 questions'
chapter9_questions = 'chapter9 questions'
chapter10_questions = 'chapter10_questions'
chapter11_questions = 'chapter11 questions'
chapter12_questions = 'chapter12 questions'
chapter13_questions = 'chapter13 questions'
chapter14_questions = 'chapter14 questions'
chapter15_questions = 'chapter15_questions'
chapter16_questions = 'chapter16_questions'
random_questions='random_questions'
questions = [chapter1_questions, chapter2_questions, chapter3_questions,chapter4_questions,chapter5_questions,chapter6_questions, chapter7_questions,chapter8_questions,chapter9_questions,chapter10_questions, chapter11_questions, chapter12_questions,chapter13_questions,chapter14_questions,chapter15_questions,chapter16_questions]
quiz = {
chapter1_questions: [
("1.The small sections of code that are used to perform a particular task is called........ \n(A) Subroutines (B) Files \n(C) Pseudo code (D) Modules","A"),
("2. Which of the following is a unit of code that is often defined within a greater code structure? \n(A) Subroutines (B) Function \n(C) Files (D) Modules","B"),
("3. Which of the following is a distinct syntactic block? \n(A) Subroutines \n(B) Function \n(C) Definition \n(D) Modules ","C"),
("4. The variables in a function definition are called as \n(A) Subroutines \n(B) Function \n(C) Definition \n(D) Parameters ","D"),
("5. The values which are passed to a function definition are called \n(A) Arguments \n(B) Subroutines \n(C) Function \n(D) Definition ","A"),
("6. Which of the following are mandatory to write the type annotations in the function definition? \n(A) Curly braces \n(B) Parentheses \n(C) Square brackets \n(D) indentations ","B"),
("7. Which of the following defines what an object can do? \n(A) Operating System \n(B) Compiler \n(C) Interface \n(D) Interpreter ","C"),
("8. Which of the following carries out the instructions defined in the interface? \n(A) Operating System \n(B) Compiler \n(C) Implementation \n(D) Interpreter ","C"),
("9. The functions which will give exact result when same arguments are passed are\n(A) Impure functions \n(B) Partial Functions \n(C) Dynamic Functions \n(D) Pure functions ","D"),
("10. The functions which cause side effects to the arguments passed are called \n(A) impure function \n(B) Partial Functions \n(C) Dynamic Functions \n(D) Pure functions","A")
],
chapter2_questions: [
("1. Which of the following functions that build the abstract data type ? \n(A) Constructors \n(B) Destructors \n(C) recursive \n(D)Nested ","A"),
("2. Which of the following functions that retrieve information from the data type? \n(A) Constructors \n(B) Selectors \n(C) recursive \n(D)Nested ","B"),
("3. The data structure which is a mutable ordered sequence of elements is called \n(A) Built in \n(B) List \n(C) Tuple \n(D) Derived data ","B"),
("4. A sequence of immutable objects is called \n(A) Built in \n(B) List \n(C) Tuple \n(D) Derived data ","C"),
("5. The data type whose representation is known are called \n(A) Built in datatype \n(B) Derived datatype \n(C) Concrete datatype \n(D) Abstract datatype ","C"),
("6. The data type whose representation is unknown are called \n(A) Built in datatype \n(B) Derived datatype \n(C) Concrete datatype \n(D) Abstract datatype ","D"),
("7. Which of the following is a compound structure? \n(A) Pair \n(B) Triplet \n(C) single \n(D) quadrat ","A"),
("8. Bundling two values together into one can be considered as \n(A) Pair \n(B) Triplet \n(C) single \n(D) quadrat ","A"),
("9. Which of the following allow to name the various parts of a multi-item object? \n(A) Tuples \n(B) Lists \n(C) Classes \n(D) quadrats ","C"),
("10. Which of the following is constructed by placing expressions within square brackets? \n(A) Tuples \n(B) Lists \n(C) Classes \n(D) quadrats","B")
],
chapter3_questions: [
("1. Which of the following refers to the visibility of variables in one part of a program to another part of the same program.\n(A) Scope \n(B) Memory \n(C) Address \n(D) Accessibility","A"),
("2. The process of binding a variable name with an object is called\n(A) Scope \n(B) Mapping \n(C) late binding \n(D) early binding","B"),
("3. Which of the following is used in programming languages to map the variable and object?\n(A) :: \n(B) := \n(C) = \n(D) ==","C"),
("4. Containers for mapping names of variables to objects is called\n(A) Scope \n(B) Mapping \n(C) Binding \n(D) Namespaces","D"),
("5. Which scope refers to variables defined in current function?\n(A) Local Scope \n(B) Global scope\n(C) Module scope \n(D) Function Scope","A"),
("6. The process of subdividing a computer program into separate sub-programs is called\n(A) Procedural Programming \n(B) Modular programming\n(C)Event Driven Programming \n(D) Object oriented Programming","B"),
("7. \nWhich of the following security technique that regulates who canuse resources in acomputing environment?\n(A) Password \n(B)Authentication\n(C) Access control \n(D) Certification","C"),
("8. \nWhich of the following members of a class can be handled only from within the class?\n(A) Public members \n(B)Protected members\n(C) Secured members \n(D) Private members","D"),
("9. \nWhich members are accessible from outside the class?\n(A) Public members \n(B)Protected members\n(C) Secured members \n(D) Private members","A"),
("10. \nThe members that are accessible from within the class and are also available to its subclassesis called\n(A) Public members \n(B)Protected members\n(C) Secured members \n(D) Private members","B")
],
chapter4_questions : [
(" 1. \nThe word comes from the name of a Persian mathematician Abu Jafar Mohammed ibn-i Musa al Khowarizmi is called? \n (A) Flowchart \n (B) Flow \n(C) Algorithm \n(D) Syntax ","C"),
("2. \nFrom the following sorting algorithms which algorithm needs the minimum number of swaps? \n (A) Bubble sort (B) Quick sort (C) Merge sort (D) Selection sort","D"),
("3. \nTwo main measures for the efficiency of an algorithm are \n(A) Processor and memory (B) Complexity and capacity \n(C) Time and space (D) Data and space","C"),
("4. \nThe complexity of linear search algorithm is \n(A) O(n) (B) O(log n) (C) O(n2) (D) O(n log n) ","A"),
("5. \nFrom the following sorting algorithms which has the lowest worst case complexity?\n(A) Bubble sort (B) Quick sort (C) Merge sort (D) Selection sort","C"),
("6. \nWhich of the following is not a stable sorting algorithm? \n(A) Insertion sort (B) Selection sort (C) Bubble sort (D) Merge sort","B"),
("7. \nTime complexity of bubble sort in best case is \n(A) θ (n) (B) θ (nlogn) (C) θ (n2) (D) θ (n(logn) 2)","A"),
("8. \nThe Θ notation in asymptotic evaluation represents \n(A) Base case (B) Average case (C) Worst case (D) NULL case","B"),
("9. \nIf a problem can be broken into subproblems which are reused several times, the problem possesses which property? \n(A) Overlapping subproblems (B) Optimal substructure \n(C) Memoization (D) Greedy","A"),
("10. \nIn dynamic programming, the technique of storing the previously calculated values is called ? \n (A) Saving value property \n(B) Storing value property \n(C) Memoization \n(D) Mapping ","C")
],
chapter5_questions: [
("1. \nWho developed Python ? \nA) Ritche \nB) Guido Van Rossum \nC) Bill Gates \nD) Sunder Pitchai","B"),
("2. \nThe Python prompt indicates that Interpreter is ready to accept instruction.\nA) >>> \nB) <<< \nC) # \nD) <<","A"),
("3. \nWhich of the following shortcut is used to create new Python Program ?\nA) Ctrl + \nC B) Ctrl + F \nC) Ctrl + B \nD) Ctrl + N","D"),
("4. \nWhich of the following character is used to give comments in Python Program ?\nA) # \nB) & \nC) @ \nD) $","A"),
("5. \nThis symbol is used to print more than one item on a single line.\nA) Semicolon(;) \nB) Dollor($) \nC) comma(,) \nD) Colon(:)","C"),
("6. \nWhich of the following is not a token ?\nA) Interpreter \nB) Identifiers \nC) Keyword \nD) Operators","A"),
("7. \nWhich of the following is not a Keyword in Python ?\nA) break \nB) while \nC) continue \nD) operators","D"),
("8. \nWhich operator is also called as Comparative operator?\nA) Arithmetic \nB) Relational\nC) Logical \nD) Assignment","B"),
("9. \nWhich of the following is not Logical operator?\nA) and \nB) or \nC) not \n D) Assignment","A"),
("10. \nWhich operator is also called as Conditional operator?\nA) Ternary \nB) Relational \nC) Logical \nD) Assignment","A")
],
chapter6_questions: [
("1. \nHow many important control structures are there in Python?\nA) 3 \nB) 4\nC) 5 \nD) 6","A"),
("2. \nelif can be considered to be abbreviation ofA) nested if \nB) if..else \nC) else if \nD) if..elif","D"),
("3. \nWhat plays a vital role in Python programming?\nA) Statements \nB) Control \nC) Structure \nD) Indentation","D"),
("4. \nWhich statement is generally used as a placeholder?\nA) continue \nB) break \nC) pass \nD) goto","C"),
("5. \nThe condition in the if statement should be in the form of \n A) Arithmetic or Relational expression \nB) Arithmetic or Logical expression \nC) Relational or Logical expression \nD) Arithmetic","C"),
("6. \nWhich is the most comfortable loop? \nA) do..while \nB) while \nC) for \nD) if..elif","C"),
("7.\nWhat is the output of the following snippet? i=1 \n while True: \nif i%3 ==0: \n break \nprint(i,end='') i +=1 \n\n A) 12 \n B) 123 \n C) 1234 D)124" ,"A"),
("8. \nWhat is the output of the following snippet? \n T=1 \n while T: \n print(True) \n brea \n A) False B) True C) 0 D) no output ","B"),
("9. \nWhich amongst this is not a jump statement ? \nA) for \nB) goto \nC) continue \nD) break","A"),
("10.\nWhich punctuation should be used in the blank? if <condition>_ \n A) ; B): C) :: D)! ","B")
],
chapter7_questions : [
("1. \nA named blocks of code that are designed to do one specific job is called as \n(a) Loop (b) Branching \n(c) Function (d) Block","C"),
("2. \nA Function which calls itself is called as \n(a) Built-in (b) Recursion \n(c) Lambda (d) return","B"),
("3. \nWhich function is called anonymous un-named function \n(a) Lambda (b) Recursion \n(c) Function (d) define","A"),
("4. \nWhich of the following keyword is used to begin the function block? \n(a) define (b) for \n(c) finally (d) def","D"),
("5. \nWhich of the following keyword is used to exit a function block? \n(a) define (b) return \n(c) finally (d) def","B"),
("6. \nWhile defining a function which of the following symbol is used. \n(a) ; (semicolon) \n(c) : (colon) (b) . (dot) (d) $ (dollar)","C"),
("7. \nIn which arguments the correct positional order is passed to a function? \n(a) Required (b) Keyword \n(c) Default (d) Variable-length","A"),
("8. \nRead the following statement and choose the correct statement(s). (I) In Python, you don’t have to mention the specific data types while defining function. \n (II) Python keywords can be used as function name. \n(a) I is correct and II is wrong (b) Both are correct \n(c) I is wrong and II is correct (d) Both are wrong ","A"),
("9. \nPick the correct one to execute the given statement successfully. if ____ : print(x, \" is a leap year\") \n(a) x%2=0 (b) x%4==0 \n(c) x/4=0 (d) x%4=0 ","B"),
("10. \nWhich of the following keyword is used to define the function testpython(): ? \n(a) define (b) pass \n(c) def (d) while","C"),
("11. \nWhat is the output of {absolute values of} \n x=20 \n y=-23.2 \n print(\'x = \', abs(x)) \n print('y = ', abs(y)) ? \n(a) 20,23.2 (b) 20,23 \n(c) 20,24 (d) 20,23.5","A"),
("12. \nWhat is the output of ord {ASCII} values of \n c=\'a\' \nd=\'A\' \n print ('c = ',ord (c)) \n print ('A = ',ord (d))? \n(a) 97,65 (b) 65,95 \n(c) 100,200 (d) 65,98","A"),
("13. \nWhat is the output of ord {ASCII} values of \n\t c=65 \n\t print(chr(c)) ? \n(a) a (b) b \n(c) c (d) A","D"),
("14. \nOutput of \n print (\'15 in binary : \',bin (x))? \n(a) 0b1111 (b) 11111 \n(c) 10101 (d) 0b10111","A"),
("15. \nOutput of x=15.2 \n print (type (x))? \n(a) <class \'str\'> (b) <class \'bool\'> \n(c) <class \'float\'> (d) <class \'int\'>","C"),
("16. \nOutput of x=15 \n print ('address of x is :',id (x)) ? \n(a) VALUE OF X \n(b) root of x \n(c) base of x \n(d) address of x","D"),
("17. \nOutput of x=15 \n print ('address of x is :',id (x)) ? \n(a) VALUE OF X \n(b) root of x \n(c) base of x \n(d) address of x","D"),
("18. \nMyList = [21,76,98,23] \n print ('Maximum of MyList :', max(MyList))? \n(a) 10 (b) 76 \n(c) 98 (d) 23","C"),
("19. \nMyList = [21,76,98,23] \n print ('Minimum of MyList :', min(MyList))? \n(a) 21 (b) 76 \n(c) 98 (d) 23","A"),
("20. \nMyList = [1,2,4,3] \n print ('Sum of MyList :\', sum(MyList))? \n(a) 10 (b) 76 \n(c) 8 (d) 23","A"),
("21. \nx=14 \n print (\'x value in binary :\',format(x,\'b\'))? \n(a) 1110 (b) 1111 \n(c) 1010 (d) 1100","A"),
("22. \nx=25 \n print (\'x value in octal :\',format(x,\'o\'))? \n(a) 30 (b) 31 \n(c) 40 (d) 110","B"),
("23. \nx=25 \n print (\'x value in FIXED POINT Flat \',format(x,\'f \'))\n(a) 25 (b) 25.000000 \n(c) 25.00 (d) 25.0","B"),
("24. \nx=17.9 \n y=22.2 \n z=-18.3 \n print (\'Value is rounded of x,y and z\', round(x), round (y), round (z)) ? \n a)18,22,18 b) 18,21,18 c) 18,21,17 d) 18,22,-18","D"),
("25. \nPower of \n a=5 \n b= 2 \n c=3.0 \nprint (pow (a,b)) ? a) 20 b) 25 c) 30 d) 10","B"),
("26. \nPower of \n a=5 \n b= 2 \n c=3.0 \nprint (pow (a,c)) ? a) 125 b) 25 c) 125.0 d) 15","C"),
("27. \nPower of \n a=5 \n b= 2 \n c=3.0 \nprint (pow (a+b,3)) ? a) 125 b) 25 c) 343 d) 340","C"),
("28. \nFloor of \n x=26.7 \n y=-26.7 \n z=-23.2 \nprint (math.floor(x)) ? \na) 27 b) 26 c) 24 d) 28","B"),
("29. \nFloor of \n x=26.7 \n y=-26.7 \n z=-23.2 \nprint (math.floor(y)) ? \na) -27 b) 26 c) 27.0 d) -28","a"),
("30. \nFloor of \n x=26.7 \n y=-26.7 \n z=-23.2 \nprint (math.floor(z))? \na) 24 b) 23 c) -24 d) 22","C"),
("31. \nCeil of \n x=26.7 \n y=-26.7 \n z=-23.2 \nprint (math.ceil(x)) ? \na)27 b) 26 c) 24 d) 26","A"),
("32. \nCeil of \n x=26.7 \n y=-26.7 \n z=-23.2 \nprint (math.ceil(y)) ? \na)27 b) 26 c) 27.0 d) -26","D"),
("33. \nCeil of \n x=26.7 \n y=-26.7 \n z=-23.2 \nprint (math.ceil(z)) ? \na)24 b) -23 c) -24 d) 22.0","B"),
("34. \nSqrt of \n a=30 \n b=-49 \n c=-25.5 \nprint (math.sqrt(a)) ? \n a) 5.477225575051661 b) 5 c) 30 d) 6","A"),
("35. \nSqrt of \n a=30 \n b=-49 \n c=-25.5 \nprint (math.sqrt(b)) ? \n a) 7 b) 79 c) 7.0 d) 6","C"),
("36. \nPower of \n a=2 \n b= 2 \n c=3.0 \nprint (pow (a+b,3)) ? a) 16 b) 2 c) 4 d) 64","D"),
("37. \nFloor of \n x=26.7 \n y=-26.7 \n z=-23.2 \nprint (math.floor(z))? \na) 24 b) 23 c) -24 d) 22","C"),
("38. \nCeil of \n y=-25.7 \nprint (math.ceil(y)) ? \na)27 b) 25 c) 27.0 d) -26","B"),
("39. \nFloor of \n y=-25.7 \nprint (math.floor(y)) ? \na)27 b) 25 c) 27.0 d) -26","D"),
("40. \nCeil of \n x=26.7 \n y=-15.3 \n z=-23.2 \nprint (math.ceil(y)) ? \na)27 b) 26 c) 27.0 d) -15","D"),
("41. \nFloor of \n x=26.7 \n y=-15.3 \n z=-23.2 \nprint (math.floor(z))? \na) 26 b) 23 c) -24 d) 22","a"),
("42. \nCeil of \n y=10.7 \nprint (math.ceil(y)) ? \na)11 b) 25 c) 27.0 d) -26","A"),
("43. \nCeil of \n y=-10.7 \nprint (math.ceil(y)) ? \na)-10 b) 25 c) 27.0 d) -26","A"),
("44. \nFloor of \n y=10.7 \nprint (math.floor(y)) ? \na)10 b) 9 c) 11 d) -12","A"),
("45. \nFoor of \n y=-10.7 \nprint (math.floor(y)) ? \na)-11 b) -10 c) -12 d) 11","A")
],
chapter8_questions : [
("1. Which of the following is the output of the following python code? \n str1=\"TamilNadu\" \n print(str1[::-1]) \n \n(a) Tamilnadu (b) Tmlau \n(c) udanlimaT d) udaNlimaT","D"),
("2. What will be the output of the following code? str1 = \"Chennai Schools\" \n str1[7] = \"-\" \n(a) Chennai-Schools (b) Chenna-School \n(c) Type error \n(D) Chennai","C"),
("3. Which of the following operator is used for concatenation? \n(a) + (b) & \n(c) * d) = ","A"),
("4. Defining strings within triple quotes allows creating:a) Single line Strings (b) Multiline Strings \n(c) Double line Strings (d) Multiple Strings","B"),
("5. Single line Strings \n(a) Changeable \n(c) Immutable (b) Mutable (d) flexible ","C"),
("6.Which of the following is the slicing operator? \n(a) { } (b) [ ] \n(c) < > (d) ( ) ","B"),
("7.What is stride? \n \n(a) index value of slide operation (b) first argument of slice operation \n(c) second argument of slice operation (d) third argument of slice operation ","D"),
("8.Which of the following formatting character is used to print exponential notation in upper case? \n \n(a) %e (b) %E \n(c) %g (d) %n ","B"),
("9.Which of the following is used as placeholders or replacement fields which get replaced along with format( ) function?\n(a) { } (b) < > \n(c) ++ (d) ^^ ","A"),
("10.The subscript of a string may be: \n(a) Positive \n(c) Both \n(a) and (b) (b) Negative (d) Either \n(a) or (b) ","C")
],
chapter9_questions : [
("1. Pick odd one in connection with collection data type \n(a) List (b) Tuple \n(c) Dictionary (d) Loop","D"),
("2. \nLet list1=[2,4,6,8,10], then print(List1[-2]) will result in \n(a) 10 (b) 8 \n(c) 4 (d) 6","B"),
("3. Which of the following function is used to count the number of elements in a list? \n(a) count() (b) find() \n(c)len() (d) index()","C"),
("4. \nIf List=[10,20,30,40,50] then List[2]=35 will result \n(a) [35,10,20,30,40,50] (b) [10,20,30,40,50,35] \n(c) [10,20,35,40,50] (d) [10,35,30,40,50]","C"),
("5. \nIf List=[17,23,41,10] then List.append(32) will result \n(a) [32,17,23,41,10] (b) [17,23,41,10,32] \n(c) [10,17,23,32,41] (d) [41,32,23,17,10] ","B"),
("6. Which of the following Python function can be used to add more than one element within an existing list? \n(a) append() (b) append_more() \n(c)extend() (d) more()","C"),
("7. What will be the result of the following Python code? S=[x**2 for x in range(5)] print(S) \n(a) [0,1,2,4,5] (b) [0,1,4,9,16] \n(c) [0,1,4,9,16,25] (d) [1,4,9,16,25]","B"),
("8. What is the use of type() function in python? \n(a) To create a Tuple (b) To know the type of an element in tuple. \n(c) To know the data type of python object. (d) To create a list.","C"),
("9. Which of the following statement is not correct? \n(a) A list is mutable (b) A tuple is immutable. \n(c) The append() function is used to add an element.(d) The extend() function is used in tuple to add elements in a list.","D"),
("10. \nLet setA={3,6,9}, setB={1,3,9}. What will be the result of the following snippet? print(setA|setB) \n(a) {3,6,9,1,3,9} (b) {3,9} \n(c) {1} (d) {1,3,6,9}","D"),
("11. Which of the following set operation includes all the elements that are in two sets but not the one that are common to two sets?\n(a) Symmetric difference \n(B) Difference \n(c) Intersection \n(D) Union","A"),
("12. The keys in Python, dictionary is specified by \n(a) = (b) ; \n(c)+ (d) : ","D")
],
chapter10_questions : [
("1. Which of the following are the key features of an Object Oriented Programming language? \n(a) Constructor and Classes (b) Constructor and Object \n(c) Classes and Objects (d) Constructor and Destructor","C"),
("2. Functions defined inside a class: \n(a) Functions (b) Module \n(c) Methods (d) section","C"),
("3. Class members are accessed through which operator? \n(a) & (b) . \n(c) # (d) %","B"),
("4. Which of the following method is automatically executed when an object is created?\n(a) __object__( ) \n(b) __del__( ) \n(c) __func__( ) \n(d) __init__( )","D"),
("5. A private class variable is prefixed with \n(a) __ (b) && \n(c) ## (d) **","A"),
("6. Which of the following method is used as destructor? \n(a) __init__( ) \n(c) __rem__( ) \n(b) __dest__( ) \n(d) __del__( )","D"),
("7. Which of the following class declaration is correct? \n(a) class class_name (b) class class_name<> \n(c) class class_name: (d) class class_name[ ]","C"),
("8. Which of the following is the output of the following program? class Student: def __init__(self, name): self.name=name S=Student(“Tamil”) \n(a) Error \n(c) name (b) Tamil (d) self ","A"),
("9. Which of the following is the private class variable? \n(a) __num (b) ##num \n(c) $$num (d) &&num ","A"),
("10. The process of creating an object is called as: \n(a) Constructor (b) Destructor \n(c) Initialize (d) Instantiation","D")
],
chapter11_questions : [
("1. What is the acronym of DBMS? \n(A) DataBase Management Symbol \n(B) Database Managing System \n(C) DataBase Management System \n(D) DataBasic Management System ","C"),
("2 A table is known as a) tuple b) attribute c) relation d)entity","C"),
("3 Which database model represents parent-child relationship? a) Relational b) Network c) Hierarchical d) Object","C"),
("4 Relational database model was first proposed by \n(A) E F Codd \n(B) E E Codd \n(C) E F Cadd d) E F Codder","A"),
("5 What type of relationship does hierarchical model represents? \n(A) one-to-one \n(B) one-to-many \n(c) many-to-one \n(D) many-to-many","B"),
("6. Who is called Father of Relational Database from the following?a) Chris Date b)Hugh Darween c) Edgar Frank Codd d) Edgar Frank Cadd","C"),
("7. Which of the following is an RDBMS? a) Dbase b) Foxpro c) Microsoft Access d) SQLite","D"),
("8 What symbol is used for SELECT statement? a) σ b) Π c) X d) Ω","A"),
("9 A tuple is also known as a) table b) row c) attribute d) field","B"),
("10. Who developed ER model? a) Chen c) Chend b) EF Codd d) Chand","A")
],
chapter12_questions : [
("1. Which commands provide definitions for creating table structure, deleting relations, and modifying relation schemas. a. DDL b. DML c. DCL d. DQL","A"),
("2. Which command lets to change the structure of the table? a. SELECT b. ORDER BY c. MODIFY d. ALTER","D"),
("3. The command to delete a table is A) DROP B) DELETE C) DELETE ALL D) ALTER TABLE","A"),
("4. Queries can be generated using \n(A) SELECT \n(B) ORDER BY \n(C) MODIFY \n(D) ALTER","A"),
("5. The clause used to sort data in a database \n(A) SORT BY \n(B) ORDER BY \n(C) GROUP BY \n(D) SELECT","A")
],
chapter13_questions : [
("1. A CSV file is also known as a .... \n(A) Flat File \n(B) 3D File \n(C) String File \n(D) Random File","A"),
("2. The expansion of CRLF is \n(A) Control Return and Line Feed \n(B) Carriage Return and Form Feed \n(C) Control Router and Line Feed \n(D) Carriage Return and Line Feed","D"),
("3. Which of the following module is provided by Python to do several operations on the CSV files? \n(A) py \n(C) csv \n(B) xls \n(D) os","C"),
("4. Which of the following mode is used when dealing with non-text files like image or exe files? \n(A) Text mode \n(B) Binary mode \n(C) xls mode \n(D) csv mode","B"),
("5. The command used to skip a row in a CSV file is \n(A) next() \n(B) skip() \n(C) omit() \n(D) bounce()","A"),
("6. Which of the following is a string used to terminate lines produced by writer()method of csv module? \n(A) Line Terminator \n(B) Enter key \n(C) Form feed \n(D) Data Terminator","A"),
("7. What is the output of the following program? import csv d=csv.reader(open('c:\PYPRG\ch13\city.csv')) next(d) for row in d: print(row) A) chennai,mylapore \n(B) mumbai,andheri \n(C) chennai \n(D) chennai,mylapore","B"),
("8. Which of the following creates an object which maps data to a dictionary? \n(A) listreader() \n(B) reader() \n(C) tuplereader() \n(D) DicReader ()","D"),
("9. Making some changes in the data of the existing file or adding more data is called \n(A)Editing \n(B) Appending \n(C)Modification \n(D) Alteration","B"),
("10. What will be written inside the file test.csv using the following program import csv D = [['Exam'],['Quarterly'],['Halfyearly']] csv.register_dialect('M',lineterminator = '\n') \n(A) Exam Quarterly Halfyearly \n(B) Exam Quarterly Halfyearly \n(C) E Q H \n(D) Exam, Quarterly, Halfyearly","D")
],
chapter14_questions : [
("1. Which of the following is not a scripting language? \n(A) JavaScript \n(B) PHP \n(C) Perl \n(D) HTML","D"),
("2. Importing C++ program in a Python program is called \n(A) wrapping \n(B) Downloading \n(C) Interconnecting \n(D) Parsing","A"),
("3. The expansion of API is \n(A) Application Programming Interpreter \n(B) Application Programming Interface \n(C) Application Performing Interface \n(D) Application Programming Interlink","B"),
("4. A framework for interfacing Python and C++ is \n(A) Ctypes \n(B) SWIG \n(C) Cython \n(D) Boost","C"),
("5.Which of the following is a software design technique to split your code into separate parts? \n(A) Object oriented Programming \n(B) Modular programming \n(C) Low Level Programming \n(D) Procedure oriented Programming","B"),
("6.The module which allows you to interface with the Windows operating system is \n(A) OS module \n(B) sys module \n(c) csv module (d) getopt module","A"),
("7.getopt() will return an empty array if there is no error in splitting strings to \n(A) argv variable \n(B) opt variable \n(c)args variable (d) ifile variable","C"),
("8.Identify the function call statement in the following snippet. if __name__ =='__main__': main(sys.argv[1:]) \n(A) main(sys.argv[1:]) \n(B) __name__ \n(C) __main__ \n(D) argv","A"),
("9.Which of the following can be used for processing text, numbers, images, and scientific data? \n(A) HTML \n(B) C \n(C) C++ \n(D) PYTHON","D"),
("10.What does __name__ contains ? \n(A) c++ filename \n(C) python filename \n(B) main() name \n(D) os module name","C")
],
chapter15_questions : [
("1. Which of the following is an organized collection of data? \n(A) Database \n(B) DBMS \n(C) Information \n(D) Records","A"),
("2. SQLite falls under which database system? \n(A) Flat file database system \n(B) Relational Database system \n(C) Hierarchical database system \n(D) Object oriented Database system","B"),
("3. Which of the following is a control structure used to traverse and fetch the records of the database? \n(A) Pointer \n(B) Key \n(C) Cursor \n(D) Insertion point","C"),
("4. Any changes made in the values of the record should be saved by the command \n(A) Save \n(B) Save As \n(C) Commit \n(D) Oblige","C"),
("5. Which of the following executes the SQL command to perform some action? \n(A) Execute() \n(B) Key() \n(C) Cursor() \n(D) run()","A"),
("6. Which of the following function retrieves the average of a selected column of rows in a table? \n(A) Add() \n(B) SUM() \n(C) AVG() \n(D) AVERAGE()","C"),
("7. The function that returns the largest value of the selected column is \n(A) MAX() \n(B) LARGE() \n(C) HIGH() \n(D) MAXIMUM()","A"),
("8. Which of the following is called the master table? \n(A) sqlite_master \n(B) sql_master \n(C) main_master \n(D) master_main","A"),
("9. The most commonly used statement in SQL is \n(A) cursor \n(B) select \n(C) execute \n(D) commit","B"),
("10. Which of the following clause avoide the duplicate? \n(A) Distinct \n(B) Remove \n(C) Where \n(D) commit \n(D) GroupBy","A")
],
chapter16_questions : [
("1. Which is a python package used for 2D graphics? \n a. matplotlib.pyplot b. matplotlib.pip c. matplotlib.numpy d. matplotlib.plt","A"),
("2. Identify the package manager for Python packages, or modules. \na. Matplotlib b. PIP c. plt.show() d. python package","B"),
("3. Identify the purpose of this code and choose the right option. >pip – version \n\n a. Check if PIP is Installed \n b. Install PIP \n c. Download a Package \n d. Check PIP version","D"),
("4. Read the following code: Identify the purpose of this code and choose the right option \n>pip list \n\na. List installed packages \nb. list command \n c. Install PIP \nd. packages installed","A"),
("5. To install matplotlib, the following function will be typed in your command prompt. What does “-U”represents? \n Python –m pip install –U pip \n\n a. downloading pip to the latest version \nb. upgrading pip to the latest version \nc. removing pip \nd. upgrading matplotlib to the latest version","B"),
("8. Which key is used to run the module? \na. F6 b.F4 c.F3 d.F5 ","D"),
("9. Identify the right type of chart using the following hints. \n Hint 1: This chart is often used to visualize a trend in data over intervals of time. \n Hint 2: The line in this type of chart is often drawn chronologically.\n\n a. Line chart b. Bar chart \n c. Pie chart d. Scatter plot","A"),
("10. Read the statements given below. Identify the right option from the following for pie chart.\n Statement A: To make a pie chart with Matplotlib, we can use the plt.pie() function. \n Statement B: The autopct parameter allows us to display the percentage value using the Python string formatting. \n\n a. Statement A is correct \n c. Both the statements are correct \n b. Statement B is correct d. Both the statements are wrong","C")
]
}
result = {"Correct": 0, "Incorrect": 0}
def get_quiz_choice():
print ("\033[1;30;47m")
while True:
try:
quiz_number = int(input('Choose the quiz you like\n1 for {}\n2 for {}\n3 for {}\n4 for {}\n5 for {} \n6 for {}\n7 for {}\n8 for {}\n9 for {}\n10 for {} \n11 for {}\n12 for {}\n13 for {}\n14 for {}\n15 for {} \n16 for {} \n17 for {} \nYour choice:'.format(chapter1_questions,chapter2_questions,chapter3_questions,chapter4_questions,chapter5_questions,chapter6_questions,chapter7_questions,chapter8_questions,chapter9_questions,chapter10_questions,chapter11_questions,chapter12_questions,chapter13_questions,chapter14_questions,chapter15_questions,chapter16_questions,random_questions)))
except ValueError:
print ("Choice should be 1 to 17, please try again \n")
else:
if 0 >= quiz_number or quiz_number >17:
print ("Invalid value, please try again\n")
else:
return quiz_number
def get_answer(question, correct_answer):
while True:
try:
print ("\033[1;50;47m Q: {} \n\t\t\t".format(question))
answer = input(" ? ")
print ("\033[1;30;47m ")
except ValueError:
print ("Not a number, please try again\n")
else:
if answer is not "A" and answer is not "B" and answer is not "C" and answer is not "D"and answer is not "a" and answer is not "b" and answer is not "c" and answer is not "d":
print ("Invalid value, please try again\n")
elif answer.lower()== correct_answer.lower():
result["Correct"] += 1
return True
else:
result["Incorrect"] += 1
print("\033[1;31;47m \n")
print("Correct answer is "+str(correct_answer))
return False
print ("\033[1;30;47m")
choice = get_quiz_choice()
if choice!=17:
quiz_name = questions[choice - 1]
#print("quiz_name : "+str(quiz_name))
print ("\nYou chose the {}\n".format(quiz_name))
quiz_questions = quiz[quiz_name]
for q in (quiz_questions):
print ("Your answer is: {}\n".format(str(get_answer(q[0], q[1]))))
print("\033[1;30;47m \n")
elif choice == 17:
print("\n\n\t\t Random 20 questions ... Good luck \n\n")
for i in range(1,21,1):
qtnidx=random.randint(0,15)
quiz_name=questions[qtnidx]
quiz_questions = quiz[quiz_name]
qtnnum=random.randint(0,len(quiz_questions)-1)
q=quiz_questions[qtnnum]
print ("Your answer is: {}\n".format(str(get_answer(q[0], q[1]))))
print("\033[1;30;47m \n")
print("\033[1;34;47m \n")
print("###########################################################################")
print("\t\t Test taken on : "+str(quiz_name))
print("\t\t"+str(result))
rst=result
percent=(rst['Correct']/(rst['Correct']+rst['Incorrect']))*100
print("\t\t Success percentage : "+str(percent)+"%")
print("###########################################################################")
print("\033[1;30;47m")