Denominations - 3
Write a program to find the minimum number of notes required for the amount M. Available note denominations are 500, 50, 10, 1.
Input
The first line is a single integer M.
Output
Print M in denominaitons.
Explanation
Given
M = 1543, it can be written as1543 = 3*(500) + 3*(50) + 0*(10) + 1*(3)Then the output should be
500: 3 50: 0 10: 4 1: 3
Sample Input 1
1543
Sample Output 1
500: 3 50: 0 10: 4 1: 3
Sample Input 2
1259
Sample Output 2
500: 2 50: 5 10: 0 1: 9
Day Name - 2
Given the weekday of the first day of the month, determine the day of the week of the given date in that month.
The first line is a string D. The second line is an integer N.
Output
The output should be a string.
In the given example,
D = Monday. As the 1st of the day of the month is a Monday, it means the 7th and 14th of the month will be Sundays (A week has 7 days). So the 16th day (N = 16) of the month will be a Tuesday.
So, the output should be
Tuesday.
Sample Input 1
Monday
16
Sample Output 1
Tuesday
Sample Input 2
Tuesday
17
Sample Output 2
Thursday
3-digit Armstrong Number
Write a program to check if a given 3-digit number X is an Armstrong number or not.
Note: A number is an Armstrong number if the number is equal to the sum of the Nth power of its digits.
Input
The first line is an integer X.
Output
The output should be a single line containing True if it satisfies the given conditions, False in all other cases.
Explanation
In the given example
X = 371, The number of digits in 371 is 3. So, 33 + 73 + 13 = 371. Hence,
371 is an Armstrong number.
So, the output should be
True.
Sample Input 1
371
Sample Output 1
True
Sample Input 2
351
Sample Output 2
False
Compute Hypotenuse
Write a program to find the hypotenuse H of a right-angled triangle of sides A and B.
Note: Pythagoras theorem states that, for a right-angled triangle. Hypotenuse2 = A2 + B2Input
The first line is an integer, A. The second line is an integer, B.
Output
The output should be an integer.
In the given example, the first side
A = 3, and the second side B = 4. To calculate the hypotenuse we use Pythagoras theorem.
According to Pythagoras theorem, hypotenuse2 = 32 + 42
Therefore, the hypotenuse value is
5. So, the output should be 5.
Sample Input 1
3
4
Sample Output 1
5
Sample Input 2
12
5
Sample Output 2
13
Uncommon Number
Given a number N, find whether the number is common or uncommon. A number is considered uncommon if it is not divisible by any of the single-digit primes.
Input
The first line of input is an integer N.
Output
The output should be a single line containing True if it satisfies the given conditions, False in all other cases.
Explanation
In the given example,
N = 5633 the number is not divisible by 2, 3, 5, 7. So, the number is an uncommon number.
Therefore, the output should be
True.
Sample Input 1
5633
Sample Output 1
True
Sample Input 2
1000
Sample Output 2
False
Write a Python code of a program that reads a candidate’s ielts score and prints out the corresponding CEFR level for that band score. The score ranges and corresponding CEFR level are shown in the table below.
(Hint: This problem can be solved in two ways: top-down and bottom-up.)
Example 1:
Sample Input:
IELTS Score: 6
Sample Output:
CEFR Level: B2
Write a python program that takes the weight of luggage from the user and prints the total amount the user needs to pay according to the given conditions:
Women Population
In a town, the percentage of men is 52 and the rest are women(W). The total population(T) of town is given as input. Write a program to print the total number of women in the town.
Input
The first line of input is an integer T.
Output
The output should be an integer representing the total number of women in the town.
Given total population
80000. Then the number of women should be 80000 x 48 / 100 = 38400 So the output is 38400.
Sample Input 1
80000
Sample Output 1
38400
Sample Input 2
100000
Sample Output 2
48000
First & Last Digits
Given a four-digit number N as input. Write a program to print first and last digit of the number.
Input
The input is a four-digit number N.
Output
Print the first digit in the first line and the last digit in the second line.
Sample Input 1
1456
Sample Output 1
1
6
Sample Input 2
9821
Sample Output 2
9
1
Number Diamond
Given an integer N as input,
write a program to print a number diamond of 2*N -1 rows as shown below.
Note: There is a space after each number.
In the given example, the number of rows in the diamond is 5
So, the output should be
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Your code:
N = int(input())
rows = []
for number in range(1, N + 1):
rows.append(' '.join([str(x) for x in range(1, number + 1)]))
for number in rows[::-1][1::]:
rows.append(number)
diamond = '\n'.join([x.center(2* N - 1) for x in rows])
print(diamond)
the above code works fine but only 7/10 test cases are passed
for input 15 the output is not the same as expected
Refer to the document in the link below
https://docs.google.com/document/d/1Un_RPlLjEqNbbkJDegaqVkYLedITyQdXRKugY24hJWk/edit?usp=sharing