Posts

Showing posts from September, 2017

INLAB-7

INLAB-7 Q. 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 INPUT: First line contains the number of books in the library, n Next n*5 lines contain...

COPY FOR SKILLRACK IN MOZILLA

CLICK THIS WEBSITE FOR COPYING AND PASTING: clkmein.com/q7BHGG

COPY FOR SKILLRACK IN GOOGLE CHROME

CLICK THIS WEBSITE FOR COPYING AND PASTING: http://clkmein.com/q7BGAi

INLAB 6

IN-LAB 6 Q.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. Write a function to check whether two numbers are sum-equivalent or not. If none of the numbers are sum-equivalent then print ‘No sum-equivalent’. Input Format First line contains the number of elements, n Next ‘n’ line contains the numbers Output Format Print first number in the first line Next few lines contain the numbers that are sum-equivalent to first number. If the none of the numbers are sum-equivalent , then Print “No sum-equivalent” Input: the number of elements ...

Practice Problem 6-Elizabeth's Trip

Practice Problem 6-Elizabeth's Trip Elizabeth visits her friend Andrew and then returns home by the same route. She always walks 2 kilometers per hour (km/h) when walking uphill, 6 km/h when walking downhill, and 4 km/h when walking on level ground. Suppose the path from Elizabeth's home to Andrew's home consists of 'x' meter in the level ground, 'y' meter in the uphill, 'z' meter in the  downhill and Elizabeth starts from home by  6 a.m. Write an algorithm and the subsequent Python code to determine when Elizabeth will reach Andrew's home and when she will reach her home back if she spends 'm1' minutes in Andrew's home. For example, if x is 1000, 'y' is 500, 'z' is 300  and m1 is '30' minutes, then Elizabeth takes 30 min to reach Andrew's home so she will reach Andrew's home by 6 hour 30 min. Elizabeth will take 26 min to walk from Andrew's home to her home and time when will reach her home ba...

Practice Problem 6-Pangram

Practice Problem 6-Pangram Pangrams are words or sentences containing every letter of the English alphabet at least once. Write an algorithm and a subsequent Python code to check whether a string is a pangram or not. Write a function to check if a given string is pangram. For example, “The quick brown fox jumps over the lazy dog” is a panagram. Input format First line contains the string to be checked Output Format Print Pangram or Not pangram Input: the string Processing: def Pangram(s):     s = ''.join(s.split())     s = s.lower()     if len(set(s))>= 26:         print('Pangram')     else:         print('Not pangram') Output: Display if the number is a Pangram or not Program: def Pangram(s):     s = ''.join(s.split())     s = s.lower()     if len(set(s))>=26:         print('Pangram')     else:     ...

Practice Problem 6-Heterosquare

Practice Problem 6-Heterosquare Heterosquare numbers are the numbers having “n” digits such that the  last n digits of the square of the number will not be the number itself. .Write an algorithm and the subsequent Python code to check if the given number is a Heterosquare number. Write a function to find the square of a given number. For example, 22 is a 2 digit heterosquare number with a square of 484 and 111 with its  square  12321, is a 3 digit heterosquare number. Input Format First line contains the number to be checked Output Format Print Heterosquare  or Not Heterosquare Input: The number Processing Involved: def heterosquare(n):     length = len(str(n))     if n != int(str(n**2)[-length:]):         print('Heterosquare')     else:         print('Not Heterosquare') Output: Display whether the number is heterosquare or not Program: def heterosquare(n):     length = len(str(n...

Practice Problem 6-Vowgram

Practice Problem 6-Vowgram Q. Vowgrams are words or sentences that has every vowel of  the English alphabet occurring  at least  once. Write an algorithm and  a subsequent Python code to check whether a string is a vowgram or not. Write a function to check if a given string is a vowgram. For example, "The quick brown fox jumps over the lazy dog" is a vowgram . Input: the string Processing: def vowgram(s):     s = s.lower()     s = ''.join(s.split())     if set(s) > set('aeiou'):         print('Vowgram')     else:         print('Not vowgram') Output: display whether string is a vowgram or not Program def vowgram(s):     s = ''.join(s.split())     s = s.lower()     if set(s) > set('aeiou'):         print('Vowgram')     else:         print('Not vowgram') s= input() vowgram(s) Algorithm: Ste...

Practice Problem 6-Elizabeth's exercise

Practice Problem 6-Elizabeth's exercise Elizabeth visits her friend Andrew and then returns home by the same route. She always walks 4 kilometers per hour (km/h) when walking uphill, 8 km/h when walking downhill, and  6 km/h when walking on level ground. Suppose the path from Elizabeth’s home to Andrew’s home consists of ‘x’ meter in the level ground, ‘y’ meter in the uphill, ‘z’ meter in the  downhill and Elizabeth starts from home by 6 a.m. Write an algorithm and the subsequent Python code to determine when Elizabeth will reach Andrew’s home and when she will reach her home back if she spends ‘m1’ minutes in Andrew’s home. For example, if x is 1000, ‘y’ is 500, ‘z’ is 300  and m1 is ’30’ minutes, then Elizabeth takes 38 min to reach Andrew’s home so she will reach Andrew’s home by 6 hour 21 min. Elizabeth will take 19 min to walk from Andrew’s home to her home and time when will reach her home back is 7 hour 10 min. The hour can be expressed in 12-hour form...

Practice Problem 6-Heterocube

Practice Problem 6-Heterocube Q.Heterocube numbers are numbers having "n" digits such that the  last n digits of the cube  of the number will not  be the number itself. Write an algorithm and the subsequent Python code to check if the given number is heterocube.  Write a function to find the cube of a given number. For example, 22  is a 2 digit heterocube number with a cube  of 10648 and 111  with its  cube  1367631, is a 3 digit heterocube number. Input Format First line contains the number to be checked Output Format Print Heterocube or Not heterocube Input: The number Processing Involved: def heterocube(n):     temp = ''     length = len(str(n))     cube = n**3     if int(str(cube)[-length:]) == n:         print('Not heterocube')     else:         print('H...

Practice Problem 6-Non-Isomorphic Numbers

Practice Problem 6-Non-Isomorphic Numbers Non-Isomorphic Numbers Q.Given ‘n’ integers, write an algorithm and the subsequent Python code to print all numbers that are Non-isomorphic to the first number. Two numbers with non-distinct digits ( numbers in which digits are repeated)  are said to be non-isomorphic if they have the same number of digits in it and the sets of positions  having the same  digits are different. For example: 12321 is not non-isomorphic to 83538 . Both the  numbers are of length five.  In 12321, positions 2 and 4 have the same digit 2, Positions 1 and 5 have same digit 1. Hence the set of positions having the same digit are {{1,5},{2,4}}. Similarly , for the number 83538, the set of positions having the same digit is {{1,5}, {2,4}}. Since the sets of positions having the same digit are same , the numbers are not non-isomorphic 1232 is non-isomorphic to 2342 because set of positions having same digits for 1232 is {{2, ...