Gujarat Technological University
Gujarat Technological University
___________
Q.1 (a) 1. Write a python program to know the current working directory and to 03
print all contents of the current directory. What changes we need to
make in the program if we wish to display the contents of only 'mysub'
directory available in current directory?
2. Write a python program to append data to an existing file 'python.py'. 04
Read data to be appended from the user. Then display the contents of
entire file.
(b) 1. Write a python program to retrieve strings starting with m and having 5 03
characters.
2. Write a python program to retrieve name and date of birth (mm-dd- 04
yyyy) of students from a given file student.txt.
Q.2 (a) 1. Explain the function that is used to retrieve the parts of URL. 02
2. Write a python program to create a TCP/IP client-server chat 05
application.
(b) What are the differences between C and Python? 07
OR
(b) 1. What is lambda function in python? Explain with any one example. 03
2. Explain built-in datatypes of python. 04
Q.3 (a) 1. Briefly describe the methods of regular expression. 02
2. Write a Python program that counts the number of occurrences of the 05
character in the given string. Provide two implementations: recursive
and iterative.
(b) Write a python program to search a specific value from a given list of values 07
using binary search method.
OR
Q.3 (a) 1. What is duck typing philosophy of python? 02
2. What is Method Resolution Order (MRO)? Explain the principles 05
followed by MRO with example.
(b) Write a python program to arrange the characters of a given string 'welcome' in 07
an alphabetical order using insertion sort algorithm.
Q.4 (a) Explain the types of methods available in python with a suitable example of 07
each method.
(b) Which are the different ways of creation of threads? Explain each with an 07
example.
OR
Q.4 (a) What are the differences between abstract class and interface? Write a python 07
program in which Maruti and Santro sub classes implement the abstract
methods of the super class Car.
1
(b) Create a class student with following member attributes: roll no, name, age and 07
total marks. Create suitable methods for reading and printing member variables.
Write a python program to overload ‘==’ operator to print the details of students
having same marks.
Q.5 (a) Explain the creation of different types of containers available in Tkinter? 07
Elaborate the explanation with suitable example.
(b) Create following regular polygons (regular means all sides the same lengths, all 07
angles the same) using for loop in turtle
An equilateral triangle
A square
A hexagon
An octagon
OR
Q.5 (a) Explain the major steps used to create widgets. Write a python program to 07
display a label upon clicking a push button.
(b) Write a Python GUI program to create three push buttons using Tkinter. The 07
background color of frame should be different when different buttons are
clicked.
*************