Department of Computer Science and Technology, UTU

Similar documents
Babu Madhav Institute of Information Technology, UTU 2015

Programming in Python 2014

Table of Contents. Preface... xxi

Glossary. For Introduction to Programming Using Python By Y. Daniel Liang

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Webgurukul Programming Language Course

Introduction to Python

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

[CHAPTER] 1 INTRODUCTION 1

Python Training. Complete Practical & Real-time Trainings. A Unit of SequelGate Innovative Technologies Pvt. Ltd.

Pace University. Fundamental Concepts of CS121 1

The SPL Programming Language Reference Manual

IT 374 C# and Applications/ IT695 C# Data Structures

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

STSCI Python Introduction. Class URL

The PCAT Programming Language Reference Manual

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Python in 10 (50) minutes

Python I. Some material adapted from Upenn cmpe391 slides and other sources

Introduction to Programming Using Java (98-388)

PYTHON CONTENT NOTE: Almost every task is explained with an example

PYTHON FOR KIDS A Pl ayfu l I ntrodu ctio n to Prog r am m i ng J a s o n R. B r i g g s

Duration: Six Weeks Faculty : Mr Sai Kumar, Having 10+ Yrs Experience in IT

Programming in Python 2016

Python Scripting for Computational Science

Advanced Python. Executive Summary, Session 1

CS260 Intro to Java & Android 03.Java Language Basics

And Parallelism. Parallelism in Prolog. OR Parallelism

Script language: Python Data structures

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Python Scripting for Computational Science

CERTIFICATE IN WEB PROGRAMMING

Advanced Algorithms and Computational Models (module A)

Model Question Paper. Credits: 4 Marks: 140

There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:

GE PROBLEM SOVING AND PYTHON PROGRAMMING. Question Bank UNIT 1 - ALGORITHMIC PROBLEM SOLVING

Full file at

Regular Expressions. Regular Expression Syntax in Python. Achtung!

PTN-202: Advanced Python Programming Course Description. Course Outline

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

5. Single-row function

Decaf Language Reference Manual

Java+- Language Reference Manual


06/11/2014. Subjects. CS Applied Robotics Lab Gerardo Carmona :: makeroboticsprojects.com June / ) Beginning with Python

egrapher Language Reference Manual

Absolute C++ Walter Savitch

PYTHON- AN INNOVATION

Regexator. User Guide. Version 1.3

Variable and Data Type I

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Full file at

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

DaMPL. Language Reference Manual. Henrique Grando

Overview of List Syntax

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

Python. Executive Summary

Introduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1

This course is designed for anyone who needs to learn how to write programs in Python.

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

Python Tutorial. Day 1

Programming Training. This Week: Tkinter for GUI Interfaces. Some examples

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

CSI33 Data Structures

Data Structures (list, dictionary, tuples, sets, strings)

Part IV. More on Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

COMP519 Web Programming Lecture 17: Python (Part 1) Handouts

About Python. Python Duration. Training Objectives. Training Pre - Requisites & Who Should Learn Python

Lecture 2 Tao Wang 1

Fundamentals of Programming Session 4

COIMBATORE EDUCATIONAL DISTRICT

Computer Hardware 6. The

UNIT- 3 Introduction to C++

LISTS WITH PYTHON. José M. Garrido Department of Computer Science. May College of Computing and Software Engineering Kennesaw State University

Strings. Upsorn Praphamontripong. Note: for reference when we practice loop. We ll discuss Strings in detail after Spring break

GraphQuil Language Reference Manual COMS W4115

STRUCTURING OF PROGRAM

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

KEYBOARD SHORTCUTS AND HOT KEYS

Sprite an animation manipulation language Language Reference Manual

Chapter 3 : Informatics Practices. Class XI ( As per CBSE Board) Python Fundamentals. Visit : python.mykvs.in for regular updates

ITP 342 Mobile App Dev. Strings

Cryptol version 2 Syntax

Python Working with files. May 4, 2017

Part III Appendices 165

Typescript on LLVM Language Reference Manual

String Computation Program

COLLEGE OF ENGINEERING, NASHIK-4

The Warhol Language Reference Manual

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

Index COPYRIGHTED MATERIAL

The Decaf Language. 1 Lexical considerations

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

CS 2316 Learning Objectives

Java 1.8 Programming

Transcription:

060010502: Programming in Python Unit 1:Introduction to Python Que: 1 Answer the following question in short. 1. Which components of lexical structure are used write programme? 2. How to terminate the multiline statement? 3. What is block? 4. Which are data types in python? 5. What is difference between * and ** as parameter? 6. Which operator is used for slicing? 7. How Print statement can be written? 8. How augmented assignment differs from plain assignment? 9. Write the importance of line and indentation. 10. What is the difference between append() and extend() of List object. 11. What is short-circuit operator? 12. What is the purpose of del statement? 13. What is slicing? 14. What is mutable object? 15. What is difference between * and ** operator? 16. What does pass keyword indicates? 17. Define simple statement? 18. What does \ (backslash) character indicates? 19. How to specify multiline comment in python? Que: 2 Answer the following question in details. 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. 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. Ms. Bhumika Patel Page 1

20. Write a note on Python for being powerful programming language in your words. Que: 3 Select most appropriate answer from the given option. 1. What will be the output of following statement: >>> type(222222222) a. <type int > b. <type long > c. Error d. <type double > 2. What will be output of following statement: >>> abc +3 a. abc3 b. abc 3 c. Error d. abcabcabc 3. >>> abc *3 a. abcabcabc b. Error c. aaabbbccc d. abc3 4. >>>B = *1, a,2, b,3, c + >>>print [B.reverse()].sort() a. *1,2,3, a, b, c + b. Error c. * a, b, c,1,2,3+ d. None 5. >>>a = [1,2,3] >>>print ( sum :,2+3), list :,a a. Error b. sum : 5 list : [1,2,3] c. ( sum:,5) list : *1,2,3+ d. sum: 5 list *1,2,3+ 6. >>>a= Hello >>> A +a*2::+ a. Error b. Allo c. Alo d. Hello 7. >>>x=y=x=range(3) >>>print y a. Error b. 1 c. None d. [0,1,2] 8. >>> print Python s World Ms. Bhumika Patel Page 2

a. Error b. Python s World c. Python s World d. Python s World 9. >>>a=* a,1, b,2, c,3, d + >>>a[::-1] a. Error b. * a,1, b,2, c,3, d + c. None d. * d,3, c,2, b,1, a + 10. >>>a=* a,1, b,2, c,3, d + >>>a[:-5:] a. Error b. * a,1, b,2, c + c. * b,2, c,3, d + d. None 11. >>>a=1.2+3.4j >>>a.image a. None b. 3.4j c. 3.4 d. 1.2 12. >>>2+4*3 >>>_*2 a. 0 b. 14 c. 28 d. Error 13. >>> < + Word *3+ > a. <Word> b. <Word3> c. <WordWordWord> d. Error 14. >>>a=( aa,123, r,45.43) >>>type(a) a. <type list > b. <type tuple > c. <type dict > d. Error 15. >>>a=(12,43, abc, p ) >>>a[2]+5 a. 48 b. Error c. None d. 435 16. >>>a=['a','b','c','d',1,23,45,3,23,5.4,22.2,"hello","bye"] Ms. Bhumika Patel Page 3

>>>a.index(23) a. 6 b. 5 c. 8 d. Error 17. >>>a=['d',1,23,45,3,23,"bye"] >>>a.remove(23) a. ['d',1,45,3,23,"bye"] b. ['d',1,23,45,3,"bye"] c. 23 d. Error 18. >>>a=['d',1,23,45,3,23,"bye"] >>>a.count(11) a. Error b. 1 c. 0 d. None 19. >>>L=[] >>>s=[[1],[2]] >>>s.extend(l) >>>print s a. [] b. [[1],[2]] c. Error d. [[1],[2],[]] 20. >>>a=['a','b','c','d',1,23,45,3,23,5.4,22.2,"hello","bye"] >>>del a[1:1:] a. b b. 0 c. Error d. None Que 4: Fill in the blanks. 1. Using and you can create data values of other types. 2. Strings in python are. 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. Ms. Bhumika Patel Page 4

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 statement and Classes Que: 1 Answer the following question 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. 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? Que: 2 Answer the following question in details. 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. 13. Explain inheritance with example. Ms. Bhumika Patel Page 5

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. Que: 3 Select most appropriate answer from the given option. 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 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 Ms. Bhumika Patel Page 6

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 Que 4: Fill in the blanks. 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. Ms. Bhumika Patel Page 7

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 Que: 1 Answer the following question 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? 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? Que: 2 Answer the following question in details. 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. Ms. Bhumika Patel Page 8

10. Write a note on set of characters pattern matching expression. 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. Que: 3 Select most appropriate answer from the given option. 1. String is a type of a. Sequence b. List c. Set d. Dictionary 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. Option which matches empty string but only at the start of the whole string is a. \A b. \B c. \M d. \E 6. (?#...) represents a. Content of parenthesis is comment Ms. Bhumika Patel Page 9

b. Content of parenthesis is quickly executable c. Content of parenthesis is look ahead assertation d. Content of parenthesis 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() b. split() c. subn() d. index() 14. To match the beginning of the string element is useful. a. $ b. ^ c. % d.! Ms. Bhumika Patel Page 10

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 21. import re sum = 0 pattern = 'back' if re.match(pattern, 'backup.txt'): sum += 1 if re.match(pattern, 'text.back'): sum += 2 if re.search(pattern, 'backup.txt'): sum += 4 if re.search(pattern, 'text.back'): sum += 8 print sum a. 3 b. 13 c. 4 Ms. Bhumika Patel Page 11

d. 2 Que 4: Fill in the blanks. 1. To convert string in title case and methods are useful. 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. Unit 4:File and Text operations Que: 1 Answer the following question in short. 1. What is file? 2. List out various operations that can be perform on a file. 3. What are the permissions for the file? 4. What is the purpose of listdir() function? 5. What is os.path module? 6. Which method is used to remove current directory? 7. What is the purpose of join() method in file system? 8. List out items of state tuple. 9. List out various modes available for state module. 10. What cmp does in the filecmp module? 11. What is file object? 12. List out various file modes. 13. What is buffering? 14. Which method is used to print total number of lines in a file? 15. What is the purpose of flush() method? 16. What is file object? 17. What is the difference between w and w+ mode? Ms. Bhumika Patel Page 12

18. Explain open() method. 19. Differentiate binary and static mode. 20. What is sequential and non-sequential access? Que: 2 Answer the following question in details. 1. Write a short note on python file system. 2. Explain os module, OSError Exception and errno module in detail. 3. What are the various directory functions of the os module? 4. Explain os.path module function in detail with appropriate examples. 5. Write a note on stat module. 6. Explain filecmp module with example. 7. Exaplain various file descriptor operations in detail. 8. Write a note on file object. 9. Explain attributes and methods of file object. 10. Write a note on fileinput module. 11. Explain linecache module in detail. 12. Explain text input and output in detail. 13. Explain getpass module with appropriate example. 14. Write a note on readline module. 15. What is cursor package? 16. Explain iteration on file object with example. 17. Explain polymorphism in detail. 18. Explain path string attributes of the os module. 19. Write a note on shutil module with appropriate examples. 20. What is standard input? Que: 3 Select most appropriate answer from the given option. What will be the output of following line of code: 1. print r"\nwoow" a. the text exactly like this: r"\nwoow" b. the text like exactly like this: \nwoow c. the letter r and then newline then the text: woow d. the letter r then the text like this: nwoow 2. print "hello" 'world' a. on one line the text: hello world b. on one line the text: helloworld c. hello on one line and world on the next line d. syntax error, this python program will not run 3. f = open("f1.txt","w") f.write("hello how are you") f.read() a. hello how are you b. Hello how are you Ms. Bhumika Patel Page 13

c. Error d. Nothing will be printed 4. f = open("f1.txt","r") f.close f.closed a. Error b. True c. False d. Nothing will be printed 5. f = open("f1.txt","w") f.write("hello how are you") f = open("f1.txt","r") f.seek(5) f.read() a. "o how are you" b. how are you c. how are you d. Error 6. f = open("f1.txt","w") f.write("hello how are you") f = open("f1.txt","r") f.read() f.read() a. Hello how are you b. Hello how are you c. d. Error 7. f = open("f1.txt","w") f.write("hello how are you") f = open("f1.txt","r") f.seek(3) f.tell() a. 'lo how are you' b. 3 c. 3L d. Nothing will be printed 8. f = open("f1.txt","w") f.name() a. f1.txt b. Error c. f1.txt d. Nothing will be printed Ms. Bhumika Patel Page 14

9. f = open("f1.txt","r") f.seek(50) f.read() a. Error b. Hello how are you c. are you d. 10. f = open( f1.txt, r ) f.seek(-1) a. hello how are you b. Hello how are you c. Error d. Nothing will be printed 11. method returns the access mode of file. a. access b. mode c. chmode d. isatty 12. method returns one line from file. a. read b. readline c. readlines d. readone 13. method is used to set the file pointer at any particular position. a. tell b. seek c. reach d. set 14. method returns a tuple of substring that matches pattern. a. group b. groups c. expand d. match 15. match object consists read only attribute which gives the last index of match substring. a. lastgroup b. lastindex c. end d. eol 16. The module supplies symbolic names for error code numbers. a. exception b. error c. errno d. noerrror 17. method ofos module is used to remove file from particular location. a. remove b. rmdir Ms. Bhumika Patel Page 15

c. removedirs d. delete 18. method returns a pair of string in which path is separated from file. a. split b. splitext c. splitdrive d. sep 19. To compare two files named by path string method is used. a. compare b. cmp c. cmpfiles d. dircmp 20. method is used to copy just the content of one file to another except permission of file. a. copy b. copy2 c. copyfile d. copyfileobj Que 4: Fill in the blanks. 1. The string that denotes current directory is. 2. To indicate line separator string is used. 3. method provides 10 items of information about file or directory path. 4. method returns true if string is file. 5. To separate drive name from path method is useful. 6. method converts path value in normal case. 7. To merge multiple path method is helpful. 8. The module supplies methods to copy and move files. 9. getpass() method belongs to module. 10. The readline module contains method to add string as a line at the end of the history buffer. 11. getpass module contains method to return the current user s username. 12. Instance of OSError indicates numeric code of the operating system error. 13. method returns the current position of file pointer. 14. After f.close() read only attribute returns true. 15. flush() method requests that f s buffer to be the operating system. 16. read only attribute returns the mode of currently open file. 17. method sets the file pointer at particular position in file. 18. method returns total number of lines of a file. 19. The os module contains method to change the current directory. 20. method unlinks the file from path. Unit 5:Tkinter and Events Que: 1 Answer the following question in short. 1. What is GUI? 2. What is purpose of Tkinter module? Ms. Bhumika Patel Page 16

3. What is importance of mainloop() method? 4. What is container? 5. What is widget? 6. What is dialog? 7. List out common widget options. 8. How to set background image in window? 9. List out file dialog methods. 10. What is the purpose of command property? 11. What is the importance of config() method in window? 12. Explain iconify and deiconify property. 13. What is the meaning of withdraw window? 14. How to set menu bar in window? 15. What is the purpose of resizable() method? 16. List out menu specific methods. 17. What is the purpose of cascade option in menu? 18. What is event? List out event types. 19. List out mouse events. 20. What is the purpose of bind() method? Que: 2 Answer the following question in details. 1. Explain events with example. 2. Write a note on text widget with appropriate example. 3. Explain the purpose of container widget with example. 4. Write a note on tkfiledialog module. 5. Explain color options with appropriate examples. 6. Write a note on dialog with appropriate example. 7. Write a note on common widget methods. 8. Explain button and checkbutton control with example. 9. Write a note on entry and listbox with appropriate example. 10. Explain container widget with example. 11. Write a note on menu with example. 12. Explain Text widget with example. 13. Write a note on Tkinter event with its type. 14. Explain event replated methods. 15. Explain other callback related methods with example. 16. Explain scrollbar control with example. 17. Explain tkcolorchosser module with example. 18. Explain keyboard event with appropriate example. 19. Explain mouse event with appropriate example. 20. What is canvas widget? Que: 3 Select most appropriate answer from the given option. 1. Which method is used to handle the control of the widget? a. pack() b. mainloop() Ms. Bhumika Patel Page 17

c. command() d. bind() 2. Which of the following is not the type of dialog box? a. showerror b. showinfo c. showwarning d. showwarn 3. Which of the following is used to take input as yes or no from user? a. askokcancel b. askquestion c. askyesno d. askretrycancel 4. Which of the following is not the method of thfiledialog? a. askdirectory b. askfile c. askopenfilename d. askopenfilenames 5. Which option is used to set the active foreground color? a. highlightcolor b. highlightforeground c. activeforeground d. activebackground 6. Which option is used to set callable method? a. anchor b. bind c. command d. none 7. Which method is used to close the window? a. quit() b. withdraw() c. close() d. exit() 8. Which of the following method works similar to command option of widget? a. call() b. invoke() c. bind() d. none of the above 9. Which of the following is widget of container type? a. Frame b. Toplevel c. Entry d. Listbox 10. Which of the following widget contains get() and set() method to get and set an integer value? a. Entry b. Listbutton c. Scale Ms. Bhumika Patel Page 18

d. Scrollbar 11. Which of the following method is used to connect event with action? a. bind() b. binder() c. command() d. none 12. Which of the following is not the event of mouse? a. Button-1 b. Button-3 c. B3-Motion d. B1-Click 13. Which of the following method is used to release the connection among widget and event? a. release() b. unbind() c. unbinder() d. none 14. Which of the following event object describes key s symbolic name? a. Key b. Keyname c. Keysym d. Char 15. Which of the following is not the type of keyboard event? a. Key b. Special key c. Normal key d. Numeric key 16. Which of the following event handles the enter key press? a. <Enter> b. <Return> c. <In> d. None 17. Which of the following option is used to set the shortcut in menu option? a. Key b. Underline c. Invoke d. None 18. Which of the following method is used to maximize the window from taskbar? a. max b. deiconify c. maximize d. none 19. Which of the following is not the Tkinter widget? a. Button b. Textbox c. Listbox d. Scale Ms. Bhumika Patel Page 19

20. Which of the following module is mandatory to import for widget development? a. tk b. tcl c. tkinter d. Tkinter Que 4: Fill in the blanks. 1. For tkmessagebox parameter asks user yes/no question. 2. To open a file method of tkfiledialog module is helpful. 3. To set the high light color method is used. 4. To set extra space for widget and method is used. 5. To show the three dimensional effect method is used. 6. option is set to callable arguments, executes when user clicks on the widget. 7. option is used to set the display text of any widget. 8. To configure any widget with event method is used. 9. Underline option sets the indexed character as shortcut. 10. mainloop() method allows event to enter into. 11. method returns width of window format. 12. module needs to be imported before developing any widget. 13. class implements a widget that lets the user input a value by sliding a cursor along a line. 14. To set window as icon on taskbar method is us 15. ed. 16. and are container widget to create multiple windows. 17. To add separator in menu method is used. 18. To set action on left mouse click event is used. 19. event is used to set the event on mouse movement. 20. To remove all callbacks method is used. 21. event is used to handle the event of key press. Unit 6:Working with Database Que: 1 Answer the following question in short. 1. Which is inbuilt DBMS with python? 2. List out various factory functions. 3. Which are type descriptor attributes? 4. What is the purpose of connect() method? 5. What is the purpose of commit() method? 6. What is cursor? 7. What is the purpose of execute() method in cursor? 8. What is the difference between execute() and executemany() methods? 9. Differentiate fetchall(), fetchmany(), and fetchone()? 10. What is the purpose of rowcount() method? 11. List out various DBAPI compliant modules. 12. What is the purpose of rollback() method? 13. Differentiate Timestamp() and TimestampFromTicks(). 14. What is the purpose of ROWID in type descriptor attributes? Ms. Bhumika Patel Page 20

15. Explain connect function. 16. What is the purpose of qmark in query execution? 17. What ADO and COM stands for? 18. What is the purpose of host in connect function? Que: 2 Answer the following question in details. 1. Write a short note on parameter style in Python. 2. Explain connection object with all its methods. 3. Write a note on factory function with all its methods. 4. Write a short note on MySQL. 5. Write source code to create and connect database and explain it. 6. Write source code to insert records in database with proper explanation. 7. Write source code to retrieve data from database and explain it. 8. Write source code to delete data from database with proper explanation. Que 3: Fill in the blanks. 1. After importing DBAPI compliant module, call the module s function. 2. A DBAPI compliant module has an attribute to identify the style of markers used as placeholders for parameters. 3. method is used to determine runtime parameter values. 4. With you pass to execute a single statement string, with a placeholder instead a value. 5. performs parsing and preparation just once, giving potentially better performance. 6. The read only string attribute tells your program how it should use parameter substitution with that module. 7. Parameter passed to the database via must be of the right type. 8. method of factory function returns an object representing the string of bytes as a BLOB. 9. A cursor instance s attribute describes the types and other characteristics of each column of query. 10. attribute of DBAPI compliant module describes columns containing numbers of any kind. 11. The DBAPI module does not mandate, that accept named argument. 12. method terminates the database connection and release all the related resources. 13. method returns new instance of class Cursor. 14. Parameter is a sequence when the module s is format, numeric, or qmark. 15. The DBAPI compliant does not support the SQL clause. 16. method closes the cursor and releases all related resources. 17. method is used to roll back the current transection in database. 18. To get all remaining result rows from the last query as a sequence of tuple method is used. 19. A read only attribute that specifies the number of rows fetched. 20. method is used to commit the current database transection. Ms. Bhumika Patel Page 21