NOTE!
Click on MENU to Browse between Subjects...17CS664 - PYTHON APPLICATION PROGRAMMING
Answer Script for Module 3
Solved Previous Year Question Paper
CBCS SCHEME
PYTHON APPLICATION PROGRAMMING
[As per Choice Based Credit System (CBCS) scheme]
(Effective from the academic year 2017 - 2018)
SEMESTER - VI
Subject Code 17CS664
IA Marks 40
Number of Lecture Hours/Week 3
Exam Marks 60
These Questions are being framed for helping the students in the "FINAL Exams" Only
(Remember for Internals the Question Paper is set by your respective teachers).
Questions may be repeated, just to show students how VTU can frame Questions.
- ADMIN
ANSWER :

Fig 11.1 Program to validate the Password Entered

Fig 11.2 Output of Program to validate the Password Entered
ANSWER :
12.1 There are Four ways in converting a Dictionary into a Tuple &
are as follows:
12.1.1 Using list comprehension
Refer Fig 12.1
12.1.2 Using items()
Refer Fig 12.1
12.1.3 Using zip
Refer Fig 12.1
12.1.4 Using iteration
Refer Fig 12.1

Fig 12.1
Various Methods to convert a Dictionary into Tuple

Fig 12.2
Output of various Methods to convert a Dictionary into Tuple
ANSWER :
Because tuples are hashable and lists are not, if we want to create a composite key to use in a dictionary we must use a tuple as the key.
We would encounter a composite key if we wanted to create a telephone directory that maps from last-name, first-name pairs to telephone numbers. Assuming that we have defined the variables last, first, and number, we could write a dictionary assignment statement as follows:
directory[last,first] = number
The expression in brackets is a tuple. We could use tuple assignment in a for loop to traverse this dictionary.
for last, first in directory:
print(first, last, directory[last,first])
This loop traverses the keys in directory, which are tuples. It assigns the elements of each tuple to last and first, then prints the name and corresponding telephone number.
ANSWER :
13.1 List Operations:
Python allows to use operators + and * on lists.
The operator + uses two list objects and returns concatenation of those two lists. Whereas * operator take one list object and one integer value, say n, and returns a list by repeating itself for n times.

Fig 13.1 List Operations

Fig 13.2 Output of List Operations
13.2 List Methods:
|
|
|
Adds an element at the end of the list |
|
Removes all the elements from the list |
|
Returns a copy of the list |
|
Returns the number of elements with the specified value |
|
Add the elements of a list (or any iterable), to the end of the current list |
|
Returns the index of the first element with the specified value |
|
Adds an element at the specified position |
|
Removes the element at the specified position |
|
Removes the first item with the specified value |
|
Reverses the order of the list |
|
Sorts the list |
13.2.1 Demonstration of these Methods:

Fig 13.3 Use of various list Methods

Fig 13.4 Output of Use of various list Methods
13.3 Program to accept 'n' numbers from user, find sum all even numbers
and product of all odd numbers in entered list :

Fig 13.5 Program to sum even number & product odd Number

Fig 13.6 Output of Program to sum even number & product odd Number

Fig 13.7 Output of Program to sum even number & product odd Number
ANSWER :
14.1 Merits of Dictionary over lists:
Refer 4th
Question & Answer or Click Here
14.2 Program to accept USN and marks obtained, find maximum, minimum
and students USN who have scored in the range 100-85, 85-75, 75-60 and
below 60 marks separately.

Fig14.1 Program to Evaluate Students Marks

Fig14.2 Output of Program to Evaluate Students Marks
Below Page NAVIGATION Links are Provided...
All the Questions on Question Bank Is SOLVED