Future Vision BIE Future Vision BIE


ONE STOP FOR ALL STUDY MATERIALS & LAB PROGRAMS


E MENU Whatsapp Share Join Telegram, to get Instant Updates
×

NOTE!

Click on MENU to Browse between Subjects...

Advertisement

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




Advertisement

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




× CLICK ON THE QUESTIONS TO VIEW ANSWER

ANSWER :

Program to validate the Password Entered

Fig 11.1 Program to validate the Password Entered


Output of Program to validate the Password Entered

Fig 11.2 Output of Program to validate the Password Entered




Advertisement

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

Various Methods to convert a Dictionary into Tuple

Fig 12.1

Various Methods to convert a Dictionary into Tuple

Output of 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.



Advertisement

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.

List Operations

Fig 13.1 List Operations

Output of List Operations

Fig 13.2 Output of List Operations

13.2 List Methods:

Method

Description

append()

Adds an element at the end of the list

clear()

Removes all the elements from the list

copy()

Returns a copy of the list

count()

Returns the number of elements with the specified value

extend()

Add the elements of a list (or any iterable), to the end of the current list

index()

Returns the index of the first element with the specified value

insert()

Adds an element at the specified position

pop()

Removes the element at the specified position

remove()

Removes the first item with the specified value

reverse()

Reverses the order of the list

sort()

Sorts the list

13.2.1 Demonstration of these Methods:

Use of various list Methods

Fig 13.3 Use of various list Methods

Output of 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 :

Program to sum even number & product odd Number

Fig 13.5 Program to sum even number & product odd Number

Output of Program to sum even number & product odd Number

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

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.

Program to Evaluate Students Marks

Fig14.1 Program to Evaluate Students Marks

Output of Program to Evaluate Students Marks

Fig14.2 Output of Program to Evaluate Students Marks


× NOTE: Each Page Provides only 5 Questions & Answer
Below Page NAVIGATION Links are Provided...
All the Questions on Question Bank Is SOLVED

Advertisement

lIKE OUR CONTENT SUPPORT US BY FOLLOWING US ON INSTAGRAM : @futurevisionbie

For immediate Notification Join the Telegram Channel



× SUGGESTION: SHARE WITH ALL THE STUDENTS AND FRIENDS -ADMIN