BONUS PRACTICE PROBLEM

Question 1 Kangaroo word

Kangaroo refers to a word carrying another word within it but without transposing any letters. Example: encourage contains courage, cog, cur, urge, core, cure, nag, rag, age, nor, rage and enrage but not run, gen, gone etc. Given two strings, design an algorithm/ flowchart and a Python function to determine if the first string is a Kangaroo word of second.

Input Format: Continue reading

Practice Problem Set 8

Question 1 (Identify machines in same local networks)

Numeric addresses for computers on the international network Internet are composed of four parts, separated by periods, of the form   xx.yy.zz.mm    where  xx ,  yy ,  zz , and  mm  are positive integers. Locally, computers are also known by a nicknames.

Continue reading

In-lab 7

In a small village library, books are lended to the members for a period of one week. Details such as name of the book, author, date of purchase, accession number and availability status are stored for each book. Given the details of the ‘n’ books sorted by the accession number of book and an accession number to search, develop an algorithm and write the Python code to perform binary search in the given data. Print ‘Found’ or ‘Not Found’ appropriately.

Input Format

First line contains the number of books in the library, n

Next n*5 lines contains the details of the book in the following order:

name of the book

author of the book

date of purchase of the book

accession number of the book

availability status of the book

Next line contains the accession number of book to be searched ‘n’

Output Format

Print Found or Not Found

CODE 1 (Correct code Incorrect way):

n=int(input())
l=[]
for i in range(n*5):
    print(i)
    if(i%5 != 3):
        a=input()
    else:
        l.append(int(input()))
a=int(input())
if a in l:
    print('Found')
else:
    print('Not Found')

Inlab 6

CSE1701 Sum-equivalent numbers (Id-3106)

Given ‘n’ integers, write an algorithm and the subsequent Python code to print all numbers that are sum-equivalent to the first number. Two numbers ‘m’ and ‘n’ are said to be sum-equivalent if ‘m’ and ‘n’ have the same number of digits and the sum of the digits in ‘m’ and ‘n’ are equal. 12381 is sum-equivalent to 10545. Here both the numbers are five digit numbers. Sum of the digits in 12381 is 1+2+3+8+1=15. Similarly the sum of the digits in 10545 is 15.

Continue reading

PP-6

Q1 Pengram

Pengrams are words or sentences containing every letter of the English alphabet at the most once. Write an algorithm and a subsequent Python code to check whether a string is a pengram or not. Write a function to check if a given string is a pengram. For example, “He is at work” is a pengram. Since every letter of the english alphabet occurs at the most once

Input format

First line contains the string to be checked

Output Format

Print Pengram or Not pengram

Continue reading

IL-5

Q) Government of India has appointed two separate teams with three members each for investigating a case. After forming the two teams with three members each, as a cost-cutting measure, the government decides to merge the two teams in to a single team with five members, by eliminating the member with the least experience among all the six members from the two teams.  Use dictionaries to store the two teams and form a new team by concatenating the two teams. The chairperson of the new team is the person with the maximum experience. Design an algorithm and write the subsequent Python code to store the members  of the two teams as dictionaries, print the new (concatenated) dictionary with the names in an increasing order of experience, to check whether a given name is present in the new dictionary or not and to print the name of the chairperson of the new team. Continue reading

PP4

Q1 Finding a Friend with Longest Name

Write an algorithm and the subsequent Python program to store the names of your friends, count the number of friends, identify the longest name and the number of letters in the longest name. Get the names of friends till ‘stop’ is entered. For example, if the input sequence is Ravi, Raj, Puela, stop,  then the output is 3, Puela and 5.

When you are coding in the online judge (SkillRack), use rstrip() function to remove carriage return from the input string.

Continue reading

In-lab 4

Q) A team of experts formed by Govt. of India conducted a survey on colleges in India. Let us assume that the survey was conducted in ‘n’ number of institutes. The experts were asked to rank the institutes based on three different metrics. The metrics are facilities, academics and infrastructure. Maximum score in each category is as follows.
Facilities = 25
Academics = 50
Infrastructure = 25

Continue reading