Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
COMPUTER ENGINEERING
PYTHON PROGRAMMING
SUBJECT CODE: 2180711
B.E. 8th SEMESTER
Rationale: Python is a modern language useful for writing compact codes specifically for programming in
the area of Server side Web development, Data Analytics, AI and scientific computing as well as
production tools and game programming. This course covers the basics and advanced Python programming
to harness its potential for modern computing requirements.
Content:
Reference Books:
1. John V Guttag. “Introduction to Computation and Programming Using Python”, Prentice Hall of
India
2. R. Nageswara Rao, “Core Python Programming”, dreamtech
3. Wesley J. Chun. “Core Python Programming - Second Edition”, Prentice Hall
4. Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser, “Data Structures and Algorithms
in Pyhon”, Wiley
5. Kenneth A. Lambert, “Fundamentals of Python – First Programs”, CENGAGE Publication
6. Luke Sneeringer, “Professional Python”, Wrox
7. “Hacking Secret Ciphers with Python”, Al Sweigart, URL-
https://inventwithpython.com/hacking/chapters
Course Outcome:
To develop proficiency in creating based applications using the Python Programming Language.
To be able to understand the various data structures available in Python programming language and
apply them in solving computational problems.
To be able to do testing and debugging of code written in Python.
To be able to draw various kinds of plots using PyLab.
To be able to do text filtering with regular expressions in Python
To be able to create socket applications in Python
To be able to create GUI applications in Python
Following guideline is to be kept in mind while framing the list:
Major Equipments:
Turtle - https://docs.python.org/2/library/turtle.html
PyLab - https://scipy.github.io/old-wiki/pages/PyLab
1. Write a python program to write a function that returns the result of sum of two numbers.
2. Write a python program to display prime number series within a given range using
function.
3. Write a python program to generate Fibonacci number series using function.
4. Write a python program to calculate the sine value of a given angle in degrees by
evaluating sine series.
5. Write a python program to calculate the cosine value of a given angle in degrees by
evaluating cosine series.
6. Write a python program to evaluate exponential series.
7. Write a python program to find factorial of a given number using recursive function.
8. Write a python program to solve the problem of tower of Hanoi using recursive function.
9. Write a python program to find maximum of two numbers using lambda function.
10. Write a python program to find products of elements of two different listusing lambda
function.
11. Write a python program to find factorial using lambda function.
12. Write a python program that uses the functions of employee module and calculate the
gross salaries and net salaries of an employee.
Subject I/C
Laxmi Institute of Technology, Sarigam
Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad
2. Write a python program to search a specific value from a given list of values using binary
search method.
3. Write a Python program that counts the number of occurrences of the character in the given
string. Provide two implementations: recursive and iterative.
5. What is Method Resolution Order (MRO)? Explain the principles followed by MRO with
example.
7. Explain the types of methods available in python with a suitable example of each method.
8. What are the differences between abstract class and interface? Write a python program in
which Maruti and Santro sub classes implement the abstract methods of the super class Car.
9. Create a class student with following member attributes: roll no, name, age and 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.
10. Create following regular polygons (regular means all sides the same lengths, all angles the
same) using for loop in turtle
• An equilateral triangle
• A square
• A hexagon
• An octagon
11. What is list in Python? Demonstrate use of any three methods of list.
13. Write a Python program to check whether the given no is Armstrong or not using user
defined function.
14. How map can be used in Python program? Explain with a suitable example
15. Give the syntax and significance of string functions: title() and capitalize().
18. How filter can be used in Python program? Explain with a suitable example.
19. Create a class Employee with data members: name, department and salary. Create suitable
methods for reading and printing employee information.
23. Read a text file in Python and print no. of lines and no. of unique words.
26. Write a python program to retrieve name and date of birth (mm-dd-yyyy) of students from a
given file student.txt.
27. Write a python program to retrieve strings starting with m and having 5 characters.
28. Write a python program to append data to an existing file 'python.py'. Read data to be
appended from the user. Then display the contents of entire file.
29. Write a python program to know the current working directory and to 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?
Subject I/C
Laxmi Institute of Technology, Sarigam
Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad
5. Write a python program to search a specific value from a given list of values using binary
search method.
6. Write a Python program that counts the number of occurrences of the character in the given
string. Provide two implementations: recursive and iterative.
8. What is Method Resolution Order (MRO)? Explain the principles followed by MRO with
example.
10. Explain the types of methods available in python with a suitable example of each method.
11. What are the differences between abstract class and interface? Write a python program in
which Maruti and Santro sub classes implement the abstract methods of the super class Car.
12. Create a class student with following member attributes: roll no, name, age and 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.
13. Create following regular polygons (regular means all sides the same lengths, all angles the
same) using for loop in turtle
• An equilateral triangle
• A square
• A hexagon
• An octagon
16. What is list in Python? Demonstrate use of any three methods of list.
18. Give the syntax and significance of raw_input() and input() methods.
19. Write a Python program to check whether the given no is Armstrong or not using user
defined function.
20. How map can be used in Python program? Explain with a suitable example
21. Give the syntax and significance of string functions: title() and capitalize().
24. How filter can be used in Python program? Explain with a suitable example.
25. Create a class Employee with data members: name, department and salary. Create suitable
methods for reading and printing employee information.
29. Read a text file in Python and print no. of lines and no. of unique words.
33. Explain steps to create widgets. Write Python program to display a label on clicking a push
button.
34. Explain the function which is used to retrieve the parts of URL.
35. Write Python GUI program to create two push buttons using Tkinter. Background color of a
frame should be changed when different buttons are clicked.
38. Write a Python GUI program to create three push buttons using Tkinter. The background
color of frame should be different when different buttons are clicked.
39. Explain the creation of different types of containers available in Tkinter? Elaborate the
explanation with suitable example.
40. Which are the different ways of creation of threads? Explain each with an example.
41. Write a python program to retrieve name and date of birth (mm-dd-yyyy) of students from a
given file student.txt.
42. Write a python program to retrieve strings starting with m and having 5 characters.
43. Write a python program to append data to an existing file 'python.py'. Read data to be
appended from the user. Then display the contents of entire file.
44. Write a python program to know the current working directory and to 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?
Subject I/C
Laxmi Institute of Technology, Sarigam
Approved by AICTE, New Delhi;
Affiliated to Gujarat Technological University, Ahmedabad
Academic Year 2018-19
Centre Code: 086 Examination : Mid Sem-I
Branch: CSE Semester: 8
Sub: Python Programming Date:28/01/2019 Marks: 20
Sub Code: 2180711 Time: 9 AM to 10 AM
Q.2 (a) What is the difference between = = and is operator in Python? [2]
(b) Explain built-in datatypes of python. [3]
(c) Justify: “Functions are perfect objects.” [5]
OR
Q.2 (a) Explain in operator in Python with an example. [2]
(b) t = (1, 2, 3, (4, ), [ 5, 6] ) [3]
print(t[3])
t[4][0] = 7
print(t)
(c) Explain parameter passing method in python. [5]
Seat No.: ________ Enrolment No.___________
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.
*************
2
Seat No.: ________ Enrolment No.___________
*************
1
Seat No.: ________ Enrolment No.___________
GUJARAT TECHNOLOGICAL UNIVERSITY
BE - SEMESTER–VIII (NEW) - EXAMINATION – SUMMER 2018
Subject Code: 2180711 Date: 07/05/2018
Subject Name: Python Programming(Departmental Elective - III)
Time: 10:30 AM to 01:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
Q.1 (a) Give syntax of the methods which can be used to take input from the user in 03
python program.
(b) Give the syntax and significance of string functions: title() and strip(). 04
(c) Write a Python program which will throw exception if the value entered by 07
user is less than zero.
Q.2 (a) How to comment specific line(s) in Python program? 03
(b) How append() and extend() are different with reference to list in Python? 04
(c) Write a Python program to find reverse of given number using user defined 07
function.
OR
(c) Write a Python program to search a specific value from a given list of values 07
using binary search method.
Q.3 (a) What is the difference between = = and is operator in Python? 03
(b) Give the output of following Python code: 04
myStr = ‘GTU is the best University’
print myStr [15 : : 1]
print myStr [-10 : -1 : 2]
(c) Write a Python program which will return the sum of the numbers in the array, 07
returning 0 for an empty array. Except the number 13 is very unlucky, so it
does not count and number that come immediately after 13 also do not count.
Example : [1, 2, 3, 4] = 10
[1, 2, 3, 4, 13] = 10
[13, 1, 2, 3, 13] = 5
OR
Q.3 (a) Briefly describe the methods of regular expression. 03
(b) Give the output of following Python code: 04
t = (1, 2, 3, (4, ), [ 5, 6] )
print t[ 3 ]
t[4][0] = 7
print t
(c) Write a Python program which takes a list and returns a list with the elements 07
"shifted left by one position" so [1, 2, 3] yields [2, 3, 1].
Example: [1, 2, 3] → [2, 3, 1]
[11, 12, 13] → [12, 13, 11]
Q.4 (a) Explain sort() with an example. 03
(b) How operator overloading can be implemented in Python? Give an example. 04
(c) Create a Python program to read a text file and do following: 07
1. Print no. of lines
2. Print no. of unique words
3. Store each word with its occurrence in dictionary
1
OR
Q.4 (a) How sorted() can be used with list in Python? Give an example. 03
(b) Differentiate between filter and map in Python using example. 04
(c) Write a Python program to implement the concept of echo server. 07
Q.5 (a) Explain in operator in Python with an example. 03
(b) Write a Python program to read a text file and do following: 04
1. Print no. of words
2. Print no. statements
(c) Write a Python program to create class GTU with attributes like class variable 07
cnt, instance variables x and y, instance methods get_value and print_value.
OR
Q.5 (a) Write a python program to implement any one classical cipher. 03
(b) Explain steps to create widgets. Write Python program to display a label on 04
clicking a push button.
(c) Write Python GUI program to create three push buttons using Tkinter. Background 07
color of a frame should be changed when different buttons are clicked.
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) Explain lambda in Python with example 03
(b) Explain Method Overloading in Python 04
(c) Write a Python program to count words, characters and spaces 07
from text file
Q.2 (a) Explain List in Python 03
(b) Explain raw_input() and input() in Python 04
(c) Explain Tuples in Python with example 07
OR
(c) Explain Dictionary in Python with example 07
Q.3 (a) Explain title() and capitalize() methods 03
(b) Write a Python program to search a specific value from a given 04
list of values using linear search method
(c) Give Difference between abstract class and interface in Python 07
using an example
OR
Q.3 (a) Explain Exception Handling in Python 03
(b) Write a Python Program to multiply two matrices 04
(c) Develop chat application using Multithreading in Python 07
Q.4 (a) Explain namespaces in Python 03
(b) Write a Python program to remove the first occurrence of a 04
specified element from an array
(c) Explain encryption and decryption in Python using an example 07
OR
Q.4 (a) Write a Python program to generate the fibonacci series using 03
recursion
(b) Explain steps to create widgets in Python 04
(c) Write a Python program to match a string that contains only 07
upper and lowercase letters, numbers, and underscores using
Regular Expression
Q.5 (a) Explain Tkinter Widgets: Menu and Menubutton 03
(b) Explain map ,reduce and filter in Python 04
(c) Write a Python program to find the substrings within a string 07
using Regular Expression
OR
Q.5 (a) Explain Tkinter Widgets: button and radiobutton 03
(b) Explain pack()and place() method of Tkinter 04
(c) Draw Circle and Triangle shapes using Turtle and fill them with 07
red color