TCS CodeVita July 2019
Programming test (Python)
1. Suppose on dd-mm-yyyy an eclipse occurred. Now, we are interested to calculate the date when next eclipse occurs. (Didn’t solve)
Input: The date in format dd-mm-yyyy Output: Desired date in yyyy-mm-dd format Constraints: It is guaranteed that given date is valid. 01 <= dd <= 31 01 <= mm <= 12 1900 <= yy <= 2100
I felt some details were missing here.
2. Given the amount invested, final amount got in return and the period of investment, found out the simple rate of return and annualized return for this investment.
Input: 1st line contains amount invested. 2nd line contains amount returned. 3rd line contains period of investment. Output: 1st line contains simple rate of return. 2nd line contains annualized return. Output must be rounded off to up to 2 decimal places.
Sample input: 10000 20000 5 Sample output: 20.00 14.87
3. Sam is interested in markets and investments. He often buys new stock and sell the non-profiting once. In order to do the same, he takes help for a broker who charges Sam certain amount. Find out how much does Sam pay the broker for given transactions. (Unsolved – some test cases failing)
Input: 1st line contains no. of stocks Sam deals with (N). 2nd line contains constant brokerage rate that the broker takes from Sam for every transaction (B). The next lines will have stock details in the form: Volume or numbers of a stock, stock name, unit price of stock, bought/sold (B/S). Output: Total amount Sam pays to the broker. The output will be upto 2 decimal places and the value will be rounded off to DOWN.
Sample input: 2 0.5 1 S1 100 B 2 S2 110 S Sample output: 1.05