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.
Input
The first line of input is an integer
N.
Explanation
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
Sample Input 1
5
Sample Output 1
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
Sample Input 2
4
Sample Output 2
1
1 2
1 2 3
1 2 3 4
1 2 3
1 2
1
sample input 3
15
sample output3
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Product of the Given Numbers
Given an integer N, write a program which reads N inputs and prints the product of the given input integers.
Input
The first line of input is a positive integer, N. The next N lines each contain an integer.
Output
The output should be the product of the given input integers.
In the given example,
N = 3 and the input integers are 2, 3, and 7.So, the output should be 2 x 3 x 7 = 42.
Sample Input 1
3
2
3
7
Sample Output 1
42
Sample Input 2
4
11
2
4
9
Sample Output 2
792
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
Denominations - 2
The possible denominations of currency notes are 100, 50, 20 and 10. The amount A to be withdrawn is given as input. Write a program to break the amount into minimum number of bank notes.
Input
The first line of input is an integer A.
Output
The output should be a string representing number of 100, 50, 20, 10 notes possible.
In the given example amount
370, it can be written as370 = 3*(100) + 1*(50) + 1*(20) + 0*(10)Then the output should be
100 Notes: 3
50 Notes: 1
20 Notes: 1
10 Notes: 0
Sample Input 1
370
Sample Output 1
100 Notes: 3
50 Notes: 1
20 Notes: 1
10 Notes: 0
Sample Input 2
130
Sample Output 2
100 Notes: 1
50 Notes: 0
20 Notes: 1
10 Notes: 1
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
Create a program in Python to calculate grade point averages for college students. Grade point averages are calculated by dividing total number of quality points by the total number of earned credit hours. Quality points are grades earned multiplied by the credit hours of a course. A grade of A is worth 4 points, B is 3 points, C is 2 points, D is 1 point and an F is 0 points.
Your program should prompt the student to enter their name, total credit hours earned, and total quality points earned. Calculate the grade point average and display back the student’s name along with their gpa for my example of John Doe.
Hi John Doe. Your grade point average is 3.30.
Sum of the series
Write a program to find the sum
The first line of input is an integer
If we take
X value as 2 in the series upto 5 terms.Then the series is 2 - 23 + 25 - 27 + 29
So, the output should be
410.
Given a sentence S, write a program to print the frequency of each word in S. The output order should correspond with the word's input order of appearance.
Input
The input will be a single line containing a sentence S.
Output
The output contains multiple lines, with each line containing a word and its count separated by ": " with the order of appearance in the given sentence.
Temperature Conversion
You are given the temperature T of an object in one of Celsius, Fahrenheit, and Kelvin scales.
Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.
Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.
Formula to convert from Kelvin K to Celsius C is C = K - 273.
Here "C", "F", "K" represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively.
The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space.
The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places.