Five years Integrated M.Sc.(IT)(Semester 5) Question Bank 060010502:Programming in Python Unit-1:Introduction To Python Q-1 Answer the following Questions in short. 1. Which operator is used for slicing? 2. What is lines and indentation. 3. What do you mean by mutable objects? 4. Define simple and compound statement. 5. What does \(back slash) character indicate? 6. What is slicing? 7. What is the use of pass statement 8. What is short-circuit operator? 9. Define with example mutating methods of list. 10. Which data types are available in Python? 11. Which components of lexical structure are used to write program in Python? 12. How to terminate multiline statement? 13. How print statement can be written? 14. What is the purpose of del statement? 15. How to specify multiline comment in Python? 16. Difference between * and ** operator. 17. Define various types of operator available in Python. 18. How identity and membership operator differ? 19. What is the difference between append() and extend() list methods. 20. How augmented assignment differ from plain assignment? Q-2 Answer the following Questions in detail. 1. Write a short note on Python programming language evolution 2. Explain various features of Python programming language in detail. 3. Explain lexical structure of Python programming language. 4. Write a short note on procedure oriented programming language. 5. Write a short note on object oriented programming language. 1
6. Write a short note on datatype of python 7. Explain various types of tokens available in python. 8. What is numeric operations, and explain it in detail. 9. Explain sequence operations with example. 10. Explain list with proper example. 11. Explain print statement with appropriate example. 12. Explain operators and expressions with example. 13. Write a note on python shell. 14. Explain string delimiters and string concatenation with example. 15. Explain expression evaluation process in python with example. 16. Explain quotation and comments in detail. 17. Explain assignment operator with suitable examples. 18. What is dictionary explain with example. 19. Explain operator s precedence in Python 20. Write a note on Python for being powerful programming language in your words. Q-3. Select most appropriate answer from the given option: 1. Each Python Program is made up of one or more. a. Logical lines b. Physical lines c. String literals d. (#) hash sign 2. Which of the following is not a keyword in Python? a. global b. lambda c. define d. with 3. What is the output of the code X=tuple( wow,) Print(X) a. runtime error b. ('w', 'o', 'w') c. ('w', 'o', 'w', ',') d. None of the above. 2
4. Which characters does not allowed to be a part of identifiers. a. @, &, $ b. &, @, % c. %, @, $ d. %, *, & 5. What is the output of below code x=dict.fromkeys('hel ',2) print(x) a. {' ': 2, 'e': 2, 'h': 2, 'l': 2} b. {'h': 2, 'e': 2, 'l': 2, ' ': 2} c. {' ': 2, 'l': 2, 'e': 2, 'h': 2} d. Runtime error 6. Which of the following is an augmented operator. a. <<== b. << c. >> d. == 7. The priority of is higher then. a. ^ (exclusive or), (regular or) b. %(modulo), &(Bitwise and) c. in,is d. **=,!= 8. divmod function is used to return. a. remainder of a given arguments b. integral division of given arguments c. floating-point division of given arguments d. pair containing quotient and remainder 9. Find the output of below code x=[1,2,3,4,5] del x[1,2] print(x) a. [1,4,5] b. [3,4,5] c. Runtime error d. [1,2,3,4,5] 10. output of the following code: 3
a=5 a<<=2 a. 20 b. 16 c. 32 d. 8 print(a) 11. What is the output of below code a=['d',1,23,45,3,23,"bye"] a.count(11) a. Error b. 1 c. 0 d. None 12. Which of the following is not comparison operator? a. < b. == c.!= d. None of the above. 13. What is output of below code: a=int( 101,2) print(a) a. 101 b. 2 c. Error d. 5 14. Output of the following code will be: X=[1,2,3,4] X[::-1] a. [1,2,3,4] b. -1 c. Error d. [4,3,2,1] 15. Output of following code will be: x=[1,2,3,4,5] del x[::2] print(x) a. [2,4] b. [3,5] 4
c. [1,2] d. None of the above 16. Which of the following type is mutable object? a. Strings b. Tuples c. Lists d. Sets 17. What will be the output of below code: x=5 x>>=2 print(x) a. 2 b. 10 c. 1 d. 0 18. Which function is used to print maximum allowable negative integer number in python. a. sys.maxint b. sys.maxint-1 c. sys.max d. sys.max-1 19. Which of the following is not a mutating method of list. a. append(x) b. remove(x) c. reverse() d. count(x) 20. output of below code will be: a=10 b=20 a,b=b,a print(a,b) a. 10 20 b. 20 10 c. 20 20 d. 10 10 Q-4 Fill in the blanks. 1. Using and you can create data values of other types. 2. Strings in python are. 5
3. To indicate long type value is used. 4. Python statements are normally terminated by delimiter. 5. can be decimal, octal, or hexadecimal. 6. statement contains other statements and controls their execution. 7. A is an ordered container of items, indexed by non-negative integers. 8. A sequence of has special meaning of slicing. 9. Enter an empty line to terminate the statements. 10. A list contains items enclosed within. 11. An object that can be altered is known as. 12. A is known as user define object. 13. The accepts any object as its argument and returns the type object that represents the type of obj. 14. An literal is specified with a 0 followed by a sequence of digits from 0 to 7. 15. A python is used to identify the variable, function, class, module or other object. 16. Starting an identifier with indicates a private identifier. 17. allows multiple statements on the single line. 18. are the most versatile compound datatypes of Python. 19. Python s are hash table type. 20. evaluates to false if the variables on the either side of the operator point to the same object and true otherwise. Unit-2: Basic flow statements and classes Q-1 Answer the following Questions in short. 1. What are the purpose of break and continue statement? 2. Write syntax for if statement. 3. Explain raw_input() method in python. 4. What is the alternative for == and!= operator available in python? 5. What is function call? 6
6. What is the purpose of module? 7. How from keyword is helpful in module? 8. What is operator overloading? 9. What is the purpose of init () function? 10. What is difference between *argument and **argument in function? 11. What is difference between list and dictionary? 12. How to specify private member in class? 13. How to access super class method? 14. What is global variable? 15. What is garbage collection? 16. What is constructor? 17. How to include packages in python module? Q-2. Answer the following Questions in detail. 1. Write different ways to join two physical lines in python. 2. What is tokens, explain with various types of token? 3. Explain while and for control statement with example. 4. Write a note on if statement with example. 5. Explain for statement with example. 6. Write a note on function in python with example. 7. Explain lambda function with example. 8. What is namespace? Explain with example. 9. What is bound and unbound method? 10. Write a note on built in object type. 11. Explain class and its benefits in detail. 12. Write a note on class instance and its special method. 7
13. Explain inheritance with example. 14. Write a note on packages in python. 15. Explain module in python with example. 16. Explain method overriding in python. 17. Explain concept of data hiding in python. 18. Write a short note on recursive function with example. Q-3 Select most appropriate answer from the given options: 1. A is group of statement that executes upon request. a. Module b. Function c. Class d. Constructor 2. In a dictionary pair is combination of and. a. Variable, constant b. Key, value c. Attribute, value d. Key, data 3. When executes, the function terminates and the value of the expression is returned. a. Break b. Continue c. Return d. Pass 4. A def statement within a function body defines function. a. Child object b. Neasted function c. Inner class d. Child function 5. A expression is the anonymous equivalent of a normal function whose body is a single return statement. a. Function b. Lambda c. Regular d. None 6. statement is known as docstring of the class. a. init b. doc c. name d. class 8
7. When subclass defines method name same as parent class then it is said to be. a. Overloading b. Overriding c. Instantiation d. None 8. A is a method that you can call on a class. a. Final method b. Static method c. Private method d. Public method 9. Python calls method for the garbage collection. a. init b. del c. cmp d. call 10. is a built in method which returns total number of item in a collection. a. len b. count c. new d. getitem 11. To remove an item from the collection method is used. a. del b. del c. delitem d. remove 12. In python method is alternative for **(power) operation. a. pow b. ipow c. rpow d. pow() 13. function having single return statement. a. Static function b. Constructor c. Lambda function d. In line function 14. Loop gets terminated when statement executes. a. Continue b. Break c. Else d. Finally 9
Q-4 Fill in the blanks below 1. Special method of a class called as, which get call at the time of instantiation. 2. To stop execution of loop statement is used. 3. To define user define method keyword is used. 4. For compound statement symbol indicates starting of block. 5. A collection of class is known as. 6. Class can have constructor namely. 7. To display class name of an object is used. 8. In dictionary every combination of key and value is said to be. 9. A class is set of and. 10. To access data member keyword is used. 11. Statement is used to iterate list value. 12. To print information regarding class is used. 13. is said to be an instance of class. 14. method is used to create constructor. 15. For the concatenation of two string operator is used. 16. method displays documentation string of class. 17. **argument takes argument as the. Unit-3 Strings and Regular Expressions Q-1 Answer the following Questions in short. 1. Differentiate substitute() and safe_substitute(). 2. List out the method associated with regular expression 3. Differentiate find() and rfind() 4. What is the use of maktrans() functions? 5. Explain match() versus search() in python 6. How capitalize() and swapcase() work differently? 10
7. When will you use wrap() and fill() method? 8. What is the significance of optional flags? 9. What is explicit flag argument? 10. When we should use RE functionality? 11. How template class will be used? 12. Which method will return all the characters in upper case? 13. Differentiate title() and capitalize(). 14. What is the use of expandtabs() method? 15. Which functions are known as Boolean functions? 16. What is the purpose of join() function? 17. What is the difference between rindex() and rfind() methods? 18. What is string formatting? 19. List out integer string formatting idioms. 20. What is the purpose of ( ) pattern matching expression? Q-2 Answer the following Questions in detail. 1. Write short note on string objects. 2. Explain string module. 3. Explain template string in detail. 4. Explain text wrapping and filling in detail. 5. Explain regular expression object. 6. Write short note on pattern string syntax. 7. Explain Boolean functions associated with string objects. 8. Write short note on optional flag used in regular expression. 9. Explain match object in detail. 10. Write a note on set of characters pattern matching expression. 11
11. Explain the difference between match and search with appropriate example. 12. What is the purpose of groups() method? 13. Explain all non Boolean methods of string object. 14. Write about string formatting conversion characters. 15. Explain re module with example. 16. What is the importance of groupdict() method? 17. Write a note on alternatives with appropriate example. 18. What is format specifier? Explain functionality of all format specifier. 19. Explain set of characters and group comparatively with respect to regular expression. 20. Write short note on common regular expression idioms. Q-3 Select most appropriate answer from the given options. 1. 5. Option which matches empty string but only at the start of the whole string is a. \A b. \B c. \M d. \E 2. Method related to groups a. Group() b. Groups() c. Groupdict() d. All of the above 3. Maketrans method returns a. Translation table b. Making transferring of table c. Translate the list d. Translation table of list 4. Method returns a copy of s with all uppercase letters converted to lowercase and vice versa is a. Swapcase() b. Capitalize() c. Translate() d. Initcap() 5. String is a type of 12
a. Sequence b. List c. Set d. Dictionary 6. (?#...) represents a. Content of parenthesis is comment. b.content of paranthesis is quickly executable c. Content of paranthesis is look ahead assertation. d. Content of paranthesis is look behind assertation. 7. String module supplies plain string attribute like a. Ascii_letters b. Ascii_swap c. Ascii_title d. Ascii_title 8. To match string irrespective of its case, flag is used. a. L b. M c. S d. I 9. To specify alternatives is used in regular expression. a. () b. {} c. d. [] 10. method returns replacement and the number of replacement. a. sub() b. subn() c. split() d. repl() 11. in match() function object returns the last indices of matched pattern. a. Span b. Start c. End d. Group 12. method returns a copy of string where escape sequence and back references are replaced. a. Span b. Start c. Expand d. End 13. To create sublists based on matched pattern method is used. a. sub() 13
b. split() c. subn() d. index() 14. To match the beginning of the string element is useful. a. $ b. ^ c. % d.! 15. (?P<id> ) element is used to indicate. a. Group b. Parent c. Id d. Process 16. To match any character including newline optional flag is used. a. I b. L c. M d. S 17. To match the end of the string element is useful. a. $ b. ^ c. % d.! 18. To match one digit element is useful. a. \a b. \d c. \D d. \W 19. To match any one of a set of characters element is used. a. ( ) b. * + c. (?...) d. *^ + 20. To match any whitespace characters element is useful. a. \s b. \S c. \t d. \T Q-4 Fill in the blanks. 1. To convert string in title case and methods are useful. 14
2. function returns the number of non-overlapping occurrences of substring. 3. To get the lowest index of substring method is useful. 4. Each tab character is changed into one or more spaces using method. 5. returns true when all characters are digits in string. 6. returns a dictionary containing all named groups of the match. 7. To define complemented character set element is used. 8. and element is used to match the end of string. 9. For the pattern matching module is require to import. 10. To convert upper case into lower case and vice-versa we can use method. 11. To remove both leading and trailing character from string method is useful. 12. Each format specifier is a substring of format that starts with sign. 13. To match a single character format specifier element is used. 14. is known as look behind assertion. 15. matches one digit like [0-9] set. 16. element is used to matches either preceding expression or following expression. 17. method returns true when all the characters in string are letters or digits. 18. To align string left with trailing space method is used. 19. To transform string in title case method is used. 20. To split string in multiple lines method is useful. 15
16
17