Hits: 7 (Python Example for Citizen Data Scientist & Business Analyst) Write a python program to find heights of the top three building in descending order from eight given buildings. Input: 0 ≤ height of building (integer) ≤ 10,000 Sample Solution: Python Code: print(“Input the heights of eight buildings:”) l = [int(input()) for …

# Day: February 23, 2021

Hits: 13 (Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to reverse the digits of a given number and add it to the original, If the sum is not a palindrome repeat this procedure. Sample Solution: Python Code: def rev_number(n): s = 0 while True: k = str(n) …

Hits: 10 (Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to find common divisors between two numbers in a given pair. Sample Solution: Python Code: def ngcd(x, y): i=1 while(i<=x and i<=y): if(x%i==0 and y%i == 0): gcd=i; i+=1 return gcd; def num_comm_div(x, y): n = ngcd(x, y) …

Hits: 7 (Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to print the length of the series and the series from the given 3rd term, 3rd last term and the sum of a series. Sample Data: Input third term of the series: 3 Input 3rd last term: 3 Sum …

## Python Example – Write a Python program to find the digits which are absent in a given mobile number

Hits: 8 (Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to find the digits which are absent in a given mobile number. Sample Solution: Python Code: def absent_digits(n): all_nums = set([0,1,2,3,4,5,6,7,8,9]) n = set([int(i) for i in n]) n = n.symmetric_difference(all_nums) n = sorted(n) return n print(absent_digits([9,8,3,2,2,0,9,7,6,3])) Sample …

Hits: 11 (Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to find the number of divisors of a given integer is even or odd. Sample Solution: Python Code: def divisor(n): for i in range(n): x = len([i for i in range(1,n+1) if not n % i]) return x …

Hits: 4 (Python Example for Citizen Data Scientist & Business Analyst) Write a Python program that accept a positive number and subtract from this number the sum of its digits and so on. Continues this operation until the number is positive. Sample Solution: Python Code: def repeat_times(n): s = 0 n_str = str(n) …

Hits: 7 (Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to find the median among three given numbers. Sample Solution: Python Code: x = input(“Input the first number”) y = input(“Input the second number”) z = input(“Input the third number”) print(“Median of the above three numbers -“) if …

Hits: 5 (Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to get the third side of right angled triangle from two given sides. Note: Use bitwise operations to add two numbers. Sample Solution: Python Code: def pythagoras(opposite_side,adjacent_side,hypotenuse): if opposite_side == str(“x”): return (“Opposite = ” + str(((hypotenuse**2) – …