0% found this document useful (0 votes)
122 views

Python QB

This document contains questions from 5 modules that cover a variety of Python programming concepts for rapid application development using Python. The modules cover topics such as flow control statements, loops, functions, lists, tuples, dictionaries, classes, file handling, regular expressions, JSON, CSV files and web scraping. Example code is provided for many of the questions to demonstrate the programming concepts.

Uploaded by

Adil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

Python QB

This document contains questions from 5 modules that cover a variety of Python programming concepts for rapid application development using Python. The modules cover topics such as flow control statements, loops, functions, lists, tuples, dictionaries, classes, file handling, regular expressions, JSON, CSV files and web scraping. Example code is provided for many of the questions to demonstrate the programming concepts.

Uploaded by

Adil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Rapid programming Application using python 18CS631

QUESTION BANK

MODULE 1
1. Explain if, else and elif flow control statements with suitable examples.
2. Explain the working of while loop with suitable example.
3. Explain the working of for loop with suitable example.
4. Explain break and continue statements in python with examples for each.
5. Briefly explain the working of range() function.
6. Explain with example print(), input(), string replication in python.
7. Write a program in python to find the largest of 3 using elif statement.
8. Discuss exception handling in Python with an example.
9. Explain how to pass parameters in user-defined functions.
8. What is a variable? List the rules to declare a variable in python? Demonstrate the same with
example.
11. Briefly explain the usage of keyword import in python.
12. Explain local and global scope with local and global variables.
13.Demonstrate the Exception handling with a python program to convert Celsius to
Farhenheit.(F=(9/5)*C+32)
14. Explain string concatenation with example.
15.Explain storing of values in python variables.

Department Of CSE, FETW, Sharnbasva University, Kalaburagi Page 1


Rapid programming Application using python 18CS631

MODULE 2
1. Define list. How do you create a list? Give examples.
2. Explain the various list methods with examples
3.Explain how tuple is different from a list with suitable example.
4. What are the different ways of deleting elements from a list? Discuss with suitable functions.
5.Write a python program to count the number of occurrences of each letter in the given string
“DEPARTMENT OF CSE”.
6. When do we encounter TypeError, ValueError and IndexError while operating on Lists?
7. Consider the list scores = [5, 4, 7, 3, 6, 2, 1] and write the python code to perform the
following operations:
i) Insert an element 9 at the beginning of the list.
ii) Insert an element 8 at the index position 3 of the list.
iii) Insert an element 7 at the end of the list.
iv) Delete all the elements of the list.
v) Delete an element at the index position 3.
vi) Delete an element at the beginning of the list.
8. For the following three questions, let‟s say bacon contains the list [3.14, 'cat', 11, 'cat', True].
i) What does bacon.index('cat') evaluate to?
ii) What does bacon.append(99) make the list value in bacon look like?
iii) What does bacon.remove('cat') make the list value in bacon look like?
9. Define a dictionary type in Python. Give example.
10.With examples discuss get(),item(),keys(), values() dictionary methods in python.
11.With code snippet explain join() and split() string methods.
12.Develop a python program to repeatedly asks users for their age and password until they
provide valid input.
13.Explain how dictionary is different from list.
14. What are Tuples ? Explain with examples how tuples are created. Compare Tuple with list.
Discuss the following Dictionary operations and functions with examples
1. Accessing , Updating , Deleting , Traversing (Iteration) , Comparing

Department Of CSE, FETW, Sharnbasva University, Kalaburagi Page 2


Rapid programming Application using python 18CS631

2. len ,(in) membership + (concatenation) and * (Repetition)


15. Define String? Explain how the strings are accessed and traversed.
16. Explain the concept of string with suitable examples
17. Explain at least 5 String in built methods with examples.
18. Briefly explain the usage of pyperclip module.
19. Explain get() and setdefault() methods in dictionary with suitable code snippet.
20. Define a tuple. Give an example to illustrate creation of a tuple.
21. How do you create an empty tuple and a single element tuple
22. How do you create a tuple using a string and using a list? Explain with example.
23. Demonstrate how dictionary items can be represented as list of tuples

Module-3
1. Explain assert statement. Illustrate the situation of getting Assertion Error exception.
2. What are regular expressions? Describe question mark, star, plus and dot regex symbols with
suitable python code snippet.
3. Write a program in python that reads a string with five characters which starts with ‘a’ and
ends with ‘z’. Print search successful if pattern matches string.
4. Explain any five character class with example.
5. With code snippet explain saving variables using the shelve module and pprint.pformat()
6.Explain functions of Shutil module with examples.
7.Explain buttons in the Debug control window.
8.What is meant y compressing files? Explain reading, extracting and creating ZIP code snippet.
9.Explain os.path module with examples.
10.Explain the process of reading the file and writing to the files with example.
11.Discuss the following methods of os module i)chdir ii)rmdir iii)walk iv)listdir
12.What is file compression? Explain reading, extracting and creating a Zip file with code
snippet.

Department Of CSE, FETW, Sharnbasva University, Kalaburagi Page 3


Rapid programming Application using python 18CS631

Module-4
1. Define class and object. Give an example for creating a class and an object of that class.
2. What are attributes? Explain with an example and draw respective object
diagram.
3. Write a program to create a class called Point with two attributes x and y.
4. Explain class diagrams with example.
5. Explain the _ _init_ _ method with example.
6. With example explain type-based dispatch.
7. Write a program in python to retrieve the current date and print the present day of the
week using datetime module.
8. Write following functions and demonstrate the working of these functions by creating
suitable objects.
To read attribute values
To display point as an ordered pair
To find distance between two points
To find the midpoint of two points
To find reflex of the point about x-axis i.e., it must return a new point
object
Example: point(5,10) -> reflex_x must return a new point (5,-10)
9. Write a program to create a class called Rectangle with the help of a corner
point, width and height. Write following functions and demonstrate their working:
To find and display center of rectangle
To display point as an ordered pair
To resize the rectangle
To find area and perimeter of a rectangle
6. Differentiate copy.copy() and copy.deepcopy() with suitable examples.
7. Differentiate between class variable and instance variable with suitable
examples.
8. Discuss the functions isinstance(),hasattr() with suitable examples.
9. With help of programming examples explain the difference between Prototype and Planned
Programming Development.

Department Of CSE, FETW, Sharnbasva University, Kalaburagi Page 4


Rapid programming Application using python 18CS631

10. Differentiate pure functions and modifiers with suitable examples


11. What is a Docstring? Why are they written?
12. What do you mean by “instance as returning value”? Explain with an example.
13.How do you find the memory address of an instance of a class?
14. List out the object oriented characteristics possessed by Python.
15. Differentiate methods and functions.
16.Write a note on data encapsulation
17. Discuss the significance of __init__() method in Python with a proper example code snippet.
18. Briefly discuss self keyword in Python.
19. What does __str__() method do in Python? Illustrate with a code snippet.
20. Discuss operator overloading. Mention any five operators with respective special functions to
be overloaded in Python.
21. Write a program to add two point objects by overloading + operator. Overload __str__() to
display point as an ordered pair.
22. Write a program to create a class Time to represent time in HH:MM:SS format. Perform
following operations:
a.Overload + to add two time objects
b. Overload + to add a numeric value to a time object (commutative)
c. Overload __str__() to display time in appropriate format
23. What is class, object,attributes. Explain copy.copy() with an example.
24. Demonstrate pure functions and modifiers with an example.
25. use the datetime module to write a program that gets the current date and prints that day of
the week.
26. Explain operator overloading and polymorphism with examples.
27.Illustrate the concepts of inheritance and class diagrams with examples.
28.Write a function called print time that takes a time object and print it in the form
hour:minute:second

Department Of CSE, FETW, Sharnbasva University, Kalaburagi Page 5


Rapid programming Application using python 18CS631

Module-5
1.Explain Parsing Html with the beautiful soup module with code snippet for creating ,finding an
element and getting data.
2.What methods do seleniums webelement object have for simulating mouseclick and
keyboardkeys. Explain with python code snippet.
3. Write a python program to access cell in a worksheet.
4. Write a program to get a list of all files with a pdf extension in the current working directory
and sort them.
5. Demonstrate the JSON module with python program.
6. What are the advantages of CSV files? Explain the reader objects and writer objects with
python code.
7. What is web scraping? Explain the following terms webbrowser, Requests, beautiful Soup,
Selenium
8. Explain downloading files from the web with the requests Module
9. Explain saving downloaded files to the Hard Drive
10. Explain creating and saving excel documents in python with an example
11. Explain setting the Font Style of cells in python with example
12. With an code snippet explain extracting Text from PDFs.
13. Explain adding pictures to the word document with code snippet in python

Department Of CSE, FETW, Sharnbasva University, Kalaburagi Page 6

You might also like