Skip to main content

Posts

PPS2

PRACTICE PROBLEMS 2 FALL 18 Q1)  A city has a dam of capacity 'x' litres, water comes to the dam from 'n' places. Given the value of 'n' and the quantity of water (in litres and millilitres) that comes from 'n' places. Write an algorithm and the corresponding Python code to determine the total amount of water in the dam. Assume that the total quantity of water in the dam, will always be less than the capacity of the dam. For example, if there are three places from which water comes to the dam and the water from place 1 is 2 litres 500 ml, water from second place is 3 litres 400 ml and water from third place is 1 litre 700 ml, then the total quantity of water in dam will be 7 litres 600 ml. Code: n=int(input()) lit=0 ml=0 for i in range(n):  lit=lit+int(input())  ml=ml+int(input()) print(lit+(ml//1000)) print(ml%1000) Input: 'n' number of litres and ml of water from each of the 'n' places Processing: for i in range(n):...
Recent posts

VIT SKILLRACK SOLUTIONS

     VIT SKILLRACK SOLUTIONS WITH        PSEUDOCODES PPS 1 FALL 18 Q1)  Design an algorithm and draw a flow chart to check the given number is Armstrong number of three digits or not. A number is said to be Armstrong number if the summation of cube of digits in a three digit number is equal to the number. Check for boundary conditions, if the value entered is outside boundary conditions then enter 'Invalid input'. Code: n=int(input('Enter the three digit number:')) if(len(str(n))==3 and n>=100 and n<=999): while(m): s=s+(m%10)**3 m=m//10 if(s==n): print('Yes') else: print('No') else: print('Invalid') Input: A number 'n' Processing: if(len(str(n))==3 and n>=100 and n<=999): while(m): s=s+(m%10)**3 m=m//10 if(s==n): print('Yes') else: print('No') else: print('Invalid') Output: Print Armstrong or Not armstrong Pseudo Code: STAR...