Posts

Showing posts with the label pps6

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, ...

Practice Problem 6-Autocube numbers

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

Practice Problem 6-Elizabeth's Visit

Practice Problem 6-Elizabeth's Visit Elizabeth’s visit Elizabeth visits her friend Andrew and then returns home by the same route. She always walks 1 kilometer per hour (km/h) when walking uphill, 4 km/h when walking downhill, and  2 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 65 min to reach Andrew's home so she will reach Andrew's home by 7 hour 05  min. Elizabeth will take 56 min to walk from Andrew's home to her home and time...

Practice Problem 6-Adam's Number

Practice Problem 6-Adam's Number Adam Number A number is said to be an Adam number if the reverse of the square of the number is equal to the square of the reverse of the number.  For example, 12 is an Adam number because the reverse of the square of 12 is the reverse of 144, which is 441, and the square of the reverse of 12 is the square of 21, which is also 441.   Write an Algorithm and the subsequent Python code to check whether the given number  is an Adam number or not. Write a function to reverse a number Input Format: The first line will contain the number. Output Format: Print Adam number or Not an Adam number Input: The number n Processing: def reverse(number):     rev_num = ''     temp = number     while temp:         rev_num = rev_num + str(temp%10)         temp = temp//10     rev_num = int(rev_num)     retu...