Proper Fractions
Given 2 fractional values A/C. B/D where A, B are numerators and C. D are denominators. You are asked to add two fractional values. If the sum gives proper fraction as output print the proper fraction. If it is improper, convert it into a mixed fraction and print it. If it is a whole number, print it.
Input
The first line of input contains two space-separated strings A/C &B/D
Output
The output should be a string of format p/q if the result is a proper fraction
a b/c if the result is a improper or med fraction
a if the result is a whole number
Discount Sale
It is a Summer Discount sale in Mumbai and all the local shops have put up various offers. Arjun selected N items to buy. While standing in the billing queue, he noticed the offer "Buy two! Get two FREE!!". This means that for every two items he buys, they give him two items for free. However, items can be of varying prices, they always charge for the two most costly items and give the other two as free. For example, if the items cost 1, 1, 2, 2, then you have to pay four rupees and take all four items.
Arjun is confused with grouping his items to reduce the total price ho has to pay. Your task is to find the minimum price Arjun has to pay to buy all the N items.
def calculate_vat(amount):
amount * 1.2
total = calculate_vat(100)
print(total)
When your boss runs the program they get the following output:
None
Your boss expects the program to output the value 120 . What is wrong? How do you fix it?
Display sets of "*" based on the user's integer input (0-9).
Example:
Enter a number: 6
******
Fibonacci sequence
given a list of M numbers and a positive integer N, print the sum of numbers whose position in the list is divisible by N. consider that the positions of numbers range from 1 to N.
Explanation : Given N = 1, M= 7 and the numbers_list = [4, 8, 6, 6, 7, 9,3]
as every position is divisible by 1, 4+8+6+6+7+9+3=43
so, output is 43
Input : 1 7
4 8 6 6 7 9 3
Output : 43
Input : 4 13
7 3 10 4 5 8 4 9 6 9 10 1 4
Output : 14
Nicholas is trying to invent a light bulb. he has to discover the right gaseous mixture that can be used to fill the bulb so that the bulb works underwater. He has prepared N gaseous mixture numbered from 0 to n-1 to check . Nicholas does not know which this gases will work, but to use a modulo-based search algorithm to keep checking different gas mixtures. So 1st chooses an integer K and select all indices i in increasing order such that i mod k= 0 (i%K==0) and tests the gases on such indices, then all indices in increasing order such that i mod k=1 and test the gases on such indices and so on.
Input:Test cases
test case contains N, P and K
output:no.of days taken
N=10 P=6 K=5
On the day1,Nicholas Will test gas numbered 0 as 0 mod 5=0,
On the day2, Nicholas Will test gas numbered 5 as 5 mod 5=0,
On the day3, Nicholas Will test gas numbered 1 as 1 mod 5=1,
On the day4, Nicholas Will test gas numbered 6 as 6 mod 5=1,
Nicolas test the gas number 6 on day 4 so the output is 4
Input:
2
10 6 5
5 2 3
Output:
4
5
Array Manipulation
Hope you can help me!
THANK YOU!!!
snake format
I'm really fond of even numbers, you know? That's why I'll be letting you make another even
number problem yet again. This time, you need to print from a range of two inputted numbers,
n1 and n2 (inclusive), all the even numbers from n2 down to n1, in descending order